Commit 29795a29 authored by Michael Natterer's avatar Michael Natterer 😴

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().
parent 29385990
......@@ -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");
}
......
......@@ -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");
}
......
......@@ -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)
......
......@@ -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);
......
......@@ -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");
}
......
......@@ -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];
......
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment