menus: add dashboard-menu with proper placeholder support.

This commit is contained in:
Jehan 2023-03-01 16:09:10 +01:00
parent 987f86a218
commit e800159847
5 changed files with 65 additions and 16 deletions

View File

@ -5001,30 +5001,21 @@ void
gimp_dashboard_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
guint merge_id;
Group group;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
merge_id = gimp_ui_manager_new_merge_id (manager);
for (group = FIRST_GROUP; group < N_GROUPS; group++)
{
const GroupInfo *group_info = &groups[group];
gchar *action_name;
gchar *action_path;
action_name = g_strdup_printf ("dashboard-group-%s", group_info->name);
action_path = g_strdup_printf ("%s/Groups/Groups", ui_path);
/* TODO GMenu: for the "/dashboard-popup/Groups/" apparently. */
gimp_ui_manager_add_ui (manager, merge_id,
action_path, action_name, action_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
gimp_ui_manager_add_ui2 (manager, "/Dashboard Menu/Groups",
action_name, "Groups", FALSE);
g_free (action_name);
g_free (action_path);
}
}

View File

@ -109,6 +109,10 @@ static gchar ** gimp_menu_shell_break_path (GimpMenuShell *
const gchar *path);
static gchar * gimp_menu_shell_make_canonical_path (const gchar *path);
static gboolean gimp_menu_shell_copy_placeholders (gpointer key,
gpointer item,
GTree *placeholders);
G_DEFINE_INTERFACE (GimpMenuShell, gimp_menu_shell, GTK_TYPE_MENU_SHELL)
@ -189,8 +193,12 @@ gimp_menu_shell_merge (GimpMenuShell *shell,
g_object_unref (item);
}
g_list_free (children);
g_tree_foreach (GET_PRIVATE (shell2)->placeholders,
(GTraverseFunc) gimp_menu_shell_copy_placeholders,
GET_PRIVATE (shell)->placeholders);
gtk_widget_destroy (GTK_WIDGET (shell2));
g_list_free (children);
}
@ -877,3 +885,12 @@ gimp_menu_shell_make_canonical_path (const gchar *path)
return canon_path;
}
static gboolean
gimp_menu_shell_copy_placeholders (gpointer key,
gpointer item,
GTree *placeholders)
{
g_tree_insert (placeholders, g_strdup ((gchar *) key), item);
return FALSE;
}

View File

@ -742,7 +742,7 @@ gimp_ui_manager_ui_popup_at_widget (GimpUIManager *manager,
model = gimp_ui_manager_get_model (manager, ui_path);
menu = gimp_menu_new (manager);
gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, NULL, TRUE);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, "ui-added", TRUE);
if (! menu)
return;
@ -755,7 +755,7 @@ gimp_ui_manager_ui_popup_at_widget (GimpUIManager *manager,
/* TODO GMenu: the "icon" attribute set in the .ui file should be visible. */
child_model = gimp_ui_manager_get_model (child_ui_manager, child_ui_path);
child_menu = gimp_menu_new (child_ui_manager);
gimp_menu_shell_fill (GIMP_MENU_SHELL (child_menu), child_model, NULL, FALSE);
gimp_menu_shell_fill (GIMP_MENU_SHELL (child_menu), child_model, "ui-added", FALSE);
gimp_menu_shell_merge (GIMP_MENU_SHELL (menu), GIMP_MENU_SHELL (child_menu), TRUE);
}
@ -795,7 +795,7 @@ gimp_ui_manager_ui_popup_at_pointer (GimpUIManager *manager,
model = gimp_ui_manager_get_model (manager, ui_path);
menu = gimp_menu_new (manager);
gtk_menu_attach_to_widget (GTK_MENU (menu), attached_widget, NULL);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, NULL, TRUE);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, "ui-added", TRUE);
if (! menu)
return;
@ -836,7 +836,7 @@ gimp_ui_manager_ui_popup_at_rect (GimpUIManager *manager,
model = gimp_ui_manager_get_model (manager, ui_path);
menu = gimp_menu_new (manager);
gtk_menu_attach_to_widget (GTK_MENU (menu), attached_widget, NULL);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, NULL, TRUE);
gimp_menu_shell_fill (GIMP_MENU_SHELL (menu), model, "ui-added", TRUE);
if (! menu)
return;

40
menus/dashboard-menu.ui Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<interface>
<menu id="/dashboard-popup">
<submenu>
<attribute name="label" translatable="yes" context="dashboard-action">Dashboard Menu</attribute>
<attribute name="icon">gimp-dashboard</attribute>
<submenu>
<attribute name="label" translatable="yes" context="dashboard-action">Groups</attribute>
<!-- Placeholder for recently used filters and plug-ins. -->
<item><attribute name="label" translatable="no">Groups</attribute></item>
</submenu>
<submenu>
<attribute name="label" translatable="yes" context="dashboard-action">_Update Interval</attribute>
<item><attribute name="action">app.dashboard-update-interval-0-25-sec</attribute></item>
<item><attribute name="action">app.dashboard-update-interval-0-5-sec</attribute></item>
<item><attribute name="action">app.dashboard-update-interval-1-sec</attribute></item>
<item><attribute name="action">app.dashboard-update-interval-2-sec</attribute></item>
<item><attribute name="action">app.dashboard-update-interval-4-sec</attribute></item>
</submenu>
<submenu>
<attribute name="label" translatable="yes" context="dashboard-action">_History Duration</attribute>
<item><attribute name="action">app.dashboard-history-duration-15-sec</attribute></item>
<item><attribute name="action">app.dashboard-history-duration-30-sec</attribute></item>
<item><attribute name="action">app.dashboard-history-duration-60-sec</attribute></item>
<item><attribute name="action">app.dashboard-history-duration-120-sec</attribute></item>
<item><attribute name="action">app.dashboard-history-duration-240-sec</attribute></item>
</submenu>
<section>
<item><attribute name="action">app.dashboard-log-record</attribute></item>
<item><attribute name="action">app.dashboard-log-add-marker</attribute></item>
<item><attribute name="action">app.dashboard-log-add-empty-marker</attribute></item>
</section>
<section>
<item><attribute name="action">app.dashboard-reset</attribute></item>
</section>
<item><attribute name="action">app.dashboard-low-swap-space-warning</attribute></item>
</submenu>
</menu>
</interface>

View File

@ -44,6 +44,7 @@ ui_menus_files = files(
'buffers-menu.ui',
'channels-menu.ui',
'colormap-menu.ui',
'dashboard-menu.ui',
'documents-menu.ui',
'dynamics-menu.ui',
'error-console-menu.ui',