static void gimp_image_map_tool_notify_preview (GObject *config, GParamSpec *pspec, GimpImageMapTool *image_map_tool) { GimpTool *tool = GIMP_TOOL (image_map_tool); GimpImageMapOptions *options = GIMP_IMAGE_MAP_OPTIONS (config); if (image_map_tool->image_map) { if (options->preview) { gimp_tool_control_set_preserve (tool->control, TRUE); gimp_image_map_tool_map (image_map_tool); gimp_tool_control_set_preserve (tool->control, FALSE); } else { gimp_tool_control_set_preserve (tool->control, TRUE); gimp_image_map_clear (image_map_tool->image_map); gimp_tool_control_set_preserve (tool->control, FALSE); gimp_image_map_tool_flush (image_map_tool->image_map, image_map_tool); } } }
void gimp_image_map_tool_create_map (GimpImageMapTool *tool) { Gimp *gimp; gboolean use_gegl; g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool)); gimp = GIMP_TOOL (tool)->tool_info->gimp; if (tool->image_map) { gimp_image_map_clear (tool->image_map); g_object_unref (tool->image_map); } g_assert (tool->operation || tool->apply_func); use_gegl = gimp_use_gegl (gimp) || ! tool->apply_func; tool->image_map = gimp_image_map_new (tool->drawable, GIMP_TOOL (tool)->tool_info->blurb, use_gegl ? tool->operation : NULL, tool->apply_func, tool->apply_data); g_signal_connect (tool->image_map, "flush", G_CALLBACK (gimp_image_map_tool_flush), tool); }
static void gimp_gegl_tool_operation_changed (GtkWidget *widget, GimpGeglTool *tool) { GtkTreeModel *model; GtkTreeIter iter; if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) return; model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); if (tool->operation) { g_free (tool->operation); tool->operation = NULL; } if (tool->config) { g_object_unref (tool->config); tool->config = NULL; } gtk_tree_model_get (model, &iter, COLUMN_NAME, &tool->operation, -1); if (! tool->operation) return; if (GIMP_IMAGE_MAP_TOOL (tool)->image_map) { gimp_image_map_clear (GIMP_IMAGE_MAP_TOOL (tool)->image_map); g_object_unref (GIMP_IMAGE_MAP_TOOL (tool)->image_map); GIMP_IMAGE_MAP_TOOL (tool)->image_map = NULL; } gegl_node_set (GIMP_IMAGE_MAP_TOOL (tool)->operation, "operation", tool->operation, NULL); gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool)); tool->config = gimp_gegl_tool_get_config (tool); if (tool->options_table) { gtk_container_remove (GTK_CONTAINER (tool->options_frame), tool->options_table); tool->options_table = NULL; } if (tool->config) { g_signal_connect_object (tool->config, "notify", G_CALLBACK (gimp_gegl_tool_config_notify), G_OBJECT (tool), 0); tool->options_table = gimp_prop_table_new (G_OBJECT (tool->config), G_TYPE_FROM_INSTANCE (tool->config), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool))); gtk_container_add (GTK_CONTAINER (tool->options_frame), tool->options_table); gtk_widget_show (tool->options_table); } gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); }
static void gimp_cage_tool_options_notify (GimpTool *tool, GimpToolOptions *options, const GParamSpec *pspec) { GimpCageTool *ct = GIMP_CAGE_TOOL (tool); GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec); if (! tool->display) return; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); if (strcmp (pspec->name, "cage-mode") == 0) { GimpCageMode mode; g_object_get (options, "cage-mode", &mode, NULL); if (mode == GIMP_CAGE_MODE_DEFORM) { /* switch to deform mode */ ct->cage_complete = TRUE; gimp_cage_config_reset_displacement (ct->config); gimp_cage_config_reverse_cage_if_needed (ct->config); gimp_tool_push_status (tool, tool->display, _("Press ENTER to commit the transform")); ct->tool_state = DEFORM_STATE_WAIT; if (! ct->render_node) { gimp_cage_tool_create_render_node (ct); } if (ct->dirty_coef) { gimp_cage_tool_compute_coef (ct); gimp_cage_tool_render_node_update (ct); } if (! ct->image_map) { GimpImage *image = gimp_display_get_image (tool->display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); gimp_cage_tool_create_image_map (ct, drawable); } gimp_cage_tool_image_map_update (ct); } else { /* switch to edit mode */ gimp_image_map_clear (ct->image_map); gimp_cage_tool_image_map_flush (ct->image_map, tool); gimp_tool_pop_status (tool, tool->display); ct->tool_state = CAGE_STATE_WAIT; } } else if (strcmp (pspec->name, "fill-plain-color") == 0) { gimp_cage_tool_render_node_update (ct); gimp_cage_tool_image_map_update (ct); } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); }