mirror of https://github.com/GNOME/gimp.git
app, menus: remove all placeholder code.
This is now fully replaced by the new section name code.
This commit is contained in:
parent
9ad5049dec
commit
b9b1f4c53d
|
@ -54,8 +54,8 @@ file_menu_setup (GimpUIManager *manager,
|
||||||
|
|
||||||
action_name = g_strdup_printf ("file-open-recent-%02d", i + 1);
|
action_name = g_strdup_printf ("file-open-recent-%02d", i + 1);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, "/File/Open Recent",
|
gimp_ui_manager_add_ui (manager, "/File/Open Recent/[Files]",
|
||||||
action_name, "Files", TRUE);
|
action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ filters_menu_setup (GimpUIManager *manager,
|
||||||
|
|
||||||
action_name = g_strdup_printf ("filters-recent-%02d", i + 1);
|
action_name = g_strdup_printf ("filters-recent-%02d", i + 1);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, "/Filters/Recently Used",
|
gimp_ui_manager_add_ui (manager, "/Filters/Recently Used/[Filters]",
|
||||||
action_name, "Filters", TRUE);
|
action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ filters_menu_setup (GimpUIManager *manager,
|
||||||
*root = '/';
|
*root = '/';
|
||||||
|
|
||||||
for (GList *m = managers; m; m = m->next)
|
for (GList *m = managers; m; m = m->next)
|
||||||
gimp_ui_manager_add_ui (m->data, root, gegl_actions[i], NULL, FALSE);
|
gimp_ui_manager_add_ui (m->data, root, gegl_actions[i], FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
|
|
@ -302,7 +302,7 @@ plug_in_menus_add_proc (GimpUIManager *manager,
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, menu_path,
|
gimp_ui_manager_add_ui (manager, menu_path,
|
||||||
gimp_object_get_name (proc),
|
gimp_object_get_name (proc),
|
||||||
NULL, FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -123,7 +123,7 @@ tool_options_menu_update_presets (GimpUIManager *manager,
|
||||||
action_name = g_strdup_printf ("%s%03d", action_prefix, i);
|
action_name = g_strdup_printf ("%s%03d", action_prefix, i);
|
||||||
path = g_strdup_printf ("/Tool Options Menu/%s", menu_path);
|
path = g_strdup_printf ("/Tool Options Menu/%s", menu_path);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, path, action_name, NULL, FALSE);
|
gimp_ui_manager_add_ui (manager, path, action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
|
|
@ -110,8 +110,7 @@ window_menu_display_opened (GdkDisplayManager *disp_manager,
|
||||||
* "/dockable-popup/Move to Screen".
|
* "/dockable-popup/Move to Screen".
|
||||||
*/
|
*/
|
||||||
if (g_str_has_prefix (ui_path, "/image-menubar/"))
|
if (g_str_has_prefix (ui_path, "/image-menubar/"))
|
||||||
gimp_ui_manager_add_ui (manager, "/View/Move to Screen",
|
gimp_ui_manager_add_ui (manager, "/View/Move to Screen", action_name, FALSE);
|
||||||
action_name, NULL, FALSE);
|
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ windows_menu_image_notify (GimpDisplay *display,
|
||||||
|
|
||||||
action_name = gimp_display_get_action_name (display);
|
action_name = gimp_display_get_action_name (display);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, "/Windows", action_name, "Images", TRUE);
|
gimp_ui_manager_add_ui (manager, "/Windows/[Images]", action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ windows_menu_dock_window_added (GimpDialogFactory *factory,
|
||||||
action_name = windows_actions_dock_window_to_action_name (dock_window);
|
action_name = windows_actions_dock_window_to_action_name (dock_window);
|
||||||
|
|
||||||
/* TODO GMenu: doesn't look like it's working, neither will old or new API. */
|
/* TODO GMenu: doesn't look like it's working, neither will old or new API. */
|
||||||
gimp_ui_manager_add_ui (manager, "/Windows", action_name, "Docks", FALSE);
|
gimp_ui_manager_add_ui (manager, "/Windows/[Docks]", action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,7 @@ windows_menu_recent_add (GimpContainer *container,
|
||||||
|
|
||||||
action_name = g_strdup_printf ("windows-recent-%04d", info_id);
|
action_name = g_strdup_printf ("windows-recent-%04d", info_id);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, "/Windows/Recently Closed Docks",
|
gimp_ui_manager_add_ui (manager, "/Windows/Recently Closed Docks", action_name, TRUE);
|
||||||
action_name, NULL, TRUE);
|
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5014,8 +5014,8 @@ gimp_dashboard_menu_setup (GimpUIManager *manager,
|
||||||
|
|
||||||
action_name = g_strdup_printf ("dashboard-group-%s", group_info->name);
|
action_name = g_strdup_printf ("dashboard-group-%s", group_info->name);
|
||||||
|
|
||||||
gimp_ui_manager_add_ui (manager, "/Dashboard Menu/Groups",
|
gimp_ui_manager_add_ui (manager, "/Dashboard Menu/Groups/[Groups]",
|
||||||
action_name, "Groups", FALSE);
|
action_name, FALSE);
|
||||||
|
|
||||||
g_free (action_name);
|
g_free (action_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
struct _GimpMenuPrivate
|
struct _GimpMenuPrivate
|
||||||
{
|
{
|
||||||
GTree *submenus;
|
GTree *submenus;
|
||||||
GTree *placeholders;
|
|
||||||
|
|
||||||
GHashTable *sections;
|
GHashTable *sections;
|
||||||
};
|
};
|
||||||
|
@ -77,15 +76,12 @@ static void gimp_menu_append (GimpMenuShell *shel
|
||||||
static void gimp_menu_add_ui (GimpMenuShell *shell,
|
static void gimp_menu_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
static void gimp_menu_remove_ui (GimpMenuShell *shell,
|
static void gimp_menu_remove_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name);
|
const gchar *action_name);
|
||||||
static void gimp_menu_model_deleted (GimpMenuShell *shell);
|
static void gimp_menu_model_deleted (GimpMenuShell *shell);
|
||||||
|
|
||||||
static void gimp_menu_add_placeholder (GimpMenu *menu,
|
|
||||||
const gchar *label);
|
|
||||||
static void gimp_menu_add_action (GimpMenu *menu,
|
static void gimp_menu_add_action (GimpMenu *menu,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
gboolean long_label,
|
gboolean long_label,
|
||||||
|
@ -120,10 +116,6 @@ static void gimp_menu_action_notify_visible (GimpAction *acti
|
||||||
const GParamSpec *pspec,
|
const GParamSpec *pspec,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
|
|
||||||
static gboolean gimp_menu_copy_placeholders (gpointer key,
|
|
||||||
gpointer item,
|
|
||||||
GTree *placeholders);
|
|
||||||
|
|
||||||
static void gimp_menu_help_fun (const gchar *bogus_help_id,
|
static void gimp_menu_help_fun (const gchar *bogus_help_id,
|
||||||
gpointer help_data);
|
gpointer help_data);
|
||||||
static void gimp_menu_hide_double_separators (GimpMenu *menu);
|
static void gimp_menu_hide_double_separators (GimpMenu *menu);
|
||||||
|
@ -157,8 +149,6 @@ gimp_menu_init (GimpMenu *menu)
|
||||||
|
|
||||||
menu->priv->submenus = g_tree_new_full ((GCompareDataFunc) g_strcmp0, NULL,
|
menu->priv->submenus = g_tree_new_full ((GCompareDataFunc) g_strcmp0, NULL,
|
||||||
g_free, NULL);
|
g_free, NULL);
|
||||||
menu->priv->placeholders = g_tree_new_full ((GCompareDataFunc) g_strcmp0, NULL,
|
|
||||||
g_free, NULL);
|
|
||||||
menu->priv->sections = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
menu->priv->sections = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||||
g_object_unref, NULL);
|
g_object_unref, NULL);
|
||||||
|
|
||||||
|
@ -183,7 +173,6 @@ gimp_menu_finalize (GObject *object)
|
||||||
GimpMenu *menu = GIMP_MENU (object);
|
GimpMenu *menu = GIMP_MENU (object);
|
||||||
|
|
||||||
g_clear_pointer (&menu->priv->submenus, g_tree_unref);
|
g_clear_pointer (&menu->priv->submenus, g_tree_unref);
|
||||||
g_clear_pointer (&menu->priv->placeholders, g_tree_unref);
|
|
||||||
g_hash_table_unref (menu->priv->sections);
|
g_hash_table_unref (menu->priv->sections);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
@ -262,22 +251,12 @@ gimp_menu_append (GimpMenuShell *shell,
|
||||||
G_CALLBACK (gimp_menu_submenu_notify_color),
|
G_CALLBACK (gimp_menu_submenu_notify_color),
|
||||||
item);
|
item);
|
||||||
}
|
}
|
||||||
else if (action_name == NULL)
|
|
||||||
{
|
|
||||||
/* Special case: we use items with no action and a label as
|
|
||||||
* placeholder which allows us to specify a placement in menus, which
|
|
||||||
* might not be only top or bottom.
|
|
||||||
*/
|
|
||||||
g_return_if_fail (label != NULL);
|
|
||||||
|
|
||||||
group = NULL;
|
|
||||||
|
|
||||||
gimp_menu_add_placeholder (menu, label);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *label_variant = NULL;
|
gchar *label_variant = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (action_name != NULL);
|
||||||
|
|
||||||
g_menu_model_get_item_attribute (G_MENU_MODEL (model), i, "label-variant", "s", &label_variant);
|
g_menu_model_get_item_attribute (G_MENU_MODEL (model), i, "label-variant", "s", &label_variant);
|
||||||
gimp_menu_add_action (menu, action_name,
|
gimp_menu_add_action (menu, action_name,
|
||||||
/* By default, we use the short label in menus,
|
/* By default, we use the short label in menus,
|
||||||
|
@ -302,48 +281,31 @@ static void
|
||||||
gimp_menu_add_ui (GimpMenuShell *shell,
|
gimp_menu_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top)
|
gboolean top)
|
||||||
{
|
{
|
||||||
GimpMenu *menu = GIMP_MENU (shell);
|
GimpMenu *menu = GIMP_MENU (shell);
|
||||||
GimpUIManager *manager = gimp_menu_shell_get_manager (GIMP_MENU_SHELL (shell));
|
GimpUIManager *manager = gimp_menu_shell_get_manager (GIMP_MENU_SHELL (shell));
|
||||||
|
GtkWidget *submenu;
|
||||||
|
|
||||||
g_return_if_fail (paths != NULL);
|
g_return_if_fail (paths != NULL && paths[0] != NULL);
|
||||||
|
|
||||||
if (paths[0] == NULL)
|
submenu = g_tree_lookup (menu->priv->submenus, paths[0]);
|
||||||
|
|
||||||
|
if (submenu == NULL)
|
||||||
{
|
{
|
||||||
GtkWidget *placeholder;
|
GtkWidget *item;
|
||||||
|
|
||||||
placeholder = g_tree_lookup (menu->priv->placeholders, placeholder_key);
|
item = gtk_menu_item_new_with_mnemonic (paths[0]);
|
||||||
|
gtk_container_add (GTK_CONTAINER (shell), item);
|
||||||
|
|
||||||
if (! placeholder)
|
submenu = gimp_menu_new (manager);
|
||||||
g_warning ("%s: no placeholder item '%s'.", G_STRFUNC, placeholder_key);
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
|
||||||
|
gtk_widget_show (submenu);
|
||||||
|
|
||||||
gimp_menu_add_action (menu, action_name, FALSE, placeholder, top, NULL);
|
g_tree_insert (menu->priv->submenus, g_strdup (paths[0]), submenu);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GtkWidget *submenu;
|
|
||||||
|
|
||||||
submenu = g_tree_lookup (menu->priv->submenus, paths[0]);
|
gimp_menu_add_ui (GIMP_MENU_SHELL (submenu), paths + 1, action_name, top);
|
||||||
|
|
||||||
if (submenu == NULL)
|
|
||||||
{
|
|
||||||
GtkWidget *item;
|
|
||||||
|
|
||||||
item = gtk_menu_item_new_with_mnemonic (paths[0]);
|
|
||||||
gtk_container_add (GTK_CONTAINER (shell), item);
|
|
||||||
|
|
||||||
submenu = gimp_menu_new (manager);
|
|
||||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
|
|
||||||
gtk_widget_show (submenu);
|
|
||||||
|
|
||||||
g_tree_insert (menu->priv->submenus, g_strdup (paths[0]), submenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_menu_add_ui (GIMP_MENU_SHELL (submenu), paths + 1,
|
|
||||||
action_name, placeholder_key, top);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_menu_hide_double_separators (menu);
|
gimp_menu_hide_double_separators (menu);
|
||||||
}
|
}
|
||||||
|
@ -420,10 +382,6 @@ gimp_menu_merge (GimpMenu *menu,
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_tree_foreach (menu2->priv->placeholders,
|
|
||||||
(GTraverseFunc) gimp_menu_copy_placeholders,
|
|
||||||
menu->priv->placeholders);
|
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (menu2));
|
gtk_widget_destroy (GTK_WIDGET (menu2));
|
||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
}
|
}
|
||||||
|
@ -431,19 +389,6 @@ gimp_menu_merge (GimpMenu *menu,
|
||||||
|
|
||||||
/* Private functions */
|
/* Private functions */
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_menu_add_placeholder (GimpMenu *menu,
|
|
||||||
const gchar *label)
|
|
||||||
{
|
|
||||||
GtkWidget *item;
|
|
||||||
|
|
||||||
/* Placeholders are inserted yet never shown, on purpose. */
|
|
||||||
item = gtk_menu_item_new_with_mnemonic (label);
|
|
||||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
|
||||||
|
|
||||||
g_tree_insert (menu->priv->placeholders, g_strdup (label), item);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_menu_add_action (GimpMenu *menu,
|
gimp_menu_add_action (GimpMenu *menu,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
|
@ -831,15 +776,6 @@ gimp_menu_action_notify_visible (GimpAction *action,
|
||||||
gimp_menu_hide_double_separators (GIMP_MENU (container));
|
gimp_menu_hide_double_separators (GIMP_MENU (container));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gimp_menu_copy_placeholders (gpointer key,
|
|
||||||
gpointer item,
|
|
||||||
GTree *placeholders)
|
|
||||||
{
|
|
||||||
g_tree_insert (placeholders, g_strdup ((gchar *) key), item);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_menu_help_fun (const gchar *bogus_help_id,
|
gimp_menu_help_fun (const gchar *bogus_help_id,
|
||||||
gpointer help_data)
|
gpointer help_data)
|
||||||
|
@ -892,9 +828,9 @@ gimp_menu_help_fun (const gchar *bogus_help_id,
|
||||||
|
|
||||||
/* With successive sections, we will end up with double separators (end one then
|
/* With successive sections, we will end up with double separators (end one then
|
||||||
* start one of the next section). Moreover sometimes, empty sections (e.g.
|
* start one of the next section). Moreover sometimes, empty sections (e.g.
|
||||||
* because items are expected to be added later through placeholders) would make
|
* because items are expected to be added later) would make even 3 to 4
|
||||||
* even 3 to 4 separators next to each other. This renders very ugly. We need to
|
* separators next to each other. This renders very ugly. We need to call this
|
||||||
* call this function to hide and show separators after changes.
|
* function to hide and show separators after changes.
|
||||||
*
|
*
|
||||||
* This also hides start and end separators in the menu.
|
* This also hides start and end separators in the menu.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -67,7 +67,6 @@ static void gimp_menu_bar_append (GimpMenuShell *sh
|
||||||
static void gimp_menu_bar_add_ui (GimpMenuShell *shell,
|
static void gimp_menu_bar_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,8 +171,8 @@ gimp_menu_bar_append (GimpMenuShell *shell,
|
||||||
g_warning ("%s: unexpected subsection. Only menus are allowed in menu bar's root.",
|
g_warning ("%s: unexpected subsection. Only menus are allowed in menu bar's root.",
|
||||||
G_STRFUNC);
|
G_STRFUNC);
|
||||||
if (action_name == NULL)
|
if (action_name == NULL)
|
||||||
g_warning ("%s: unexpected placeholder '%s'. Only menus are allowed in menu bar's root.",
|
g_warning ("%s: missing action name. Only menus are allowed in menu bar's root.",
|
||||||
G_STRFUNC, label);
|
G_STRFUNC);
|
||||||
else
|
else
|
||||||
g_warning ("%s: unexpected action '%s'. Only menus are allowed in menu bar's root.",
|
g_warning ("%s: unexpected action '%s'. Only menus are allowed in menu bar's root.",
|
||||||
G_STRFUNC, action_name);
|
G_STRFUNC, action_name);
|
||||||
|
@ -189,7 +188,6 @@ static void
|
||||||
gimp_menu_bar_add_ui (GimpMenuShell *shell,
|
gimp_menu_bar_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top)
|
gboolean top)
|
||||||
{
|
{
|
||||||
GimpMenuBar *bar = GIMP_MENU_BAR (shell);
|
GimpMenuBar *bar = GIMP_MENU_BAR (shell);
|
||||||
|
@ -223,9 +221,7 @@ gimp_menu_bar_add_ui (GimpMenuShell *shell,
|
||||||
}
|
}
|
||||||
|
|
||||||
GIMP_MENU_SHELL_GET_INTERFACE (menu)->add_ui (GIMP_MENU_SHELL (menu),
|
GIMP_MENU_SHELL_GET_INTERFACE (menu)->add_ui (GIMP_MENU_SHELL (menu),
|
||||||
paths + 1,
|
paths + 1, action_name, top);
|
||||||
action_name,
|
|
||||||
placeholder_key, top);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,6 @@ static void gimp_menu_model_action_notify_label (GimpAction
|
||||||
static gboolean gimp_menu_model_ui_added (GimpUIManager *manager,
|
static gboolean gimp_menu_model_ui_added (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top,
|
gboolean top,
|
||||||
GimpMenuModel *model);
|
GimpMenuModel *model);
|
||||||
static gboolean gimp_menu_model_ui_removed (GimpUIManager *manager,
|
static gboolean gimp_menu_model_ui_removed (GimpUIManager *manager,
|
||||||
|
@ -757,46 +756,43 @@ gimp_menu_model_initialize (GimpMenuModel *model,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GimpAction *action;
|
||||||
|
gchar *label_variant = NULL;
|
||||||
|
|
||||||
item = g_menu_item_new_from_model (G_MENU_MODEL (gmodel), i);
|
item = g_menu_item_new_from_model (G_MENU_MODEL (gmodel), i);
|
||||||
|
|
||||||
if (action_name)
|
g_return_if_fail (action_name != NULL);
|
||||||
{
|
|
||||||
GimpAction *action;
|
|
||||||
gchar *label_variant = NULL;
|
|
||||||
|
|
||||||
action = gimp_ui_manager_find_action (model->priv->manager, NULL, action_name);
|
action = gimp_ui_manager_find_action (model->priv->manager, NULL, action_name);
|
||||||
|
|
||||||
if (model->priv->manager->store_action_paths)
|
if (model->priv->manager->store_action_paths)
|
||||||
/* Special-case the main menu manager when constructing it as
|
/* Special-case the main menu manager when constructing it as
|
||||||
* this is the only one which should set the menu path.
|
* this is the only one which should set the menu path.
|
||||||
*/
|
*/
|
||||||
gimp_action_set_menu_path (action, gimp_menu_model_get_path (model));
|
gimp_action_set_menu_path (action, gimp_menu_model_get_path (model));
|
||||||
|
|
||||||
g_signal_connect_object (action,
|
g_signal_connect_object (action,
|
||||||
"notify::visible",
|
"notify::visible",
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
||||||
model, 0);
|
model, 0);
|
||||||
|
|
||||||
g_menu_item_get_attribute (item, "label-variant", "s",
|
g_menu_item_get_attribute (item, "label-variant", "s",
|
||||||
&label_variant);
|
&label_variant);
|
||||||
if (g_strcmp0 (label_variant, "long") == 0)
|
if (g_strcmp0 (label_variant, "long") == 0)
|
||||||
g_menu_item_set_label (item, gimp_action_get_label (action));
|
g_menu_item_set_label (item, gimp_action_get_label (action));
|
||||||
else
|
else
|
||||||
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
g_menu_item_set_label (item, gimp_action_get_short_label (action));
|
||||||
|
|
||||||
g_signal_connect_object (action,
|
g_signal_connect_object (action,
|
||||||
"notify::short-label",
|
"notify::short-label",
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||||
item, 0);
|
item, 0);
|
||||||
g_signal_connect_object (action,
|
g_signal_connect_object (action,
|
||||||
"notify::label",
|
"notify::label",
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||||
item, 0);
|
item, 0);
|
||||||
|
|
||||||
g_free (label_variant);
|
g_free (label_variant);
|
||||||
}
|
|
||||||
|
|
||||||
/* else we instal a placeholder (no-action and always invisible) item. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item)
|
if (item)
|
||||||
|
@ -917,9 +913,7 @@ gimp_menu_model_get_item (GimpMenuModel *model,
|
||||||
{
|
{
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
/* Count neither placeholders (items with no action_name), nor invisible
|
/* Do not count invisible actions. */
|
||||||
* actions.
|
|
||||||
*/
|
|
||||||
else if (g_menu_item_get_attribute (iter->data,
|
else if (g_menu_item_get_attribute (iter->data,
|
||||||
G_MENU_ATTRIBUTE_ACTION,
|
G_MENU_ATTRIBUTE_ACTION,
|
||||||
"&s", &action_name))
|
"&s", &action_name))
|
||||||
|
@ -1048,7 +1042,6 @@ static gboolean
|
||||||
gimp_menu_model_ui_added (GimpUIManager *manager,
|
gimp_menu_model_ui_added (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top,
|
gboolean top,
|
||||||
GimpMenuModel *model)
|
GimpMenuModel *model)
|
||||||
{
|
{
|
||||||
|
@ -1082,17 +1075,6 @@ gimp_menu_model_ui_added (GimpUIManager *manager,
|
||||||
|
|
||||||
added = TRUE;
|
added = TRUE;
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (action,
|
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
|
||||||
model);
|
|
||||||
detailed_action_name = g_strdup_printf ("%s.%s", action_prefix, g_action_get_name (action));
|
|
||||||
item = g_menu_item_new (gimp_action_get_short_label (GIMP_ACTION (action)), detailed_action_name);
|
|
||||||
/* TODO: add also G_MENU_ATTRIBUTE_ICON attribute? */
|
|
||||||
g_free (detailed_action_name);
|
|
||||||
|
|
||||||
if (model->priv->manager->store_action_paths)
|
|
||||||
gimp_action_set_menu_path (GIMP_ACTION (action), gimp_menu_model_get_path (model));
|
|
||||||
|
|
||||||
if (section_name != NULL)
|
if (section_name != NULL)
|
||||||
{
|
{
|
||||||
GMenuItem *section_item;
|
GMenuItem *section_item;
|
||||||
|
@ -1105,57 +1087,18 @@ gimp_menu_model_ui_added (GimpUIManager *manager,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placeholder_key)
|
g_signal_handlers_disconnect_by_func (action,
|
||||||
{
|
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
||||||
GList *placeholder = NULL;
|
mod_model);
|
||||||
GMenuModel *subsection = NULL;
|
detailed_action_name = g_strdup_printf ("%s.%s", action_prefix, g_action_get_name (action));
|
||||||
|
item = g_menu_item_new (gimp_action_get_short_label (GIMP_ACTION (action)), detailed_action_name);
|
||||||
|
/* TODO: add also G_MENU_ATTRIBUTE_ICON attribute? */
|
||||||
|
g_free (detailed_action_name);
|
||||||
|
|
||||||
for (GList *iter = model->priv->items; iter; iter = iter->next)
|
if (model->priv->manager->store_action_paths)
|
||||||
{
|
gimp_action_set_menu_path (GIMP_ACTION (action), gimp_menu_model_get_path (model));
|
||||||
const gchar *label;
|
|
||||||
|
|
||||||
subsection = g_menu_item_get_link (iter->data, G_MENU_LINK_SECTION);
|
if (top)
|
||||||
|
|
||||||
if (subsection != NULL)
|
|
||||||
{
|
|
||||||
if (gimp_menu_model_ui_added (manager, path, action_name,
|
|
||||||
placeholder_key, top,
|
|
||||||
GIMP_MENU_MODEL (subsection)))
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
g_clear_object (&subsection);
|
|
||||||
}
|
|
||||||
else if (g_menu_item_get_attribute (iter->data,
|
|
||||||
G_MENU_ATTRIBUTE_LABEL,
|
|
||||||
"&s", &label) &&
|
|
||||||
g_strcmp0 (label, placeholder_key) == 0)
|
|
||||||
{
|
|
||||||
placeholder = iter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (placeholder)
|
|
||||||
{
|
|
||||||
if (top)
|
|
||||||
model->priv->items = g_list_insert_before (model->priv->items,
|
|
||||||
placeholder, item);
|
|
||||||
else
|
|
||||||
model->priv->items = g_list_insert_before (model->priv->items,
|
|
||||||
placeholder->next, item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
added = FALSE;
|
|
||||||
|
|
||||||
if (subsection == NULL && ! model->priv->is_section)
|
|
||||||
g_warning ("%s: no placeholder item '%s'.", G_STRFUNC, placeholder_key);
|
|
||||||
}
|
|
||||||
/* else: added in a subsection. */
|
|
||||||
|
|
||||||
g_clear_object (&subsection);
|
|
||||||
}
|
|
||||||
else if (top)
|
|
||||||
{
|
{
|
||||||
mod_model->priv->items = g_list_prepend (mod_model->priv->items, item);
|
mod_model->priv->items = g_list_prepend (mod_model->priv->items, item);
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1114,7 @@ gimp_menu_model_ui_added (GimpUIManager *manager,
|
||||||
g_signal_connect_object (action,
|
g_signal_connect_object (action,
|
||||||
"notify::visible",
|
"notify::visible",
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
G_CALLBACK (gimp_menu_model_action_notify_visible),
|
||||||
model, 0);
|
mod_model, 0);
|
||||||
g_signal_connect_object (action,
|
g_signal_connect_object (action,
|
||||||
"notify::short-label",
|
"notify::short-label",
|
||||||
G_CALLBACK (gimp_menu_model_action_notify_label),
|
G_CALLBACK (gimp_menu_model_action_notify_label),
|
||||||
|
|
|
@ -54,7 +54,6 @@ struct _GimpMenuShellInterface
|
||||||
void (* add_ui) (GimpMenuShell *shell,
|
void (* add_ui) (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
void (* remove_ui) (GimpMenuShell *shell,
|
void (* remove_ui) (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
|
|
|
@ -64,12 +64,10 @@ static void gimp_toolbar_append (GimpMenuShell *she
|
||||||
static void gimp_toolbar_add_ui (GimpMenuShell *shell,
|
static void gimp_toolbar_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
|
|
||||||
static void gimp_toolbar_add_action (GimpToolbar *toolbar,
|
static void gimp_toolbar_add_action (GimpToolbar *toolbar,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key G_GNUC_UNUSED,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
|
|
||||||
static void gimp_toolbar_toggle_item_toggled (GtkToggleToolButton *item,
|
static void gimp_toolbar_toggle_item_toggled (GtkToggleToolButton *item,
|
||||||
|
@ -155,7 +153,7 @@ gimp_toolbar_append (GimpMenuShell *shell,
|
||||||
}
|
}
|
||||||
else if (submenu == NULL && action_name != NULL)
|
else if (submenu == NULL && action_name != NULL)
|
||||||
{
|
{
|
||||||
gimp_toolbar_add_action (toolbar, action_name, NULL, FALSE);
|
gimp_toolbar_add_action (toolbar, action_name, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -163,7 +161,7 @@ gimp_toolbar_append (GimpMenuShell *shell,
|
||||||
g_warning ("%s: unexpected submenu. Only actions and sections are allowed in toolbar's root.",
|
g_warning ("%s: unexpected submenu. Only actions and sections are allowed in toolbar's root.",
|
||||||
G_STRFUNC);
|
G_STRFUNC);
|
||||||
else if (label != NULL)
|
else if (label != NULL)
|
||||||
g_warning ("%s: unexpected placeholder '%s'. Only actions and sections are allowed in toolbar's root.",
|
g_warning ("%s: unexpected label '%s'. Only actions and sections are allowed in toolbar's root.",
|
||||||
G_STRFUNC, label);
|
G_STRFUNC, label);
|
||||||
else
|
else
|
||||||
g_warning ("%s: unexpected toolbar item. Only actions and sections are allowed in toolbar's root.",
|
g_warning ("%s: unexpected toolbar item. Only actions and sections are allowed in toolbar's root.",
|
||||||
|
@ -181,7 +179,6 @@ static void
|
||||||
gimp_toolbar_add_ui (GimpMenuShell *shell,
|
gimp_toolbar_add_ui (GimpMenuShell *shell,
|
||||||
const gchar **paths,
|
const gchar **paths,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder_key,
|
|
||||||
gboolean top)
|
gboolean top)
|
||||||
{
|
{
|
||||||
GimpToolbar *toolbar = GIMP_TOOLBAR (shell);
|
GimpToolbar *toolbar = GIMP_TOOLBAR (shell);
|
||||||
|
@ -192,7 +189,7 @@ gimp_toolbar_add_ui (GimpMenuShell *shell,
|
||||||
g_warning ("%s: unexpected path '%s'. Menus are not allowed in toolbar's root.",
|
g_warning ("%s: unexpected path '%s'. Menus are not allowed in toolbar's root.",
|
||||||
G_STRFUNC, paths[0]);
|
G_STRFUNC, paths[0]);
|
||||||
else
|
else
|
||||||
gimp_toolbar_add_action (toolbar, action_name, placeholder_key, top);
|
gimp_toolbar_add_action (toolbar, action_name, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,10 +214,6 @@ gimp_toolbar_new (GimpMenuModel *model,
|
||||||
static void
|
static void
|
||||||
gimp_toolbar_add_action (GimpToolbar *toolbar,
|
gimp_toolbar_add_action (GimpToolbar *toolbar,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
/* XXX: right now unused, maybe be useful later for
|
|
||||||
* when we want to support user-managed toolbars.
|
|
||||||
*/
|
|
||||||
const gchar *placeholder_key G_GNUC_UNUSED,
|
|
||||||
gboolean top)
|
gboolean top)
|
||||||
{
|
{
|
||||||
GimpUIManager *manager;
|
GimpUIManager *manager;
|
||||||
|
|
|
@ -69,7 +69,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
gchar *path;
|
gchar *path;
|
||||||
gchar *action_name;
|
gchar *action_name;
|
||||||
gchar *placeholder;
|
|
||||||
gboolean top;
|
gboolean top;
|
||||||
} GimpUIManagerMenuItem;
|
} GimpUIManagerMenuItem;
|
||||||
|
|
||||||
|
@ -186,8 +185,7 @@ gimp_ui_manager_class_init (GimpUIManagerClass *klass)
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (GimpUIManagerClass, ui_added),
|
G_STRUCT_OFFSET (GimpUIManagerClass, ui_added),
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 4,
|
G_TYPE_NONE, 3,
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_BOOLEAN);
|
G_TYPE_BOOLEAN);
|
||||||
|
@ -615,7 +613,6 @@ void
|
||||||
gimp_ui_manager_add_ui (GimpUIManager *manager,
|
gimp_ui_manager_add_ui (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder,
|
|
||||||
gboolean top)
|
gboolean top)
|
||||||
{
|
{
|
||||||
GimpUIManagerMenuItem *item;
|
GimpUIManagerMenuItem *item;
|
||||||
|
@ -627,13 +624,12 @@ gimp_ui_manager_add_ui (GimpUIManager *manager,
|
||||||
item = g_slice_new0 (GimpUIManagerMenuItem);
|
item = g_slice_new0 (GimpUIManagerMenuItem);
|
||||||
item->path = g_strdup (path);
|
item->path = g_strdup (path);
|
||||||
item->action_name = g_strdup (action_name);
|
item->action_name = g_strdup (action_name);
|
||||||
item->placeholder = g_strdup (placeholder);
|
|
||||||
item->top = top;
|
item->top = top;
|
||||||
|
|
||||||
manager->ui_items = g_list_prepend (manager->ui_items, item);
|
manager->ui_items = g_list_prepend (manager->ui_items, item);
|
||||||
|
|
||||||
g_signal_emit (manager, manager_signals[UI_ADDED], 0,
|
g_signal_emit (manager, manager_signals[UI_ADDED], 0,
|
||||||
path, action_name, placeholder, top);
|
path, action_name, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -645,8 +641,7 @@ gimp_ui_manager_foreach_ui (GimpUIManager *manager,
|
||||||
{
|
{
|
||||||
GimpUIManagerMenuItem *item = iter->data;
|
GimpUIManagerMenuItem *item = iter->data;
|
||||||
|
|
||||||
callback (manager, item->path, item->action_name, item->placeholder,
|
callback (manager, item->path, item->action_name, item->top, user_data);
|
||||||
item->top, user_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,7 +1146,6 @@ gimp_ui_manager_menu_item_free (GimpUIManagerMenuItem *item)
|
||||||
{
|
{
|
||||||
g_free (item->path);
|
g_free (item->path);
|
||||||
g_free (item->action_name);
|
g_free (item->action_name);
|
||||||
g_free (item->placeholder);
|
|
||||||
|
|
||||||
g_slice_free (GimpUIManagerMenuItem, item);
|
g_slice_free (GimpUIManagerMenuItem, item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
typedef void (* GimpUIMenuCallback) (GimpUIManager *manager,
|
typedef void (* GimpUIMenuCallback) (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder,
|
|
||||||
gboolean top,
|
gboolean top,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
@ -90,7 +89,6 @@ struct _GimpUIManagerClass
|
||||||
void (* ui_added) (GimpUIManager *manager,
|
void (* ui_added) (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
void (* ui_removed) (GimpUIManager *manager,
|
void (* ui_removed) (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
|
@ -124,7 +122,6 @@ void gimp_ui_manager_remove_uis (GimpUIManager *manager,
|
||||||
void gimp_ui_manager_add_ui (GimpUIManager *manager,
|
void gimp_ui_manager_add_ui (GimpUIManager *manager,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *placeholder,
|
|
||||||
gboolean top);
|
gboolean top);
|
||||||
void gimp_ui_manager_foreach_ui (GimpUIManager *manager,
|
void gimp_ui_manager_foreach_ui (GimpUIManager *manager,
|
||||||
GimpUIMenuCallback callback,
|
GimpUIMenuCallback callback,
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
<attribute name="icon">gimp-dashboard</attribute>
|
<attribute name="icon">gimp-dashboard</attribute>
|
||||||
<submenu>
|
<submenu>
|
||||||
<attribute name="label" translatable="yes" context="dashboard-action">Groups</attribute>
|
<attribute name="label" translatable="yes" context="dashboard-action">Groups</attribute>
|
||||||
<!-- Placeholder for recently used filters and plug-ins. -->
|
<section>
|
||||||
<item><attribute name="label" translatable="no">Groups</attribute></item>
|
<attribute name="section-name" translatable="no">Groups</attribute>
|
||||||
|
</section>
|
||||||
</submenu>
|
</submenu>
|
||||||
<submenu>
|
<submenu>
|
||||||
<attribute name="label" translatable="yes" context="dashboard-action">_Update Interval</attribute>
|
<attribute name="label" translatable="yes" context="dashboard-action">_Update Interval</attribute>
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
<submenu>
|
<submenu>
|
||||||
<attribute name="label" translatable="yes" context="file-action">Open _Recent</attribute>
|
<attribute name="label" translatable="yes" context="file-action">Open _Recent</attribute>
|
||||||
<section>
|
<section>
|
||||||
<!-- Placeholder for recently opened files. -->
|
<attribute name="section-name" translatable="no">Files</attribute>
|
||||||
<item><attribute name="label" translatable="no">Files</attribute></item>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
<item><attribute name="action">app.dialogs-document-history</attribute></item>
|
<item><attribute name="action">app.dialogs-document-history</attribute></item>
|
||||||
</submenu>
|
</submenu>
|
||||||
|
@ -624,8 +622,9 @@
|
||||||
<item><attribute name="action">app.filters-reshow</attribute></item>
|
<item><attribute name="action">app.filters-reshow</attribute></item>
|
||||||
<submenu>
|
<submenu>
|
||||||
<attribute name="label" translatable="yes" context="filters-action">Recently Used</attribute>
|
<attribute name="label" translatable="yes" context="filters-action">Recently Used</attribute>
|
||||||
<!-- Placeholder for recently used filters and plug-ins. -->
|
<section>
|
||||||
<item><attribute name="label" translatable="no">Filters</attribute></item>
|
<attribute name="section-name" translatable="no">Filters</attribute>
|
||||||
|
</section>
|
||||||
</submenu>
|
</submenu>
|
||||||
<item><attribute name="action">app.plug-in-reset-all</attribute></item>
|
<item><attribute name="action">app.plug-in-reset-all</attribute></item>
|
||||||
</section>
|
</section>
|
||||||
|
@ -795,13 +794,12 @@
|
||||||
</submenu>
|
</submenu>
|
||||||
<item><attribute name="action">app.dialogs-toolbox</attribute></item>
|
<item><attribute name="action">app.dialogs-toolbox</attribute></item>
|
||||||
</section>
|
</section>
|
||||||
<!-- Placeholder invisible item to know where to place opened images list -->
|
|
||||||
<section>
|
<section>
|
||||||
<item><attribute name="label" translatable="no">Images</attribute></item>
|
<attribute name="section-name" translatable="no">Images</attribute>
|
||||||
</section>
|
</section>
|
||||||
<!-- Placeholder invisible item - TODO GMenu: is this one actually working/used? -->
|
|
||||||
<section>
|
<section>
|
||||||
<item><attribute name="label" translatable="no">Docks</attribute></item>
|
<!-- TODO GMenu: is this placeholder section actually working/used? -->
|
||||||
|
<attribute name="section-name" translatable="no">Docks</attribute>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<item><attribute name="action">app.windows-hide-docks</attribute></item>
|
<item><attribute name="action">app.windows-hide-docks</attribute></item>
|
||||||
|
|
Loading…
Reference in New Issue