]> Pileus Git - ~andy/gtk/commitdiff
application-window: try to use the desktop name in the fallback menu
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 11 Apr 2012 14:24:04 +0000 (10:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 13 Apr 2012 01:41:46 +0000 (21:41 -0400)
Try to fetch the name from the application desktop file for the
fallback menu if possible, instead of forcing applications to use
g_set_application_name or hardcoding "Application".

https://bugzilla.gnome.org/show_bug.cgi?id=673882

configure.ac
gtk/gtkapplicationwindow.c

index f94997b726473ec9cd2c01e2836b607777242f29..5f23a73bc7761be1306459c23180abcfc23c7a96 100644 (file)
@@ -1292,6 +1292,9 @@ GTK_PRIVATE_PACKAGES=""
 if test "x$enable_x11_backend" = xyes; then
   GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
 fi
+if test "$have_gio_unix" = "yes"; then
+  GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES gio-unix-2.0"
+fi
 GTK_EXTRA_LIBS=
 
 GTK_EXTRA_CFLAGS=
index 04b947109433552e335e788fc1571979e5d752e1..7037a0a9229e5a2aa5519405f93fdc788181fecf 100644 (file)
 #include <gdk/x11/gdkx.h>
 #endif
 
+#ifdef HAVE_GIO_UNIX
+#include <gio/gdesktopappinfo.h>
+#endif
+
 /**
  * SECTION:gtkapplicationwindow
  * @title: GtkApplicationWindow
@@ -279,11 +283,32 @@ gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window
           if (app_menu != NULL)
             {
               const gchar *name;
+              GDesktopAppInfo *app_info = NULL;
 
               name = g_get_application_name ();
               if (name == g_get_prgname ())
-                name = _("Application");
+                {
+                  const gchar *app_name = NULL;
+
+#ifdef HAVE_GIO_UNIX
+                  gchar *desktop_name;
+
+                  desktop_name = g_strconcat (name, ".desktop", NULL);
+                  app_info = g_desktop_app_info_new (desktop_name);
+                  if (app_info != NULL)
+                    app_name = g_app_info_get_name (G_APP_INFO (app_info));
+
+                  g_free (desktop_name);
+#endif /* HAVE_GIO_UNIX */
+
+                  if (app_name != NULL &&
+                      g_strcmp0 (app_name, name) != 0)
+                    name = app_name;
+                  else
+                    name = _("Application");
+                }
               g_menu_append_submenu (window->priv->app_menu_section, name, app_menu);
+              g_clear_object (&app_info);
             }
         }
     }