[gtk+] application-window: try to use the desktop name in the fallback menu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] application-window: try to use the desktop name in the fallback menu
- Date: Fri, 13 Apr 2012 01:53:37 +0000 (UTC)
commit 398ba38cfe159ede25edd2cd0c5a14f052b5ebea
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Apr 11 10:24:04 2012 -0400
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
configure.ac | 3 +++
gtk/gtkapplicationwindow.c | 27 ++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f94997b..5f23a73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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=
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index 04b9471..7037a0a 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -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);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]