From: Colin Clark Date: Sat, 7 Nov 2020 14:40:47 +0000 (+0000) Subject: Ref #820: Problem with window in the current build X-Git-Tag: v1.6~6 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=581d8ef0912d18e53422d1c4cf884695ca4b7e86 Ref #820: Problem with window in the current build https://github.com/BestImageViewer/geeqie/issues/820 Remove the requirement for a "main" window. --- diff --git a/src/layout.c b/src/layout.c index 9c45ef5a..1e5bc887 100644 --- a/src/layout.c +++ b/src/layout.c @@ -181,12 +181,6 @@ static void layout_set_unique_id(LayoutWindow *lw) g_free(lw->options.id); lw->options.id = NULL; - if (!layout_find_by_layout_id("main")) - { - lw->options.id = g_strdup("main"); - return; - } - i = 1; while (TRUE) { @@ -2420,7 +2414,7 @@ void save_layout(LayoutWindow *lw) gchar *path; gchar *xml_name; - if (!g_str_has_prefix(lw->options.id, "lw") && !g_str_equal(lw->options.id, "main")) + if (!g_str_has_prefix(lw->options.id, "lw")) { xml_name = g_strdup_printf("%s.xml", lw->options.id); path = g_build_filename(get_window_layouts_dir(), xml_name, NULL); @@ -2438,30 +2432,8 @@ void layout_close(LayoutWindow *lw) if (layout_window_list && layout_window_list->next) { - if (g_strcmp0(lw->options.id, "main") == 0) - { - while (layout_window_list && layout_window_list->next) - { - list = layout_window_list; - while (list) - { - tmp_lw = list->data; - if (g_strcmp0(tmp_lw->options.id, "main") != 0) - { - save_layout(list->data); - layout_free(list->data); - break; - } - list = list->next; - } - } - exit_program(); - } - else - { - save_layout(lw); - layout_free(lw); - } + save_layout(lw); + layout_free(lw); } else { @@ -2933,6 +2905,8 @@ static void layout_config_commandline(LayoutOptions *lop, gchar **path) } } +static gboolean first_found = FALSE; + LayoutWindow *layout_new_from_config(const gchar **attribute_names, const gchar **attribute_values, gboolean use_commandline) { LayoutOptions lop; @@ -2946,8 +2920,9 @@ LayoutWindow *layout_new_from_config(const gchar **attribute_names, const gchar /* If multiple windows are specified in the config. file, * use the command line options only in the main window. */ - if (use_commandline && (g_strcmp0(lop.id, "main") == 0)) + if (use_commandline && !first_found) { + first_found = TRUE; layout_config_commandline(&lop, &path); } else diff --git a/src/layout_image.c b/src/layout_image.c index 66870fde..cc61feff 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -2137,7 +2137,7 @@ void layout_image_activate(LayoutWindow *lw, gint i, gboolean force) layout_image_set_buttons(lw); image_set_drag_func(lw->image, layout_image_drag_cb, lw); - image_attach_window(lw->image, lw->window, NULL, g_strcmp0(lw->options.id, "main") == 0 ? GQ_APPNAME : GQ_APPNAME_LC, FALSE); + image_attach_window(lw->image, lw->window, NULL, GQ_APPNAME, FALSE); /* do not hilight selected image in SPLIT_NONE */ /* maybe the image should be selected always and hilight should be controled by diff --git a/src/layout_util.c b/src/layout_util.c index d32df518..b24f6e29 100644 --- a/src/layout_util.c +++ b/src/layout_util.c @@ -2248,15 +2248,15 @@ static void layout_menu_windows_menu_cb(GtkWidget *widget, gpointer data) menu = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/WindowsMenu/"); sub_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu)); - /* disable Rename and Delete for main window */ - if (g_strcmp0(lw->options.id, "main") == 0) + /* disable Delete for temporary windows */ + if (g_str_has_prefix(lw->options.id, "lw")) { i = 0; children = gtk_container_get_children(GTK_CONTAINER(sub_menu)); for (iter = children; iter != NULL; iter = g_list_next(iter), i++) { menu_label = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(iter->data))); - if (g_strcmp0(menu_label, _("Delete window")) == 0 || g_strcmp0(menu_label, _("Rename window")) == 0) + if (g_strcmp0(menu_label, _("Delete window")) == 0) { gtk_widget_set_sensitive(GTK_WIDGET(iter->data), FALSE); } diff --git a/src/main.c b/src/main.c index 92207031..f497240d 100644 --- a/src/main.c +++ b/src/main.c @@ -754,6 +754,8 @@ static void gtkrc_load(void) static void exit_program_final(void) { LayoutWindow *lw = NULL; + GList *list; + LayoutWindow *tmp_lw; /* make sure that external editors are loaded, we would save incomplete configuration otherwise */ layout_editors_reload_finish(); @@ -762,6 +764,21 @@ static void exit_program_final(void) collect_manager_flush(); + /* Save the named windows */ + if (layout_window_list && layout_window_list->next) + { + list = layout_window_list; + while (list) + { + tmp_lw = list->data; + if (!g_str_has_prefix(tmp_lw->options.id, "lw")) + { + save_layout(list->data); + } + list = list->next; + } + } + save_options(options); keys_save(); accel_map_save(); diff --git a/src/remote.c b/src/remote.c index e4249d8b..78634cf9 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1269,11 +1269,7 @@ static void gr_pwd(const gchar *text, GIOChannel *channel, gpointer data) { LayoutWindow *lw = NULL; - lw = layout_find_by_layout_id("main"); - if (!lw) - { - lw = g_list_first(layout_window_list)->data; - } + layout_valid(&lw); g_free(pwd); pwd = g_strdup(text);