[gimp/gimp-2-10] Move macos menu init to the gui related code and reparent it with a main window.



commit eb4b8fbd05f1257ced0a30638c348f3e6ccc085a
Author: Oleksii Samorukov <samm os2 kiev ua>
Date:   Fri Jan 10 11:03:01 2020 +0100

    Move macos menu init to the gui related code and reparent it with a main window.
    
    Closes #1258

 app/gui/gui.c | 116 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 59 insertions(+), 57 deletions(-)
---
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 2b372c4bd6..6657fcacde 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -628,63 +628,6 @@ gui_restore_after_callback (Gimp               *gimp,
 
   gimp_action_history_init (gimp);
 
-#ifdef GDK_WINDOWING_QUARTZ
-  {
-    GtkosxApplication *osx_app;
-    GtkWidget         *menu;
-    GtkWidget         *item;
-
-    [[NSUserDefaults standardUserDefaults] setObject:@"NO"
-                                           forKey:@"NSTreatUnknownArgumentsAsOpen"];
-
-    osx_app = gtkosx_application_get ();
-
-    menu = gimp_ui_manager_get_widget (image_ui_manager,
-                                       "/image-menubar");
-    if (GTK_IS_MENU_ITEM (menu))
-      menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
-
-    /* do not activate OSX menu if tests are running */
-    if (!getenv("GIMP_TESTING_ABS_TOP_SRCDIR"))
-      gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu));
-
-    gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE);
-
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         "/image-menubar/Help/dialogs-about", 0);
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         "/image-menubar/Help/dialogs-search-action", 1);
-
-#define PREFERENCES "/image-menubar/Edit/Preferences/"
-
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         PREFERENCES "dialogs-preferences", 3);
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         PREFERENCES "dialogs-input-devices", 4);
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         PREFERENCES "dialogs-keyboard-shortcuts", 5);
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         PREFERENCES "dialogs-module-dialog", 6);
-    gui_add_to_app_menu (image_ui_manager, osx_app,
-                         PREFERENCES "plug-in-unit-editor", 7);
-
-#undef PREFERENCES
-
-    item = gtk_separator_menu_item_new ();
-    gtkosx_application_insert_app_menu_item (osx_app, item, 8);
-
-    item = gimp_ui_manager_get_widget (image_ui_manager,
-                                       "/image-menubar/File/file-quit");
-    gtk_widget_hide (item);
-
-    g_signal_connect (osx_app, "NSApplicationBlockTermination",
-                      G_CALLBACK (gui_quartz_quit_callback),
-                      image_ui_manager);
-
-    gtkosx_application_ready (osx_app);
-  }
-#endif /* GDK_WINDOWING_QUARTZ */
-
   g_signal_connect_object (gui_config, "notify::single-window-mode",
                            G_CALLBACK (gui_single_window_mode_notify),
                            ui_configurer, 0);
@@ -724,6 +667,65 @@ gui_restore_after_callback (Gimp               *gimp,
 
       /*  move keyboard focus to the display  */
       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
+#ifdef GDK_WINDOWING_QUARTZ
+        {
+          GtkosxApplication *osx_app;
+          GtkWidget         *menu;
+          GtkWidget         *item;
+
+          [[NSUserDefaults standardUserDefaults] setObject:@"NO"
+                                                 forKey:@"NSTreatUnknownArgumentsAsOpen"];
+
+          osx_app = gtkosx_application_get ();
+
+          menu = gimp_ui_manager_get_widget (image_ui_manager,
+                                             "/image-menubar");
+          /* menu should have window parent for accelerator support */
+          gtk_widget_set_parent(menu, toplevel);
+
+          if (GTK_IS_MENU_ITEM (menu))
+            menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
+
+          /* do not activate OSX menu if tests are running */
+          if (!getenv("GIMP_TESTING_ABS_TOP_SRCDIR"))
+            gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu));
+
+          gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE);
+
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               "/image-menubar/Help/dialogs-about", 0);
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               "/image-menubar/Help/dialogs-search-action", 1);
+
+#define PREFERENCES "/image-menubar/Edit/Preferences/"
+
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               PREFERENCES "dialogs-preferences", 3);
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               PREFERENCES "dialogs-input-devices", 4);
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               PREFERENCES "dialogs-keyboard-shortcuts", 5);
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               PREFERENCES "dialogs-module-dialog", 6);
+          gui_add_to_app_menu (image_ui_manager, osx_app,
+                               PREFERENCES "plug-in-unit-editor", 7);
+
+#undef PREFERENCES
+
+          item = gtk_separator_menu_item_new ();
+          gtkosx_application_insert_app_menu_item (osx_app, item, 8);
+
+          item = gimp_ui_manager_get_widget (image_ui_manager,
+                                             "/image-menubar/File/file-quit");
+          gtk_widget_hide (item);
+
+          g_signal_connect (osx_app, "NSApplicationBlockTermination",
+                            G_CALLBACK (gui_quartz_quit_callback),
+                            image_ui_manager);
+
+          gtkosx_application_ready (osx_app);
+        }
+#endif /* GDK_WINDOWING_QUARTZ */
       gtk_window_present (GTK_WINDOW (toplevel));
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]