[glade/glade-3-18] osx: Use current gtk-mac-integration API



commit 62a115d0231f5fd0f47b8110251738ab14371524
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Oct 10 22:35:24 2014 -0700

    osx: Use current gtk-mac-integration API
    
    The #ifdef'd block did not compile at all because it used the old API
    from gtk-mac-integration, and because it used GtkBuilder when the
    surrounding code had been ported to use widget templates.
    
    This fixes up the use of the API and adds a few widget variables to
    GladeWindowPrivate which have to be bound to the template.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738339

 configure.ac       |    2 +-
 src/glade-window.c |   43 +++++++++++++++++++++++++------------------
 2 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0c19bdd..377ce3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -263,7 +263,7 @@ dnl ================================================================
 _gdk_tgt=`$PKG_CONFIG --variable=targets gdk-3.0`
 AM_CONDITIONAL([GDK_TARGET_QUARTZ], [test x$_gdk_tgt = xquartz])
 if test "x$_gdk_tgt" = xquartz; then 
-   PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration)
+   PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration-gtk3)
 
    GTK_MAC_BUNDLE_FLAG=
 
diff --git a/src/glade-window.c b/src/glade-window.c
index 2e36cfa..c397909 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -136,11 +136,17 @@ struct _GladeWindowPrivate
   GtkActionGroup *static_actiongroup;
   GtkActionGroup *view_actiongroup;
 
+  GtkMenuShell *menubar;
   GtkMenuShell *project_menu;
   
   GtkRecentManager *recent_manager;
   GtkWidget *recent_menu;
 
+  GtkWidget *quit_menuitem;
+  GtkWidget *about_menuitem;
+  GtkWidget *properties_menuitem;
+  GtkMenuItem *help_menuitem;
+
   gchar *default_path;          /* the default path for open/save operations */
 
   GtkToolItem *undo_toolbutton; /* customized buttons for undo/redo with history */
@@ -3274,33 +3280,29 @@ glade_window_constructed (GObject *object)
 #ifdef MAC_INTEGRATION
   {
     /* Fix up the menubar for MacOSX Quartz builds */
-    GtkWidget *menubar = GET_OBJECT (builder, GTK_WIDGET, "menubar");
-    GtkOSXApplication *theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
-    GtkWidget *sep, *widget;
-
-    gtk_widget_hide (menubar);
-    gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
-    widget = GET_OBJECT (builder, GTK_WIDGET, "quit_menuitem");
-    gtk_widget_hide (widget);
-    widget = GET_OBJECT (builder, GTK_WIDGET, "about_menuitem");
-    gtk_osxapplication_insert_app_menu_item (theApp, widget, 0);
+    GtkosxApplication *theApp = gtkosx_application_get ();
+    GtkWidget *sep;
+
+    gtk_widget_hide (priv->menubar);
+    gtkosx_application_set_menu_bar (theApp, priv->menubar);
+    gtk_widget_hide (priv->quit_menuitem);
+    gtkosx_application_insert_app_menu_item (theApp, priv->about_menuitem, 0);
     sep = gtk_separator_menu_item_new();
     g_object_ref(sep);
-    gtk_osxapplication_insert_app_menu_item (theApp, sep, 1);
+    gtkosx_application_insert_app_menu_item (theApp, sep, 1);
 
-    widget = GET_OBJECT (builder, GTK_WIDGET, "properties_menuitem");
-    gtk_osxapplication_insert_app_menu_item  (theApp, widget, 2);
+    gtkosx_application_insert_app_menu_item (theApp, priv->properties_menuitem,
+                                             2);
     sep = gtk_separator_menu_item_new();
     g_object_ref(sep);
-    gtk_osxapplication_insert_app_menu_item (theApp, sep, 3);
+    gtkosx_application_insert_app_menu_item (theApp, sep, 3);
 
-    widget = GET_OBJECT (builder, GTK_WIDGET, "help_menuitem");
-    gtk_osxapplication_set_help_menu(theApp, GTK_MENU_ITEM(widget));
+    gtkosx_application_set_help_menu (theApp, priv->help_menuitem);
 
     g_signal_connect(theApp, "NSApplicationWillTerminate",
                      G_CALLBACK(on_quit_action_activate), window);
 
-    gtk_osxapplication_ready(theApp);
+    gtkosx_application_ready (theApp);
   }
 #endif
 
@@ -3393,7 +3395,12 @@ glade_window_class_init (GladeWindowClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, pointer_mode_actiongroup);
   gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, static_actiongroup);
   gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, view_actiongroup);
-  
+  gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, menubar);
+  gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, quit_menuitem);
+  gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, properties_menuitem);
+  gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, about_menuitem);
+  gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, help_menuitem);
+
   /* Actions */
   gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, save_action);
   gtk_widget_class_bind_template_child_private (widget_class, GladeWindow, quit_action);


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