mirror of https://github.com/GNOME/gimp.git
app, menus: add an application menu for systems which wants this.
In particular on macOS, we want to show some default common actions (see comments in !837) but gtk_application_prefers_app_menu() docs says that it will always return FALSE on this OS. So we ignore this call on macOS.
This commit is contained in:
parent
634bb0836e
commit
a752ad5e07
|
@ -351,6 +351,7 @@ gimp_image_window_constructed (GObject *object)
|
|||
GimpGuiConfig *config;
|
||||
GimpMenuModel *model;
|
||||
gboolean use_gtk_menubar = TRUE;
|
||||
gboolean use_app_menu = TRUE;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -425,6 +426,25 @@ gimp_image_window_constructed (GObject *object)
|
|||
window);
|
||||
}
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
/* Docs says that macOS always returns FALSE but we actually want to create
|
||||
* our custom macOS menu.
|
||||
*/
|
||||
use_app_menu = gtk_application_prefers_app_menu (GTK_APPLICATION (private->gimp->app));
|
||||
#endif /* !GDK_WINDOWING_QUARTZ */
|
||||
|
||||
if (use_app_menu)
|
||||
{
|
||||
GimpUIManager *app_menu_manager;
|
||||
GimpMenuModel *app_menu_model;
|
||||
|
||||
app_menu_manager = gimp_menu_factory_get_manager (menus_get_global_menu_factory (private->gimp),
|
||||
"<AppMenu>", private->gimp);
|
||||
app_menu_model = gimp_ui_manager_get_model (app_menu_manager, "/app-menu");
|
||||
gtk_application_set_app_menu (GTK_APPLICATION (private->gimp->app),
|
||||
G_MENU_MODEL (app_menu_model));
|
||||
}
|
||||
|
||||
/* Create the hbox that contains docks and images */
|
||||
private->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (private->main_vbox), private->hbox,
|
||||
|
|
|
@ -98,6 +98,14 @@ menus_init (Gimp *gimp)
|
|||
"quick-mask-menu", NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<AppMenu>",
|
||||
"file",
|
||||
"dialogs",
|
||||
NULL,
|
||||
"/app-menu",
|
||||
"app-menu", NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Toolbox>",
|
||||
"file",
|
||||
"context",
|
||||
|
|
|
@ -10,6 +10,7 @@ menudata_built_files = $(menudata_in_files:.ui.in.in=.ui)
|
|||
|
||||
menudata_DATA = \
|
||||
$(menudata_built_files) \
|
||||
app-menu.ui \
|
||||
brush-editor-menu.ui \
|
||||
brushes-menu.ui \
|
||||
buffers-menu.ui \
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<interface>
|
||||
<menu id="/app-menu">
|
||||
<item><attribute name="action">app.dialogs-about</attribute></item>
|
||||
<item><attribute name="action">app.dialogs-welcome</attribute></item>
|
||||
<section>
|
||||
<item><attribute name="action">app.dialogs-preferences</attribute></item>
|
||||
<item><attribute name="action">app.dialogs-input-devices</attribute></item>
|
||||
<item><attribute name="action">app.dialogs-keyboard-shortcuts</attribute></item>
|
||||
</section>
|
||||
<item><attribute name="action">app.file-quit</attribute></item>
|
||||
</menu>
|
||||
</interface>
|
|
@ -1,6 +1,7 @@
|
|||
menus_dir = prefix / gimpdatadir / 'menus'
|
||||
|
||||
ui_menus_files = files(
|
||||
'app-menu.ui',
|
||||
'brush-editor-menu.ui',
|
||||
'brushes-menu.ui',
|
||||
'buffers-menu.ui',
|
||||
|
|
Loading…
Reference in New Issue