[gimp/soc-2011-seamless-clone2] app: add a stock_id to GimpImageMap and use it for its filter
- From: Clayton Walker <claytonw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-seamless-clone2] app: add a stock_id to GimpImageMap and use it for its filter
- Date: Wed, 8 May 2013 15:13:53 +0000 (UTC)
commit 1cd1ea59a6eae20cd5a7f5c54a633aae93353b41
Author: Michael Natterer <mitch gimp org>
Date: Tue Apr 16 20:32:58 2013 +0200
app: add a stock_id to GimpImageMap and use it for its filter
Refactor GimpImageMapTool and GimpOperationTool to set the stock_id,
and to be a bit smarter with the image map's undo string.
app/core/gimpimagemap.c | 18 ++++++++++++---
app/core/gimpimagemap.h | 3 +-
app/tools/gimpcagetool.c | 3 +-
app/tools/gimpimagemaptool.c | 19 ++++++++++++----
app/tools/gimpimagemaptool.h | 3 +-
app/tools/gimpoperationtool.c | 46 ++++++++++++++++++----------------------
app/tools/gimpoperationtool.h | 4 +-
7 files changed, 57 insertions(+), 39 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index 5eb1c40..dae6c15 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -65,10 +65,10 @@ struct _GimpImageMap
GimpDrawable *drawable;
gchar *undo_desc;
+ GeglNode *operation;
+ gchar *stock_id;
GimpFilter *filter;
-
- GeglNode *operation;
GeglNode *translate;
GimpApplicator *applicator;
};
@@ -161,6 +161,12 @@ gimp_image_map_finalize (GObject *object)
image_map->operation = NULL;
}
+ if (image_map->stock_id)
+ {
+ g_free (image_map->stock_id);
+ image_map->stock_id = NULL;
+ }
+
if (image_map->filter)
{
g_object_unref (image_map->filter);
@@ -230,7 +236,8 @@ gimp_image_map_get_pixel_at (GimpPickable *pickable,
GimpImageMap *
gimp_image_map_new (GimpDrawable *drawable,
const gchar *undo_desc,
- GeglNode *operation)
+ GeglNode *operation,
+ const gchar *stock_id)
{
GimpImageMap *image_map;
@@ -244,6 +251,7 @@ gimp_image_map_new (GimpDrawable *drawable,
image_map->undo_desc = g_strdup (undo_desc);
image_map->operation = g_object_ref (operation);
+ image_map->stock_id = g_strdup (stock_id);
gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable));
@@ -276,7 +284,9 @@ gimp_image_map_apply (GimpImageMap *image_map,
GeglNode *filter_output;
GeglNode *input;
- image_map->filter = gimp_filter_new ("Image Map");
+ image_map->filter = gimp_filter_new (image_map->undo_desc);
+ gimp_viewable_set_stock_id (GIMP_VIEWABLE (image_map->filter),
+ image_map->stock_id);
filter_node = gimp_filter_get_node (image_map->filter);
diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h
index fbf0f99..c4a1545 100644
--- a/app/core/gimpimagemap.h
+++ b/app/core/gimpimagemap.h
@@ -51,7 +51,8 @@ GType gimp_image_map_get_type (void) G_GNUC_CONST;
GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
const gchar *undo_desc,
- GeglNode *operation);
+ GeglNode *operation,
+ const gchar *stock_id);
void gimp_image_map_apply (GimpImageMap *image_map,
const GeglRectangle *visible);
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 4e6562c..1c1e8e3 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -1242,7 +1242,8 @@ gimp_cage_tool_create_image_map (GimpCageTool *ct,
ct->image_map = gimp_image_map_new (drawable,
_("Cage transform"),
- ct->render_node);
+ ct->render_node,
+ GIMP_STOCK_TOOL_CAGE);
g_signal_connect (ct->image_map, "flush",
G_CALLBACK (gimp_cage_tool_image_map_flush),
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index cf687ec..64333c6 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -438,7 +438,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
image_map_tool->drawable = drawable;
- gimp_image_map_tool_create_map (image_map_tool);
+ gimp_image_map_tool_create_map (image_map_tool, NULL);
return TRUE;
}
@@ -661,8 +661,11 @@ gimp_image_map_tool_reset (GimpImageMapTool *tool)
}
void
-gimp_image_map_tool_create_map (GimpImageMapTool *tool)
+gimp_image_map_tool_create_map (GimpImageMapTool *tool,
+ const gchar *undo_desc)
{
+ GimpToolInfo *tool_info;
+
g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool));
if (tool->image_map)
@@ -673,9 +676,15 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
g_assert (tool->operation);
+ tool_info = GIMP_TOOL (tool)->tool_info;
+
+ if (! undo_desc)
+ undo_desc = tool_info->blurb;
+
tool->image_map = gimp_image_map_new (tool->drawable,
- GIMP_TOOL (tool)->tool_info->blurb,
- tool->operation);
+ undo_desc,
+ tool->operation,
+ gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info)));
g_signal_connect (tool->image_map, "flush",
G_CALLBACK (gimp_image_map_tool_flush),
@@ -809,7 +818,7 @@ gimp_image_map_tool_gegl_notify (GObject *config,
{
gimp_tool_control_push_preserve (GIMP_TOOL (im_tool)->control, TRUE);
- gimp_image_map_tool_create_map (im_tool);
+ gimp_image_map_tool_create_map (im_tool, NULL);
gimp_tool_control_pop_preserve (GIMP_TOOL (im_tool)->control);
diff --git a/app/tools/gimpimagemaptool.h b/app/tools/gimpimagemaptool.h
index bd7713b..35efe7b 100644
--- a/app/tools/gimpimagemaptool.h
+++ b/app/tools/gimpimagemaptool.h
@@ -101,7 +101,8 @@ GType gimp_image_map_tool_get_type (void) G_GNUC_CONST;
void gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool);
/* temp hack for the gegl tool */
-void gimp_image_map_tool_create_map (GimpImageMapTool *image_map_tool);
+void gimp_image_map_tool_create_map (GimpImageMapTool *image_map_tool,
+ const gchar *undo_desc);
void gimp_image_map_tool_edit_as (GimpImageMapTool *image_map_tool,
const gchar *new_tool_id,
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index bf9bacc..d22bde6 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -149,10 +149,10 @@ gimp_operation_tool_finalize (GObject *object)
tool->config = NULL;
}
- if (tool->dialog_desc)
+ if (tool->undo_desc)
{
- g_free (tool->dialog_desc);
- tool->dialog_desc = NULL;
+ g_free (tool->undo_desc);
+ tool->undo_desc = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -220,9 +220,9 @@ gimp_operation_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (tool->options_table);
}
- if (tool->dialog_desc)
+ if (tool->undo_desc)
g_object_set (GIMP_IMAGE_MAP_TOOL (tool)->dialog,
- "description", tool->dialog_desc,
+ "description", tool->undo_desc,
NULL);
}
@@ -262,8 +262,8 @@ gimp_operation_tool_get_settings_ui (GimpImageMapTool *image_map_tool,
filename = g_build_filename (gimp_directory (), "filters", basename, NULL);
g_free (basename);
- import_title = g_strdup_printf (_("Import '%s' Settings"), tool->dialog_desc);
- export_title = g_strdup_printf (_("Export '%s' Settings"), tool->dialog_desc);
+ import_title = g_strdup_printf (_("Import '%s' Settings"), tool->undo_desc);
+ export_title = g_strdup_printf (_("Export '%s' Settings"), tool->undo_desc);
widget =
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->get_settings_ui (image_map_tool,
@@ -306,7 +306,7 @@ gimp_operation_tool_config_notify (GObject *object,
void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
- const gchar *dialog_desc)
+ const gchar *undo_desc)
{
g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool));
g_return_if_fail (operation != NULL);
@@ -317,6 +317,12 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
tool->operation = NULL;
}
+ if (tool->undo_desc)
+ {
+ g_free (tool->undo_desc);
+ tool->undo_desc = NULL;
+ }
+
if (tool->config)
{
g_object_unref (tool->config);
@@ -330,6 +336,7 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
}
tool->operation = g_strdup (operation);
+ tool->undo_desc = g_strdup (undo_desc);
if (GIMP_IMAGE_MAP_TOOL (tool)->image_map)
{
@@ -343,7 +350,7 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
NULL);
if (GIMP_TOOL (tool)->drawable)
- gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool));
+ gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool), undo_desc);
tool->config = gimp_gegl_get_config_proxy (tool->operation,
GIMP_TYPE_IMAGE_MAP_CONFIG);
@@ -351,7 +358,7 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
GIMP_VIEWABLE_GET_CLASS (tool->config)->default_stock_id = GIMP_STOCK_GEGL;
- if (dialog_desc)
+ if (undo_desc)
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = "yes"; /* XXX hack */
else
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = NULL; /* XXX hack */
@@ -383,21 +390,10 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
}
}
- if (tool->dialog_desc)
- {
- g_free (tool->dialog_desc);
- tool->dialog_desc = NULL;
- }
-
- if (dialog_desc)
- {
- tool->dialog_desc = g_strdup (dialog_desc);
-
- if (GIMP_IMAGE_MAP_TOOL (tool)->dialog)
- g_object_set (GIMP_IMAGE_MAP_TOOL (tool)->dialog,
- "description", dialog_desc,
- NULL);
- }
+ if (undo_desc && GIMP_IMAGE_MAP_TOOL (tool)->dialog)
+ g_object_set (GIMP_IMAGE_MAP_TOOL (tool)->dialog,
+ "description", undo_desc,
+ NULL);
if (GIMP_TOOL (tool)->drawable)
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
diff --git a/app/tools/gimpoperationtool.h b/app/tools/gimpoperationtool.h
index 0abfe73..ddca8ba 100644
--- a/app/tools/gimpoperationtool.h
+++ b/app/tools/gimpoperationtool.h
@@ -38,10 +38,10 @@ struct _GimpOperationTool
GimpImageMapTool parent_instance;
gchar *operation;
+ gchar *undo_desc;
GimpObject *config;
/* dialog */
- gchar *dialog_desc;
GtkWidget *options_box;
GtkWidget *options_table;
};
@@ -59,7 +59,7 @@ GType gimp_operation_tool_get_type (void) G_GNUC_CONST;
void gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
- const gchar *dialog_desc);
+ const gchar *undo_desc);
#endif /* __GIMP_OPERATION_TOOL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]