void gimp_operation_tool_set_operation (GimpOperationTool *tool, const gchar *operation, const gchar *undo_desc) { g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool)); g_return_if_fail (operation != NULL); if (tool->operation) g_free (tool->operation); if (tool->undo_desc) g_free (tool->undo_desc); tool->operation = g_strdup (operation); tool->undo_desc = g_strdup (undo_desc); if (tool->config) g_object_unref (tool->config); tool->config = gimp_gegl_get_config_proxy (tool->operation, GIMP_TYPE_IMAGE_MAP_CONFIG); gimp_image_map_tool_get_operation (GIMP_IMAGE_MAP_TOOL (tool)); 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 */ if (tool->options_table) { gtk_widget_destroy (tool->options_table); tool->options_table = NULL; } if (tool->config) { tool->options_table = gimp_prop_table_new (G_OBJECT (tool->config), G_TYPE_FROM_INSTANCE (tool->config), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)), (GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker, tool); if (tool->options_box) { gtk_container_add (GTK_CONTAINER (tool->options_box), tool->options_table); gtk_widget_show (tool->options_table); } } 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)); }
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)); }