application-window: try to use the desktop name in the fallback menu

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
This commit is contained in:
Cosimo Cecchi
2012-04-11 10:24:04 -04:00
committed by Matthias Clasen
parent 1713cbe8d0
commit 398ba38cfe
2 changed files with 29 additions and 1 deletions

View 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=

View File

@ -35,6 +35,10 @@
#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);
}
}
}