1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

app: add gimp_tool_info_get_action_name()

Move the logic for translating a tool identifier to a corresponding
action name to GimpToolInfo.  It's currently only used in
tools-actions.c, but the next commits will use it in tool buttons.
This commit is contained in:
Ell
2020-01-29 21:49:12 +02:00
parent 2255d62891
commit ffe4f8a068
3 changed files with 28 additions and 7 deletions

View File

@@ -768,19 +768,14 @@ tools_actions_setup (GimpActionGroup *group)
if (tool_info->menu_label)
{
GimpStringActionEntry entry;
gchar *name;
const gchar *icon_name;
const gchar *identifier;
gchar *tmp;
gchar *name;
name = gimp_tool_info_get_action_name (tool_info);
icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info));
identifier = gimp_object_get_name (tool_info);
tmp = g_strndup (identifier + strlen ("gimp-"),
strlen (identifier) - strlen ("gimp--tool"));
name = g_strdup_printf ("tools-%s", tmp);
g_free (tmp);
entry.name = name;
entry.icon_name = icon_name;
entry.label = tool_info->menu_label;

View File

@@ -220,6 +220,30 @@ gimp_tool_info_get_standard (Gimp *gimp)
return gimp->standard_tool_info;
}
gchar *
gimp_tool_info_get_action_name (GimpToolInfo *tool_info)
{
const gchar *identifier;
gchar *tmp;
gchar *name;
g_return_val_if_fail (GIMP_IS_TOOL_INFO (tool_info), NULL);
identifier = gimp_object_get_name (GIMP_OBJECT (tool_info));
g_return_val_if_fail (g_str_has_prefix (identifier, "gimp-"), NULL);
g_return_val_if_fail (g_str_has_suffix (identifier, "-tool"), NULL);
tmp = g_strndup (identifier + strlen ("gimp-"),
strlen (identifier) - strlen ("gimp--tool"));
name = g_strdup_printf ("tools-%s", tmp);
g_free (tmp);
return name;
}
GFile *
gimp_tool_info_get_options_file (GimpToolInfo *tool_info,
const gchar *suffix)

View File

@@ -85,6 +85,8 @@ void gimp_tool_info_set_standard (Gimp *gimp,
GimpToolInfo *tool_info);
GimpToolInfo * gimp_tool_info_get_standard (Gimp *gimp);
gchar * gimp_tool_info_get_action_name (GimpToolInfo *tool_info);
GFile * gimp_tool_info_get_options_file (GimpToolInfo *tool_info,
const gchar *suffix);