[recipes/osx-fixes: 2/3] Explicitly set an app menu when not on OS X
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/osx-fixes: 2/3] Explicitly set an app menu when not on OS X
- Date: Sun, 7 May 2017 19:24:50 +0000 (UTC)
commit 6a4881bab50ef51359db2ae13d66c3d11a936f3e
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 6 20:54:36 2017 -0500
Explicitly set an app menu when not on OS X
Sadly, the prefer-app-menu heuristics don't quite work
right in all cases for windows with headerbars, which
never display a menubar. There are cases where the heuristics
expect a menubar to be displayed inside the window, and
don't provide an app menu. But with our header bar, we
always want our app menu, _except_ for the OS X case,
where we want our menubar with the platform-provided
app mnenu.
src/gr-app.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 6d04b3c..e85769d 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -35,6 +35,9 @@
#include "gr-utils.h"
#include "gr-recipe-exporter.h"
+#ifdef GDK_WINDOWING_QUARTZ
+#include <gdk/gdkquartz.h>
+#endif
struct _GrApp
{
@@ -353,6 +356,21 @@ gr_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.search('')", search_accels);
+#ifdef GDK_WINDOWING_QUARTZ
+ if (GDK_IS_QUARTZ_DISPLAY (gdk_display_get_default ())) {
+ g_debug ("Not setting an app menu on OS X");
+ }
+ else
+#endif
+ {
+ g_autoptr(GtkBuilder) builder = NULL;
+ GObject *menu;
+
+ builder = gtk_builder_new_from_resource ("/org/gnome/Recipes/gtk/menus-appmenu.ui");
+ menu = gtk_builder_get_object (builder, "app-menu");
+ gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (menu));
+ }
+
load_application_css (GR_APP (app));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]