[gimp] app: remove all "has_settings" stuff from the GimpFilterTool API
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove all "has_settings" stuff from the GimpFilterTool API
- Date: Sun, 9 Jul 2017 17:00:13 +0000 (UTC)
commit 29795a29ebe2315483384e0b6116666e76d8e231
Author: Michael Natterer <mitch gimp org>
Date: Sun Jul 9 18:58:00 2017 +0200
app: remove all "has_settings" stuff from the GimpFilterTool API
Instead, use gimp_operation_config_list_properties() to figure if an
operation has editable properties directly in
gimp_filter_tool_get_operation().
app/tools/gimpbrightnesscontrasttool.c | 9 +--
app/tools/gimpcurvestool.c | 9 +--
app/tools/gimpfiltertool.c | 141 ++++++++++++++++---------------
app/tools/gimpfiltertool.h | 6 +-
app/tools/gimplevelstool.c | 9 +--
app/tools/gimpoperationtool.c | 13 +--
app/tools/gimpthresholdtool.c | 9 +--
7 files changed, 89 insertions(+), 107 deletions(-)
---
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index c919efe..6bef1b2 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -73,8 +73,7 @@ static void gimp_brightness_contrast_tool_motion (GimpTool
static gchar *
gimp_brightness_contrast_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
static void gimp_brightness_contrast_tool_dialog (GimpFilterTool *filter_tool);
static void brightness_contrast_to_levels_callback (GtkWidget *widget,
@@ -157,11 +156,9 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
static gchar *
gimp_brightness_contrast_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings)
+ gchar **description)
{
- *description = g_strdup (_("Adjust Brightness and Contrast"));
- *has_settings = TRUE;
+ *description = g_strdup (_("Adjust Brightness and Contrast"));
return g_strdup ("gimp:brightness-contrast");
}
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 2ef4800..8078087 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -81,8 +81,7 @@ static void gimp_curves_tool_oper_update (GimpTool *tool,
GimpDisplay *display);
static gchar * gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
static void gimp_curves_tool_dialog (GimpFilterTool *filter_tool);
static void gimp_curves_tool_reset (GimpFilterTool *filter_tool);
static void gimp_curves_tool_config_notify (GimpFilterTool *filter_tool,
@@ -343,11 +342,9 @@ gimp_curves_tool_oper_update (GimpTool *tool,
static gchar *
gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings)
+ gchar **description)
{
- *description = g_strdup (_("Adjust Color Curves"));
- *has_settings = TRUE;
+ *description = g_strdup (_("Adjust Color Curves"));
return g_strdup ("gimp:curves");
}
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 5d79088..71509c5 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -174,6 +174,9 @@ static void gimp_filter_tool_response (GimpToolGui *gui,
gint response_id,
GimpFilterTool *filter_tool);
+static void gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
+ gboolean has_settings);
+
G_DEFINE_TYPE (GimpFilterTool, gimp_filter_tool, GIMP_TYPE_COLOR_TOOL)
@@ -1290,15 +1293,72 @@ gimp_filter_tool_response (GimpToolGui *gui,
}
}
+static void
+gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
+ gboolean has_settings)
+{
+ g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
+
+ filter_tool->has_settings = has_settings;
+
+ if (! filter_tool->settings_box)
+ return;
+
+ if (filter_tool->has_settings)
+ {
+ GimpTool *tool = GIMP_TOOL (filter_tool);
+ GQuark quark = g_quark_from_static_string ("settings-folder");
+ GType type = G_TYPE_FROM_INSTANCE (filter_tool->config);
+ GFile *settings_folder;
+ gchar *import_title;
+ gchar *export_title;
+
+ settings_folder = g_type_get_qdata (type, quark);
+
+ import_title = g_strdup_printf (_("Import '%s' Settings"),
+ gimp_tool_get_label (tool));
+ export_title = g_strdup_printf (_("Export '%s' Settings"),
+ gimp_tool_get_label (tool));
+
+ g_object_set (filter_tool->settings_box,
+ "visible", TRUE,
+ "config", filter_tool->config,
+ "container", filter_tool->settings,
+ "help-id", gimp_tool_get_help_id (tool),
+ "import-title", import_title,
+ "export-title", export_title,
+ "default-folder", settings_folder,
+ "last-file", NULL,
+ NULL);
+
+ g_free (import_title);
+ g_free (export_title);
+ }
+ else
+ {
+ g_object_set (filter_tool->settings_box,
+ "visible", FALSE,
+ "config", NULL,
+ "container", NULL,
+ "help-id", NULL,
+ "import-title", NULL,
+ "export-title", NULL,
+ "default-folder", NULL,
+ "last-file", NULL,
+ NULL);
+ }
+}
+
/* public functions */
void
gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
{
- GimpTool *tool;
- GimpFilterToolClass *klass;
- gchar *operation_name;
+ GimpTool *tool;
+ GimpFilterToolClass *klass;
+ gchar *operation_name;
+ GParamSpec **pspecs;
g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
@@ -1347,8 +1407,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
}
operation_name = klass->get_operation (filter_tool,
- &filter_tool->description,
- &filter_tool->has_settings);
+ &filter_tool->description);
if (! operation_name)
operation_name = g_strdup ("gegl:nop");
@@ -1378,6 +1437,15 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
(GCompareFunc) gimp_settings_compare);
g_object_ref (filter_tool->settings);
+ pspecs =
+ gimp_operation_config_list_properties (GIMP_OBJECT (filter_tool->config),
+ G_TYPE_FROM_INSTANCE (filter_tool->config),
+ 0, NULL);
+
+ gimp_filter_tool_set_has_settings (filter_tool, (pspecs != NULL));
+
+ g_free (pspecs);
+
if (filter_tool->gui)
{
gimp_tool_gui_set_title (filter_tool->gui,
@@ -1389,9 +1457,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
gimp_tool_get_help_id (tool));
}
- gimp_filter_tool_set_has_settings (filter_tool,
- filter_tool->has_settings);
-
if (gegl_operation_get_key (operation_name, "position-dependent"))
{
if (filter_tool->gui)
@@ -1422,66 +1487,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
gimp_filter_tool_create_filter (filter_tool);
}
-/* this function should better not exist, but we determine whether an
- * op has settings by checking if gimp_prop_gui_new() returns a
- * GtkLabel, which happens after get_operation() is called.
- */
-void
-gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
- gboolean has_settings)
-{
- g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
-
- filter_tool->has_settings = has_settings;
-
- if (filter_tool->settings_box)
- {
- if (filter_tool->has_settings)
- {
- GimpTool *tool = GIMP_TOOL (filter_tool);
- GQuark quark = g_quark_from_static_string ("settings-folder");
- GType type = G_TYPE_FROM_INSTANCE (filter_tool->config);
- GFile *settings_folder;
- gchar *import_title;
- gchar *export_title;
-
- settings_folder = g_type_get_qdata (type, quark);
-
- import_title = g_strdup_printf (_("Import '%s' Settings"),
- gimp_tool_get_label (tool));
- export_title = g_strdup_printf (_("Export '%s' Settings"),
- gimp_tool_get_label (tool));
-
- g_object_set (filter_tool->settings_box,
- "visible", TRUE,
- "config", filter_tool->config,
- "container", filter_tool->settings,
- "help-id", gimp_tool_get_help_id (tool),
- "import-title", import_title,
- "export-title", export_title,
- "default-folder", settings_folder,
- "last-file", NULL,
- NULL);
-
- g_free (import_title);
- g_free (export_title);
- }
- else
- {
- g_object_set (filter_tool->settings_box,
- "visible", FALSE,
- "config", NULL,
- "container", NULL,
- "help-id", NULL,
- "import-title", NULL,
- "export-title", NULL,
- "default-folder", NULL,
- "last-file", NULL,
- NULL);
- }
- }
-}
-
void
gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
GimpConfig *config)
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index 0ce0c5e..31ff909 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -74,8 +74,7 @@ struct _GimpFilterToolClass
/* virtual functions */
gchar * (* get_operation) (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
void (* dialog) (GimpFilterTool *filter_tool);
void (* reset) (GimpFilterTool *filter_tool);
void (* set_config) (GimpFilterTool *filter_tool,
@@ -104,9 +103,6 @@ GType gimp_filter_tool_get_type (void) G_GNUC_CONST;
void gimp_filter_tool_get_operation (GimpFilterTool *filter_tool);
-void gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
- gboolean has_settings);
-
void gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
GimpConfig *config);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 60be850..3134f82 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -72,8 +72,7 @@ static gboolean gimp_levels_tool_initialize (GimpTool *tool,
GError **error);
static gchar * gimp_levels_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
static void gimp_levels_tool_dialog (GimpFilterTool *filter_tool);
static void gimp_levels_tool_reset (GimpFilterTool *filter_tool);
static void gimp_levels_tool_config_notify (GimpFilterTool *filter_tool,
@@ -237,11 +236,9 @@ gimp_levels_tool_initialize (GimpTool *tool,
static gchar *
gimp_levels_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings)
+ gchar **description)
{
- *description = g_strdup (_("Adjust Color Levels"));
- *has_settings = TRUE;
+ *description = g_strdup (_("Adjust Color Levels"));
return g_strdup ("gimp:levels");
}
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index a2a802b..574cb06 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -83,8 +83,7 @@ static void gimp_operation_tool_options_notify (GimpTool *tool,
const GParamSpec *pspec);
static gchar * gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
static void gimp_operation_tool_dialog (GimpFilterTool *filter_tool);
static void gimp_operation_tool_reset (GimpFilterTool *filter_tool);
static void gimp_operation_tool_set_config (GimpFilterTool *filter_tool,
@@ -269,13 +268,11 @@ gimp_operation_tool_options_notify (GimpTool *tool,
static gchar *
gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings)
+ gchar **description)
{
GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool);
- *description = g_strdup (op_tool->description);
- *has_settings = FALSE;
+ *description = g_strdup (op_tool->description);
return g_strdup (op_tool->operation);
}
@@ -527,10 +524,6 @@ gimp_operation_tool_create_gui (GimpOperationTool *op_tool)
g_object_add_weak_pointer (G_OBJECT (op_tool->options_gui),
(gpointer) &op_tool->options_gui);
- /* ugly, see comment in the function */
- gimp_filter_tool_set_has_settings (filter_tool,
- ! GTK_IS_LABEL (op_tool->options_gui));
-
for (aux = 1; ; aux++)
{
gchar pad[32];
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 14eb036..cafc27d 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -52,8 +52,7 @@ static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
GError **error);
static gchar * gimp_threshold_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings);
+ gchar **description);
static void gimp_threshold_tool_dialog (GimpFilterTool *filter_tool);
static void gimp_threshold_tool_config_notify (GimpFilterTool *filter_tool,
GimpConfig *config,
@@ -152,11 +151,9 @@ gimp_threshold_tool_initialize (GimpTool *tool,
static gchar *
gimp_threshold_tool_get_operation (GimpFilterTool *filter_tool,
- gchar **description,
- gboolean *has_settings)
+ gchar **description)
{
- *description = g_strdup (_("Apply Threshold"));
- *has_settings = TRUE;
+ *description = g_strdup (_("Apply Threshold"));
return g_strdup ("gimp:threshold");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]