Ref #820: Problem with window in the current build
authorColin Clark <colin.clark@cclark.uk>
Sat, 7 Nov 2020 14:40:47 +0000 (14:40 +0000)
committerColin Clark <colin.clark@cclark.uk>
Sat, 7 Nov 2020 14:40:47 +0000 (14:40 +0000)
https://github.com/BestImageViewer/geeqie/issues/820

Remove the requirement for a "main" window.

src/layout.c
src/layout_image.c
src/layout_util.c
src/main.c
src/remote.c

index 9c45ef5..1e5bc88 100644 (file)
@@ -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
index 66870fd..cc61fef 100644 (file)
@@ -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
index d32df51..b24f6e2 100644 (file)
@@ -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);
                                }
index 9220703..f497240 100644 (file)
@@ -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();
index e4249d8..78634cf 100644 (file)
@@ -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);