From: Colin Clark Date: Fri, 15 Mar 2024 14:19:38 +0000 (+0000) Subject: Aditional remote command - window list X-Git-Tag: v2.4~12 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=68356f5f583b47eac5e77e29797130b0e64f2382 Aditional remote command - window list --- diff --git a/src/layout.cc b/src/layout.cc index f955399d..df0403f8 100644 --- a/src/layout.cc +++ b/src/layout.cc @@ -241,6 +241,41 @@ static void layout_box_folders_changed_cb(GtkWidget *widget, gpointer) } } +static gint window_list_sort_cb(gconstpointer a, gconstpointer b) +{ + return CASE_SORT((gchar *)a, (gchar *)b); +} + +GString *layout_get_window_list() +{ + LayoutWindow *lw; + GList *work; + GList *window_list = nullptr; + GString *ret = g_string_new(nullptr); + + work = layout_window_list; + while (work) + { + lw = static_cast(work->data); + window_list = g_list_insert_sorted(window_list, g_strdup(lw->options.id), window_list_sort_cb); + work = work->next; + } + + work = g_list_first(window_list); + g_string_append_printf(ret, "%s", (gchar *)work->data); + work = work->next; + + while (work) + { + g_string_append_printf(ret, "\n%s", (gchar *)work->data); + work = work->next; + } + + g_list_free(window_list); + + return ret; +} + /* *----------------------------------------------------------------------------- * menu, toolbar, and dir view diff --git a/src/layout.h b/src/layout.h index 711c1474..78141e14 100644 --- a/src/layout.h +++ b/src/layout.h @@ -192,6 +192,7 @@ guint layout_list_count(LayoutWindow *lw, gint64 *bytes); FileData *layout_list_get_fd(LayoutWindow *lw, gint index); gint layout_list_get_index(LayoutWindow *lw, FileData *fd); void layout_list_sync_fd(LayoutWindow *lw, FileData *fd); +GString *layout_get_window_list(); GList *layout_selection_list(LayoutWindow *lw); /* return list of pointers to int for selection */ diff --git a/src/remote.cc b/src/remote.cc index 7d47b178..e1102fd5 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -1426,6 +1426,18 @@ static void gr_config_load(const gchar *text, GIOChannel *, gpointer) g_free(filename); } +static void gr_window_list(const gchar *, GIOChannel *channel, gpointer) +{ + GString *window_list; + + window_list = layout_get_window_list(); + + g_io_channel_write_chars(channel, window_list->str, -1, nullptr, nullptr); + g_io_channel_write_chars(channel, "", -1, nullptr, nullptr); + + g_string_free(window_list, TRUE); +} + static void gr_get_sidecars(const gchar *text, GIOChannel *channel, gpointer) { gchar *filename = expand_tilde(text); @@ -1739,6 +1751,7 @@ static RemoteCommandEntry remote_commands[] = { { nullptr, "--get-render-intent", gr_render_intent, FALSE, FALSE, nullptr, N_("get render intent") }, { nullptr, "--get-selection", gr_get_selection, FALSE, FALSE, nullptr, N_("get list of selected files") }, { nullptr, "--get-sidecars:", gr_get_sidecars, TRUE, FALSE, N_(""), N_("get list of sidecars of FILE") }, + { nullptr, "--get-window-list", gr_window_list, FALSE, FALSE, nullptr, N_("get window list") }, { nullptr, "--id:", gr_lw_id, TRUE, FALSE, N_(""), N_("window id for following commands") }, { nullptr, "--last", gr_image_last, FALSE, FALSE, nullptr, N_("last image") }, { nullptr, "--list-add:", gr_list_add, TRUE, FALSE, N_(""), N_("add FILE to command line collection list") },