app: only show the new menubar now.

This commit is contained in:
Jehan 2023-02-22 17:07:32 +01:00
parent 6ecfc4a77b
commit 8ec589915a
5 changed files with 82 additions and 78 deletions

View file

@ -117,7 +117,6 @@ struct _GimpImageWindowPrivate
GimpDisplayShell *active_shell;
GtkWidget *main_vbox;
GtkWidget *new_menubar;
GtkWidget *menubar;
GtkWidget *hbox;
GtkWidget *left_hpane;
@ -349,9 +348,7 @@ gimp_image_window_constructed (GObject *object)
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
GimpMenuFactory *menu_factory;
GimpGuiConfig *config;
GtkBuilder *builder;
GMenuModel *model;
gchar *filename;
G_OBJECT_CLASS (parent_class)->constructed (object);
@ -389,11 +386,8 @@ gimp_image_window_constructed (GObject *object)
gtk_widget_show (private->main_vbox);
/* Create the menubar */
filename = g_build_filename (gimp_data_directory (), "menus",
"image-menu.ui", NULL);
builder = gtk_builder_new_from_file (filename);
model = G_MENU_MODEL (gtk_builder_get_object (builder, "/image-menubar"));
model = gimp_ui_manager_get_model (private->menubar_manager,
"/image-menubar");
#ifdef GDK_WINDOWING_QUARTZ
/* macOS has its native menubar system, and this should support it. It means
@ -403,9 +397,7 @@ gimp_image_window_constructed (GObject *object)
*/
gtk_application_set_menubar (private->gimp->app, G_MENU_MODEL (model));
#else
/* TODO: this is the old menubar system. It should go away soon. */
private->menubar = gimp_ui_manager_get_widget (private->menubar_manager,
"/image-menubar");
private->menubar = gimp_menu_new (model, private->menubar_manager);
gtk_box_pack_start (GTK_BOX (private->main_vbox),
private->menubar, FALSE, FALSE, 0);
@ -427,34 +419,8 @@ gimp_image_window_constructed (GObject *object)
g_signal_connect (private->menubar, "key-press-event",
G_CALLBACK (gimp_image_window_shell_events),
window);
private->new_menubar = gimp_menu_new (model, private->menubar_manager);
gtk_box_pack_start (GTK_BOX (private->main_vbox),
private->new_menubar, FALSE, FALSE, 0);
/* make sure we can activate accels even if the menubar is invisible
* (see https://bugzilla.gnome.org/show_bug.cgi?id=137151)
*/
g_signal_connect (private->new_menubar, "can-activate-accel",
G_CALLBACK (gtk_true),
NULL);
/* active display callback */
g_signal_connect (private->new_menubar, "button-press-event",
G_CALLBACK (gimp_image_window_shell_events),
window);
g_signal_connect (private->new_menubar, "button-release-event",
G_CALLBACK (gimp_image_window_shell_events),
window);
g_signal_connect (private->new_menubar, "key-press-event",
G_CALLBACK (gimp_image_window_shell_events),
window);
#endif /* !GDK_WINDOWING_QUARTZ */
g_object_unref (builder);
g_free (filename);
/* 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,
@ -1390,8 +1356,6 @@ gimp_image_window_set_show_menubar (GimpImageWindow *window,
if (private->menubar)
gtk_widget_set_visible (private->menubar, show);
if (private->new_menubar)
gtk_widget_set_visible (private->new_menubar, show);
}
gboolean

View file

@ -97,11 +97,11 @@ menus_init (Gimp *gimp,
"quick-mask",
NULL,
"/image-menubar",
"image-menu.xml", image_menu_setup,
"image-menu", image_menu_setup,
"/dummy-menubar",
"image-menu.xml", image_menu_setup,
"image-menu", image_menu_setup,
"/quick-mask-popup",
"quick-mask-menu.xml", NULL,
"quick-mask-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Toolbox>",
@ -151,7 +151,7 @@ menus_init (Gimp *gimp,
"filters",
NULL,
"/layers-popup",
"layers-menu.xml", plug_in_menus_setup,
"layers-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Channels>",
@ -160,7 +160,7 @@ menus_init (Gimp *gimp,
"filters",
NULL,
"/channels-popup",
"channels-menu.xml", plug_in_menus_setup,
"channels-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Vectors>",
@ -168,14 +168,14 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/vectors-popup",
"vectors-menu.xml", plug_in_menus_setup,
"vectors-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<VectorToolPath>",
"vector-toolpath",
NULL,
"/vector-toolpath-popup",
"vector-toolpath-menu.xml",
"vector-toolpath-menu",
NULL,
NULL);
@ -184,7 +184,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/colormap-popup",
"colormap-menu.xml", plug_in_menus_setup,
"colormap-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Dockable>",
@ -192,7 +192,7 @@ menus_init (Gimp *gimp,
"dock",
NULL,
"/dockable-popup",
"dockable-menu.xml", dockable_menu_setup,
"dockable-menu", dockable_menu_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Brushes>",
@ -200,7 +200,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/brushes-popup",
"brushes-menu.xml", plug_in_menus_setup,
"brushes-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Dynamics>",
@ -208,7 +208,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/dynamics-popup",
"dynamics-menu.xml", plug_in_menus_setup,
"dynamics-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<MyPaintBrushes>",
@ -216,7 +216,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/mypaint-brushes-popup",
"mypaint-brushes-menu.xml", plug_in_menus_setup,
"mypaint-brushes-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Patterns>",
@ -224,7 +224,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/patterns-popup",
"patterns-menu.xml", plug_in_menus_setup,
"patterns-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Gradients>",
@ -232,7 +232,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/gradients-popup",
"gradients-menu.xml", plug_in_menus_setup,
"gradients-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Palettes>",
@ -240,7 +240,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/palettes-popup",
"palettes-menu.xml", plug_in_menus_setup,
"palettes-menu", plug_in_menus_setup,
NULL);
@ -249,7 +249,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/tool-presets-popup",
"tool-presets-menu.xml", plug_in_menus_setup,
"tool-presets-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Fonts>",
@ -257,7 +257,7 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/fonts-popup",
"fonts-menu.xml", plug_in_menus_setup,
"fonts-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Buffers>",
@ -265,63 +265,63 @@ menus_init (Gimp *gimp,
"plug-in",
NULL,
"/buffers-popup",
"buffers-menu.xml", plug_in_menus_setup,
"buffers-menu", plug_in_menus_setup,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Documents>",
"documents",
NULL,
"/documents-popup",
"documents-menu.xml", NULL,
"documents-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Templates>",
"templates",
NULL,
"/templates-popup",
"templates-menu.xml", NULL,
"templates-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Images>",
"images",
NULL,
"/images-popup",
"images-menu.xml", NULL,
"images-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<BrushEditor>",
"brush-editor",
NULL,
"/brush-editor-popup",
"brush-editor-menu.xml", NULL,
"brush-editor-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<DynamicsEditor>",
"dynamics-editor",
NULL,
"/dynamics-editor-popup",
"dynamics-editor-menu.xml", NULL,
"dynamics-editor-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<GradientEditor>",
"gradient-editor",
NULL,
"/gradient-editor-popup",
"gradient-editor-menu.xml", NULL,
"gradient-editor-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<PaletteEditor>",
"palette-editor",
NULL,
"/palette-editor-popup",
"palette-editor-menu.xml", NULL,
"palette-editor-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<ToolPresetEditor>",
"tool-preset-editor",
NULL,
"/tool-preset-editor-popup",
"tool-preset-editor-menu.xml", NULL,
"tool-preset-editor-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Selection>",
@ -329,7 +329,7 @@ menus_init (Gimp *gimp,
"vectors",
NULL,
"/selection-popup",
"selection-menu.xml", NULL,
"selection-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<NavigationEditor>",
@ -341,21 +341,21 @@ menus_init (Gimp *gimp,
"edit",
NULL,
"/undo-popup",
"undo-menu.xml", NULL,
"undo-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<ErrorConsole>",
"error-console",
NULL,
"/error-console-popup",
"error-console-menu.xml", NULL,
"error-console-menu", NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<ToolOptions>",
"tool-options",
NULL,
"/tool-options-popup",
"tool-options-menu.xml",
"tool-options-menu",
tool_options_menu_setup,
NULL);
@ -363,7 +363,7 @@ menus_init (Gimp *gimp,
"text-editor",
NULL,
"/text-editor-toolbar",
"text-editor-toolbar.xml",
"text-editor-toolbar",
NULL,
NULL);
@ -371,7 +371,7 @@ menus_init (Gimp *gimp,
"text-tool",
NULL,
"/text-tool-popup",
"text-tool-menu.xml",
"text-tool-menu",
NULL,
NULL);
@ -379,7 +379,7 @@ menus_init (Gimp *gimp,
"cursor-info",
NULL,
"/cursor-info-popup",
"cursor-info-menu.xml",
"cursor-info-menu",
NULL,
NULL);
@ -387,7 +387,7 @@ menus_init (Gimp *gimp,
"sample-points",
NULL,
"/sample-points-popup",
"sample-points-menu.xml",
"sample-points-menu",
NULL,
NULL);
@ -395,7 +395,7 @@ menus_init (Gimp *gimp,
"dashboard",
NULL,
"/dashboard-popup",
"dashboard-menu.xml", gimp_dashboard_menu_setup,
"dashboard-menu", gimp_dashboard_menu_setup,
NULL);
}

View file

@ -90,6 +90,7 @@ gimp_menu_factory_finalize (GObject *object)
g_free (ui_entry->ui_path);
g_free (ui_entry->basename);
g_clear_object (&ui_entry->builder);
g_slice_free (GimpUIManagerUIEntry, ui_entry);
}

View file

@ -272,6 +272,7 @@ gimp_ui_manager_finalize (GObject *object)
g_free (entry->ui_path);
g_free (entry->basename);
g_clear_object (&entry->builder);
if (entry->widget)
g_object_unref (entry->widget);
@ -506,6 +507,31 @@ gimp_ui_manager_get_widget (GimpUIManager *manager,
return gtk_ui_manager_get_widget ((GtkUIManager *) manager, path);
}
GMenuModel *
gimp_ui_manager_get_model (GimpUIManager *manager,
const gchar *path)
{
GimpUIManagerUIEntry *entry;
GMenuModel *model;
gchar *filename;
gchar *full_basename;
entry = gimp_ui_manager_entry_ensure (manager, path);
full_basename = g_strconcat (entry->basename, ".ui", NULL);
filename = g_build_filename (gimp_data_directory (), "menus",
full_basename, NULL);
if (entry->builder == NULL)
/* The model is owned by the builder which I have to keep around. */
entry->builder = gtk_builder_new_from_file (filename);
model = G_MENU_MODEL (gtk_builder_get_object (entry->builder, path));
g_free (filename);
g_free (full_basename);
return model;
}
gchar *
gimp_ui_manager_get_ui (GimpUIManager *manager)
{
@ -684,6 +710,7 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
entry->setup_func = setup_func;
entry->merge_id = 0;
entry->widget = NULL;
entry->builder = NULL;
manager->registered_uis = g_list_prepend (manager->registered_uis, entry);
}
@ -846,8 +873,10 @@ gimp_ui_manager_entry_load (GimpUIManager *manager,
GError **error)
{
gchar *filename = NULL;
gchar *full_basename;
const gchar *menus_path_override = g_getenv ("GIMP_TESTING_MENUS_PATH");
full_basename = g_strconcat (entry->basename, ".xml", NULL);
/* In order for test cases to be able to run without GIMP being
* installed yet, allow them to override the menus directory to the
* menus dir in the source root
@ -859,7 +888,7 @@ gimp_ui_manager_entry_load (GimpUIManager *manager,
for (list = path; list; list = g_list_next (list))
{
filename = g_build_filename (list->data, entry->basename, NULL);
filename = g_build_filename (list->data, full_basename, NULL);
if (! list->next ||
g_file_test (filename, G_FILE_TEST_EXISTS))
@ -873,7 +902,7 @@ gimp_ui_manager_entry_load (GimpUIManager *manager,
else
{
filename = g_build_filename (gimp_data_directory (), "menus",
entry->basename, NULL);
full_basename, NULL);
}
if (manager->gimp->be_verbose)
@ -884,6 +913,7 @@ gimp_ui_manager_entry_load (GimpUIManager *manager,
filename, error);
g_free (filename);
g_free (full_basename);
if (! entry->merge_id)
return FALSE;
@ -923,11 +953,14 @@ gimp_ui_manager_entry_ensure (GimpUIManager *manager,
}
else
{
gchar *full_basename = g_strconcat (entry->basename, ".xml", NULL);
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
_("There was an error parsing the menu definition "
"from %s: %s"),
gimp_filename_to_utf8 (entry->basename),
gimp_filename_to_utf8 (full_basename),
error->message);
g_free (full_basename);
}
g_clear_error (&error);
@ -959,9 +992,12 @@ gimp_ui_manager_entry_ensure (GimpUIManager *manager,
}
else
{
gchar *full_basename = g_strconcat (entry->basename, ".xml", NULL);
g_warning ("%s: \"%s\" does not contain registered toplevel "
"widget \"%s\"",
G_STRFUNC, entry->basename, entry->ui_path);
G_STRFUNC, full_basename, entry->ui_path);
g_free (full_basename);
return NULL;
}
}

View file

@ -39,6 +39,7 @@ struct _GimpUIManagerUIEntry
GimpUIManagerSetupFunc setup_func;
guint merge_id;
GtkWidget *widget;
GtkBuilder *builder;
};
@ -107,6 +108,8 @@ GtkAccelGroup * gimp_ui_manager_get_accel_group (GimpUIManager *manager);
GtkWidget * gimp_ui_manager_get_widget (GimpUIManager *manager,
const gchar *path);
GMenuModel * gimp_ui_manager_get_model (GimpUIManager *manager,
const gchar *path);
gchar * gimp_ui_manager_get_ui (GimpUIManager *manager);