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:
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user