diff options
author | Ryan Lortie <desrt@desrt.ca> | 2014-06-30 12:16:19 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-07-02 20:17:34 -0400 |
commit | d3b34d3cf2caa19dc67e99df67c4b8cc1d4455df (patch) | |
tree | 610a3b9b8916971e1d99efdb7c6c447e02533715 /gtk/gtkapplication-dbus.c | |
parent | d8934ea23325ffb01e74529112b793b1f9939729 (diff) | |
download | gtk+-d3b34d3cf2caa19dc67e99df67c4b8cc1d4455df.tar.gz |
Add gtk_application_prefers_app_menu()
Applications can call this to determine if they should an app menu.
This will be %FALSE on desktop environments that do not have an
application menu like the one in gnome-shell. It is %FALSE on Windows
and Mac OS.
Applications are completely free to totally ignore this API -- it is
only provided as a hint to help applications that may be interested in
supporting non-GNOME platforms with a more native 'look and feel'.
https://bugzilla.gnome.org/show_bug.cgi?id=722092
Diffstat (limited to 'gtk/gtkapplication-dbus.c')
-rw-r--r-- | gtk/gtkapplication-dbus.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c index 09afcfa015..60d4edddf0 100644 --- a/gtk/gtkapplication-dbus.c +++ b/gtk/gtkapplication-dbus.c @@ -23,6 +23,7 @@ #include "config.h" #include "gtkapplicationprivate.h" +#include "gtksettings.h" G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL) @@ -411,6 +412,38 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl, return inhibited; } +static gboolean +gtk_application_impl_dbus_prefers_app_menu (GtkApplicationImpl *impl) +{ + static gboolean decided; + static gboolean result; + + /* We do not support notifying if/when the result changes, so make + * sure that once we give an answer, we will always give the same one. + */ + if (!decided) + { + GtkSettings *gtk_settings; + gboolean show_app_menu; + gboolean show_menubar; + + gtk_settings = gtk_settings_get_default (); + g_object_get (G_OBJECT (gtk_settings), + "gtk-shell-shows-app-menu", &show_app_menu, + "gtk-shell-shows-menubar", &show_menubar, + NULL); + + /* We prefer traditional menus when we have a shell that doesn't + * show the appmenu or we have a shell that shows menubars + * (ie: Unity) + */ + result = show_app_menu && !show_menubar; + decided = TRUE; + } + + return result; +} + static void gtk_application_impl_dbus_init (GtkApplicationImplDBus *dbus) { @@ -446,6 +479,7 @@ gtk_application_impl_dbus_class_init (GtkApplicationImplDBusClass *class) impl_class->inhibit = gtk_application_impl_dbus_inhibit; impl_class->uninhibit = gtk_application_impl_dbus_uninhibit; impl_class->is_inhibited = gtk_application_impl_dbus_is_inhibited; + impl_class->prefers_app_menu = gtk_application_impl_dbus_prefers_app_menu; gobject_class->finalize = gtk_application_impl_dbus_finalize; } |