[gimp] app: add an optional "label" to GimpTool which overrides GimpToolInfo's
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add an optional "label" to GimpTool which overrides GimpToolInfo's
- Date: Tue, 4 Jul 2017 20:32:09 +0000 (UTC)
commit c682c5466c56374fe875d1dbef9f368f0377e857
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 4 22:30:35 2017 +0200
app: add an optional "label" to GimpTool which overrides GimpToolInfo's
Remove GimpFilterTool's "title" and use the GimpTool's "label" instead.
app/tools/gimpbrightnesscontrasttool.c | 2 --
app/tools/gimpcurvestool.c | 2 --
app/tools/gimpfiltertool-settings.c | 11 +++++++----
app/tools/gimpfiltertool.c | 30 ++++++++----------------------
app/tools/gimpfiltertool.h | 2 --
app/tools/gimplevelstool.c | 2 --
app/tools/gimpoperationtool.c | 20 +-------------------
app/tools/gimpoperationtool.h | 1 -
app/tools/gimpthresholdtool.c | 2 --
app/tools/gimptool.c | 27 +++++++++++++++++++++++++++
app/tools/gimptool.h | 5 +++++
11 files changed, 48 insertions(+), 56 deletions(-)
---
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index 24edf5c..c919efe 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -73,7 +73,6 @@ static void gimp_brightness_contrast_tool_motion (GimpTool
static gchar *
gimp_brightness_contrast_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
static void gimp_brightness_contrast_tool_dialog (GimpFilterTool *filter_tool);
@@ -158,7 +157,6 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
static gchar *
gimp_brightness_contrast_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings)
{
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 70f66b0..54ee687 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -81,7 +81,6 @@ static void gimp_curves_tool_oper_update (GimpTool *tool,
GimpDisplay *display);
static gchar * gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
static void gimp_curves_tool_dialog (GimpFilterTool *filter_tool);
@@ -344,7 +343,6 @@ gimp_curves_tool_oper_update (GimpTool *tool,
static gchar *
gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings)
{
diff --git a/app/tools/gimpfiltertool-settings.c b/app/tools/gimpfiltertool-settings.c
index f22bded..4d448a5 100644
--- a/app/tools/gimpfiltertool-settings.c
+++ b/app/tools/gimpfiltertool-settings.c
@@ -69,9 +69,9 @@ gimp_filter_tool_get_settings_box (GimpFilterTool *filter_tool)
settings_folder = g_type_get_qdata (type, quark);
import_title = g_strdup_printf (_("Import '%s' Settings"),
- filter_tool->title);
+ gimp_tool_get_label (GIMP_TOOL (filter_tool)));
export_title = g_strdup_printf (_("Export '%s' Settings"),
- filter_tool->title);
+ gimp_tool_get_label (GIMP_TOOL (filter_tool)));
box = gimp_settings_box_new (tool_info->gimp,
filter_tool->config,
@@ -123,12 +123,15 @@ gimp_filter_tool_real_settings_export (GimpFilterTool *filter_tool,
GOutputStream *output,
GError **error)
{
+ GimpTool *tool = GIMP_TOOL (filter_tool);
gchar *header;
gchar *footer;
gboolean success;
- header = g_strdup_printf ("GIMP '%s' settings", filter_tool->title);
- footer = g_strdup_printf ("end of '%s' settings", filter_tool->title);
+ header = g_strdup_printf ("GIMP '%s' settings",
+ gimp_tool_get_label (tool));
+ footer = g_strdup_printf ("end of '%s' settings",
+ gimp_tool_get_label (tool));
success = gimp_config_serialize_to_stream (GIMP_CONFIG (filter_tool->config),
output,
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index bc544cb..e14220b 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -254,12 +254,6 @@ gimp_filter_tool_finalize (GObject *object)
filter_tool->settings = NULL;
}
- if (filter_tool->title)
- {
- g_free (filter_tool->title);
- filter_tool->title = NULL;
- }
-
if (filter_tool->description)
{
g_free (filter_tool->description);
@@ -340,7 +334,7 @@ gimp_filter_tool_initialize (GimpTool *tool,
filter_tool->gui =
gimp_tool_gui_new (tool_info,
- filter_tool->title,
+ gimp_tool_get_label (tool),
filter_tool->description,
gimp_tool_get_icon_name (tool),
gimp_tool_get_help_id (tool),
@@ -455,7 +449,8 @@ gimp_filter_tool_initialize (GimpTool *tool,
}
else
{
- gimp_tool_gui_set_title (filter_tool->gui, filter_tool->title);
+ gimp_tool_gui_set_title (filter_tool->gui,
+ gimp_tool_get_label (tool));
gimp_tool_gui_set_description (filter_tool->gui, filter_tool->description);
gimp_tool_gui_set_icon_name (filter_tool->gui,
gimp_tool_get_icon_name (tool));
@@ -1346,12 +1341,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
filter_tool->settings = NULL;
}
- if (filter_tool->title)
- {
- g_free (filter_tool->title);
- filter_tool->title = NULL;
- }
-
if (filter_tool->description)
{
g_free (filter_tool->description);
@@ -1359,18 +1348,14 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
}
operation_name = klass->get_operation (filter_tool,
- &filter_tool->title,
&filter_tool->description,
&filter_tool->has_settings);
if (! operation_name)
operation_name = g_strdup ("gegl:nop");
- if (! filter_tool->title)
- filter_tool->title = g_strdup (tool->tool_info->label);
-
if (! filter_tool->description)
- filter_tool->description = g_strdup (filter_tool->title);
+ filter_tool->description = g_strdup (gimp_tool_get_label (tool));
filter_tool->operation = gegl_node_new_child (NULL,
"operation", operation_name,
@@ -1396,7 +1381,8 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
if (filter_tool->gui)
{
- gimp_tool_gui_set_title (filter_tool->gui, filter_tool->title);
+ gimp_tool_gui_set_title (filter_tool->gui,
+ gimp_tool_get_label (tool));
gimp_tool_gui_set_description (filter_tool->gui, filter_tool->description);
gimp_tool_gui_set_icon_name (filter_tool->gui,
gimp_tool_get_icon_name (tool));
@@ -1463,9 +1449,9 @@ gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
settings_folder = g_type_get_qdata (type, quark);
import_title = g_strdup_printf (_("Import '%s' Settings"),
- filter_tool->title);
+ gimp_tool_get_label (tool));
export_title = g_strdup_printf (_("Export '%s' Settings"),
- filter_tool->title);
+ gimp_tool_get_label (tool));
g_object_set (filter_tool->settings_box,
"visible", TRUE,
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index 846b8ed..90cccc7 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -45,7 +45,6 @@ struct _GimpFilterTool
GObject *default_config;
GimpContainer *settings;
- gchar *title;
gchar *description;
gboolean has_settings;
@@ -75,7 +74,6 @@ struct _GimpFilterToolClass
/* virtual functions */
gchar * (* get_operation) (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
void (* dialog) (GimpFilterTool *filter_tool);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 7a9a731..504669f 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -72,7 +72,6 @@ static gboolean gimp_levels_tool_initialize (GimpTool *tool,
GError **error);
static gchar * gimp_levels_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
static void gimp_levels_tool_dialog (GimpFilterTool *filter_tool);
@@ -238,7 +237,6 @@ gimp_levels_tool_initialize (GimpTool *tool,
static gchar *
gimp_levels_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings)
{
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 14ba1c8..22ca668 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -84,7 +84,6 @@ static void gimp_operation_tool_options_notify (GimpTool *tool,
const GParamSpec *pspec);
static gchar * gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
static void gimp_operation_tool_dialog (GimpFilterTool *filter_tool);
@@ -172,12 +171,6 @@ gimp_operation_tool_finalize (GObject *object)
tool->operation = NULL;
}
- if (tool->title)
- {
- g_free (tool->title);
- tool->title = NULL;
- }
-
if (tool->description)
{
g_free (tool->description);
@@ -270,13 +263,11 @@ gimp_operation_tool_options_notify (GimpTool *tool,
static gchar *
gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings)
{
GimpOperationTool *tool = GIMP_OPERATION_TOOL (filter_tool);
- *title = g_strdup (tool->title);
*description = g_strdup (tool->description);
*has_settings = FALSE;
@@ -440,12 +431,6 @@ gimp_operation_tool_halt (GimpOperationTool *op_tool)
op_tool->operation = NULL;
}
- if (op_tool->title)
- {
- g_free (op_tool->title);
- op_tool->title = NULL;
- }
-
if (op_tool->description)
{
g_free (op_tool->description);
@@ -676,16 +661,13 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (tool->operation)
g_free (tool->operation);
- if (tool->title)
- g_free (tool->title);
-
if (tool->description)
g_free (tool->description);
tool->operation = g_strdup (operation);
- tool->title = g_strdup (title);
tool->description = g_strdup (description);
+ gimp_tool_set_label (GIMP_TOOL (tool), title);
gimp_tool_set_undo_desc (GIMP_TOOL (tool), undo_desc);
gimp_tool_set_icon_name (GIMP_TOOL (tool), icon_name);
gimp_tool_set_help_id (GIMP_TOOL (tool), help_id);
diff --git a/app/tools/gimpoperationtool.h b/app/tools/gimpoperationtool.h
index 9670476..8f5be1f 100644
--- a/app/tools/gimpoperationtool.h
+++ b/app/tools/gimpoperationtool.h
@@ -38,7 +38,6 @@ struct _GimpOperationTool
GimpFilterTool parent_instance;
gchar *operation;
- gchar *title;
gchar *description;
GList *aux_inputs;
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 7a4a31f..14eb036 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -52,7 +52,6 @@ static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
GError **error);
static gchar * gimp_threshold_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings);
static void gimp_threshold_tool_dialog (GimpFilterTool *filter_tool);
@@ -153,7 +152,6 @@ gimp_threshold_tool_initialize (GimpTool *tool,
static gchar *
gimp_threshold_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **title,
gchar **description,
gboolean *has_settings)
{
diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c
index fe21fc0..96e717b 100644
--- a/app/tools/gimptool.c
+++ b/app/tools/gimptool.c
@@ -234,6 +234,12 @@ gimp_tool_finalize (GObject *object)
tool->tool_info = NULL;
}
+ if (tool->label)
+ {
+ g_free (tool->label);
+ tool->label = NULL;
+ }
+
if (tool->undo_desc)
{
g_free (tool->undo_desc);
@@ -511,6 +517,27 @@ gimp_tool_get_options (GimpTool *tool)
}
void
+gimp_tool_set_label (GimpTool *tool,
+ const gchar *label)
+{
+ g_return_if_fail (GIMP_IS_TOOL (tool));
+
+ g_free (tool->label);
+ tool->label = g_strdup (label);
+}
+
+const gchar *
+gimp_tool_get_label (GimpTool *tool)
+{
+ g_return_val_if_fail (GIMP_IS_TOOL (tool), NULL);
+
+ if (tool->label)
+ return tool->label;
+
+ return tool->tool_info->label;
+}
+
+void
gimp_tool_set_undo_desc (GimpTool *tool,
const gchar *undo_desc)
{
diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h
index 92e1fa9..c8b70fc 100644
--- a/app/tools/gimptool.h
+++ b/app/tools/gimptool.h
@@ -40,6 +40,7 @@ struct _GimpTool
GimpToolInfo *tool_info;
+ gchar *label;
gchar *undo_desc;
gchar *icon_name;
gchar *help_id;
@@ -164,6 +165,10 @@ GType gimp_tool_get_type (void) G_GNUC_CONST;
GimpToolOptions * gimp_tool_get_options (GimpTool *tool);
+void gimp_tool_set_label (GimpTool *tool,
+ const gchar *label);
+const gchar * gimp_tool_get_label (GimpTool *tool);
+
void gimp_tool_set_undo_desc (GimpTool *tool,
const gchar *undo_desc);
const gchar * gimp_tool_get_undo_desc (GimpTool *tool);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]