[gtk-mac-integration] Bug 709427 - gtk-mac-integration: app menu issues in 2.0.4



commit 71bf0c443ab6c90ccf6262e07d9d066643ed3fc3
Author: John Ralls <jralls ceridwen us>
Date:   Fri Oct 4 13:09:01 2013 -0700

    Bug 709427 - gtk-mac-integration: app menu issues in 2.0.4
    
    Remove the capitalization of the application name string and
    use a more robust method to find the application name.

 src/gtkosxapplication_quartz.c |   32 ++++++++++++++++++++++++++------
 src/test-integration.c         |    4 ++++
 2 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/gtkosxapplication_quartz.c b/src/gtkosxapplication_quartz.c
index 8226dc1..77d1255 100644
--- a/src/gtkosxapplication_quartz.c
+++ b/src/gtkosxapplication_quartz.c
@@ -159,6 +159,24 @@ add_to_menubar (GtkosxApplication *self, NSMenu *menu, int pos)
     [menubar insertItem: dummyItem atIndex: pos];
   return dummyItem;
 }
+static NSString*
+get_application_name (void)
+{
+  NSString *appname = nil;
+  NSBundle *bundle = [NSBundle mainBundle];
+  NSString *path = nil;
+  if ([bundle bundleIdentifier])
+    {
+      NSString *bundlep = [bundle bundlePath];
+      appname =  [[NSFileManager defaultManager] displayNameAtPath: bundlep];
+    }
+  else
+    {
+      NSString *exepath = [bundle executablePath];
+      appname =  [[NSFileManager defaultManager] displayNameAtPath: exepath];
+    }
+  return appname;
+}
 
 /*
  * create_apple_menu:
@@ -186,9 +204,12 @@ create_apple_menu (GtkosxApplication *self)
                                                @"GtkOSXApplication",
                                                @"Services Menu title");
   NSMenu *menuServices = [[[NSMenu alloc] initWithTitle: title] autorelease];
-  NSString *appname = [[[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"] 
capitalizedString];
+  NSString *appname = get_application_name ();
+  /*
+  NSString *appname = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
   if (appname == nil)
     appname = [[[NSProcessInfo processInfo] processName] capitalizedString];
+  */
   [NSApp setServicesMenu: menuServices];
 
   [app_menu addItem: [NSMenuItem separatorItem]];
@@ -749,12 +770,11 @@ gtkosx_application_insert_app_menu_item (GtkosxApplication* self,
     zero'th item, it's the About item. */
   if (index == 0)
     {
-      gchar *label = gtk_menu_item_get_label (GTK_MENU_ITEM (item));
+      GtkWidget *widgetLabel = NULL;
+      gchar *label = get_menu_label_text (item, &widgetLabel);
       gchar *appname;
-      NSString *nsappname = [[[NSBundle mainBundle] localizedInfoDictionary] 
objectForKey:@"CFBundleDisplayName"];
-      if (nsappname == nil)
-       nsappname = [[NSProcessInfo processInfo] processName];
-      appname = [[nsappname capitalizedString] UTF8String];
+      NSString *nsappname = get_application_name ();
+      appname = [nsappname UTF8String];
       gtk_menu_item_set_label (GTK_MENU_ITEM (item), g_strdup_printf ("%s %s", label, appname));
     }
 
diff --git a/src/test-integration.c b/src/test-integration.c
index 56f0575..448d535 100644
--- a/src/test-integration.c
+++ b/src/test-integration.c
@@ -367,7 +367,11 @@ test_setup_menu (MenuItems *items, GtkAccelGroup *accel)
   menu = gtk_menu_new ();
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
 
+#ifndef HAVE_GTK_310
+  items->about_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+#else
   items->about_item = gtk_menu_item_new_with_label ("About");
+#endif
   g_signal_connect_data (items->about_item, "activate",
                          G_CALLBACK (menu_item_activate_cb),
                          menu_cbdata_new ("about", items->window),


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