static void gimp_image_map_tool_map (GimpImageMapTool *tool) { if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map) GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool); gimp_image_map_apply (tool->image_map, NULL); }
static void gimp_image_map_tool_map (GimpImageMapTool *tool) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (GIMP_TOOL (tool)->display->shell); GimpItem *item = GIMP_ITEM (tool->drawable); gint x, y; gint w, h; gint off_x, off_y; GeglRectangle visible; GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool); gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h); gimp_item_offsets (item, &off_x, &off_y); gimp_rectangle_intersect (x, y, w, h, off_x, off_y, gimp_item_width (item), gimp_item_height (item), &visible.x, &visible.y, &visible.width, &visible.height); visible.x -= off_x; visible.y -= off_y; gimp_image_map_apply (tool->image_map, &visible); }
static void gimp_image_map_tool_dialog (GimpImageMapTool *im_tool) { GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool)->dialog (im_tool); g_signal_connect (gimp_tool_gui_get_dialog (im_tool->gui), "unmap", G_CALLBACK (gimp_image_map_tool_dialog_unmap), im_tool); }
static void gimp_image_map_tool_reset (GimpImageMapTool *im_tool) { if (im_tool->config) g_object_freeze_notify (im_tool->config); GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool)->reset (im_tool); if (im_tool->config) g_object_thaw_notify (im_tool->config); }
static void gimp_image_map_tool_reset (GimpImageMapTool *tool) { if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset) { GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool); } else if (tool->config) { if (tool->default_config) { gimp_config_copy (GIMP_CONFIG (tool->default_config), GIMP_CONFIG (tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (tool->config)); } } }
static GObject * gimp_image_map_tool_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpImageMapTool *image_map_tool; GimpImageMapToolClass *klass; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); image_map_tool = GIMP_IMAGE_MAP_TOOL (object); klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool); if (klass->get_operation) image_map_tool->operation = klass->get_operation (image_map_tool, &image_map_tool->config); return object; }
static void gimp_image_map_tool_color_picked (GimpColorTool *color_tool, GimpColorPickState pick_state, gdouble x, gdouble y, const Babl *sample_format, gpointer pixel, const GimpRGB *color) { GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (color_tool); gpointer identifier; g_return_if_fail (GTK_IS_WIDGET (im_tool->active_picker)); identifier = g_object_get_data (G_OBJECT (im_tool->active_picker), "picker-identifier"); GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool)->color_picked (im_tool, identifier, x, y, sample_format, color); }
static void gimp_image_map_tool_dialog (GimpImageMapTool *tool) { GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->dialog (tool); }
static gboolean gimp_image_map_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool); GimpToolInfo *tool_info = tool->tool_info; GimpDrawable *drawable; /* set display so the dialog can be hidden on display destruction */ tool->display = display; if (! image_map_tool->shell) { GimpImageMapToolClass *klass; GtkWidget *shell; GtkWidget *vbox; GtkWidget *toggle; const gchar *stock_id; klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool); stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info)); image_map_tool->shell = shell = gimp_tool_dialog_new (tool_info, display->shell, klass->shell_desc, GIMP_STOCK_RESET, RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (shell), RESPONSE_RESET, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (shell, "response", G_CALLBACK (gimp_image_map_tool_response), G_OBJECT (image_map_tool), 0); image_map_tool->main_vbox = vbox = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox); if (klass->settings_name) gimp_image_map_tool_add_settings_gui (image_map_tool); /* The preview toggle */ toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options), "preview", _("_Preview")); gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), toggle, FALSE, FALSE, 0); gtk_widget_show (toggle); g_signal_connect_object (tool_info->tool_options, "notify::preview", G_CALLBACK (gimp_image_map_tool_notify_preview), image_map_tool, 0); /* Fill in subclass widgets */ gimp_image_map_tool_dialog (image_map_tool); gtk_widget_show (vbox); if (image_map_tool->operation) g_signal_connect_object (tool_info->gimp->config, "notify::use-gegl", G_CALLBACK (gimp_image_map_tool_gegl_notify), image_map_tool, 0); } drawable = gimp_image_get_active_drawable (display->image); gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (image_map_tool->shell), GIMP_VIEWABLE (drawable), GIMP_CONTEXT (tool_info->tool_options)); gtk_widget_show (image_map_tool->shell); image_map_tool->drawable = drawable; gimp_image_map_tool_create_map (image_map_tool); return TRUE; }
void gimp_operation_tool_set_operation (GimpOperationTool *tool, const gchar *operation, const gchar *undo_desc, const gchar *icon_name) { GimpImageMapTool *im_tool; GtkSizeGroup *size_group = NULL; gint aux; g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool)); g_return_if_fail (operation != NULL); im_tool = GIMP_IMAGE_MAP_TOOL (tool); if (tool->operation) g_free (tool->operation); if (tool->undo_desc) g_free (tool->undo_desc); if (tool->icon_name) g_free (tool->icon_name); tool->operation = g_strdup (operation); tool->undo_desc = g_strdup (undo_desc); tool->icon_name = g_strdup (icon_name); g_list_free_full (tool->aux_inputs, (GDestroyNotify) gimp_operation_tool_aux_input_free); tool->aux_inputs = NULL; gimp_image_map_tool_get_operation (im_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_gui) { gtk_widget_destroy (tool->options_gui); tool->options_gui = NULL; if (im_tool->active_picker) { im_tool->active_picker = NULL; gimp_color_tool_disable (GIMP_COLOR_TOOL (tool)); } } for (aux = 1; ; aux++) { gchar pad[32]; gchar label[32]; if (aux == 1) { g_snprintf (pad, sizeof (pad), "aux"); g_snprintf (label, sizeof (label), _("Aux Input")); } else { g_snprintf (pad, sizeof (pad), "aux%d", aux); g_snprintf (label, sizeof (label), _("Aux%d Input"), aux); } if (gegl_node_has_pad (im_tool->operation, pad)) { AuxInput *input; GtkWidget *toggle; if (! size_group) size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); input = gimp_operation_tool_aux_input_new (tool, im_tool->operation, pad, label); tool->aux_inputs = g_list_append (tool->aux_inputs, input); toggle = gimp_buffer_source_box_get_toggle (GIMP_BUFFER_SOURCE_BOX (input->box)); gtk_size_group_add_widget (size_group, toggle); if (tool->options_box) { gtk_box_pack_start (GTK_BOX (tool->options_box), input->box, FALSE, FALSE, 0); gtk_widget_show (input->box); } } else { break; } } if (size_group) g_object_unref (size_group); if (im_tool->config) { tool->options_gui = gimp_prop_gui_new (G_OBJECT (im_tool->config), G_TYPE_FROM_INSTANCE (im_tool->config), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)), (GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker, tool); if (tool->options_box) { gtk_box_pack_start (GTK_BOX (tool->options_box), tool->options_gui, FALSE, FALSE, 0); gtk_widget_show (tool->options_gui); } } if (im_tool->gui) { if (undo_desc) gimp_tool_gui_set_description (im_tool->gui, undo_desc); if (icon_name) gimp_tool_gui_set_icon_name (im_tool->gui, icon_name); } if (GIMP_TOOL (tool)->drawable) { gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable); gimp_image_map_tool_preview (im_tool); } }
static void gimp_operation_tool_init (GimpOperationTool *tool) { GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = NULL; /* XXX hack */ }
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)); }
void gimp_operation_tool_set_operation (GimpOperationTool *tool, const gchar *operation, const gchar *undo_desc, const gchar *icon_name) { GimpImageMapTool *im_tool; g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool)); g_return_if_fail (operation != NULL); im_tool = GIMP_IMAGE_MAP_TOOL (tool); if (tool->operation) g_free (tool->operation); if (tool->undo_desc) g_free (tool->undo_desc); if (tool->icon_name) g_free (tool->icon_name); tool->operation = g_strdup (operation); tool->undo_desc = g_strdup (undo_desc); tool->icon_name = g_strdup (icon_name); if (tool->aux_input) { g_object_unref (tool->aux_input); tool->aux_input = NULL; } if (tool->aux2_input) { g_object_unref (tool->aux2_input); tool->aux2_input = NULL; } gimp_image_map_tool_get_operation (im_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->aux_input_box) { gtk_widget_destroy (tool->aux_input_box); tool->aux_input_button = NULL; tool->aux_input_box = NULL; } if (tool->aux2_input_box) { gtk_widget_destroy (tool->aux2_input_box); tool->aux2_input_button = NULL; tool->aux2_input_box = NULL; } if (tool->options_gui) { gtk_widget_destroy (tool->options_gui); tool->options_gui = NULL; if (im_tool->active_picker) { im_tool->active_picker = NULL; gimp_color_tool_disable (GIMP_COLOR_TOOL (tool)); } } if (gegl_node_has_pad (im_tool->operation, "aux")) { GimpContext *context; GtkWidget *label; tool->aux_input = gegl_node_new_child (NULL, "operation", "gegl:buffer-source", NULL); gegl_node_connect_to (tool->aux_input, "output", im_tool->operation, "aux"); context = GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)); tool->aux_input_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); label = gtk_label_new_with_mnemonic (_("_Aux Input")); gtk_box_pack_start (GTK_BOX (tool->aux_input_box), label, FALSE, FALSE, 0); gtk_widget_show (label); tool->aux_input_button = gimp_pickable_button_new (context, GIMP_VIEW_SIZE_LARGE, 1); gtk_box_pack_start (GTK_BOX (tool->aux_input_box), tool->aux_input_button, FALSE, FALSE, 0); gtk_widget_show (tool->aux_input_button); gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->aux_input_button); if (tool->options_box) { gtk_box_pack_start (GTK_BOX (tool->options_box), tool->aux_input_box, FALSE, FALSE, 0); gtk_widget_show (tool->aux_input_box); } g_signal_connect_object (tool->aux_input_button, "notify::pickable", G_CALLBACK (gimp_operation_tool_aux_notify), tool->aux_input, 0); } if (gegl_node_has_pad (im_tool->operation, "aux2")) { GimpContext *context; GtkWidget *label; tool->aux2_input = gegl_node_new_child (NULL, "operation", "gegl:buffer-source", NULL); gegl_node_connect_to (tool->aux2_input, "output", im_tool->operation, "aux2"); context = GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)); tool->aux2_input_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); label = gtk_label_new_with_mnemonic (_("_Aux2 Input")); gtk_box_pack_start (GTK_BOX (tool->aux2_input_box), label, FALSE, FALSE, 0); gtk_widget_show (label); tool->aux2_input_button = gimp_pickable_button_new (context, GIMP_VIEW_SIZE_LARGE, 1); gtk_box_pack_start (GTK_BOX (tool->aux2_input_box), tool->aux2_input_button, FALSE, FALSE, 0); gtk_widget_show (tool->aux2_input_button); gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->aux2_input_button); if (tool->options_box) { gtk_box_pack_start (GTK_BOX (tool->options_box), tool->aux2_input_box, FALSE, FALSE, 0); gtk_widget_show (tool->aux2_input_box); } g_signal_connect_object (tool->aux2_input_button, "notify::pickable", G_CALLBACK (gimp_operation_tool_aux_notify), tool->aux2_input, 0); } if (im_tool->config) { tool->options_gui = gimp_prop_gui_new (G_OBJECT (im_tool->config), G_TYPE_FROM_INSTANCE (im_tool->config), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)), (GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker, tool); if (tool->options_box) { gtk_box_pack_start (GTK_BOX (tool->options_box), tool->options_gui, FALSE, FALSE, 0); gtk_widget_show (tool->options_gui); } } if (im_tool->gui) { if (undo_desc) gimp_tool_gui_set_description (im_tool->gui, undo_desc); if (icon_name) gimp_tool_gui_set_icon_name (im_tool->gui, icon_name); } if (GIMP_TOOL (tool)->drawable) { gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable); gimp_image_map_tool_preview (im_tool); } }
static gboolean gimp_image_map_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool); GimpToolInfo *tool_info = tool->tool_info; GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpDisplayShell *shell = gimp_display_get_shell (display); if (! drawable) return FALSE; if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("Cannot modify the pixels of layer groups.")); return FALSE; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("The active layer's pixels are locked.")); return FALSE; } if (! gimp_item_is_visible (GIMP_ITEM (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("The active layer is not visible.")); return FALSE; } if (im_tool->active_picker) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (im_tool->active_picker), FALSE); /* set display so the dialog can be hidden on display destruction */ tool->display = display; if (im_tool->config) gimp_config_reset (GIMP_CONFIG (im_tool->config)); if (! im_tool->gui) { GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool); GtkWidget *vbox; GtkWidget *hbox; GtkWidget *toggle; gchar *operation_name; /* disabled for at least GIMP 2.8 */ im_tool->overlay = FALSE; im_tool->gui = gimp_tool_gui_new (tool_info, im_tool->title, im_tool->description, im_tool->icon_name, im_tool->help_id, gtk_widget_get_screen (GTK_WIDGET (shell)), gimp_widget_get_monitor (GTK_WIDGET (shell)), im_tool->overlay, GIMP_STOCK_RESET, RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gimp_tool_gui_set_default_response (im_tool->gui, GTK_RESPONSE_OK); gimp_tool_gui_set_alternative_button_order (im_tool->gui, RESPONSE_RESET, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); vbox = gimp_tool_gui_get_vbox (im_tool->gui); g_signal_connect_object (im_tool->gui, "response", G_CALLBACK (gimp_image_map_tool_response), G_OBJECT (im_tool), 0); if (im_tool->config && klass->settings_name) { GType type = G_TYPE_FROM_INSTANCE (im_tool->config); GimpContainer *settings; GFile *settings_file; GFile *default_folder; GtkWidget *settings_ui; settings = gimp_gegl_config_get_container (type); if (! gimp_list_get_sort_func (GIMP_LIST (settings))) gimp_list_set_sort_func (GIMP_LIST (settings), (GCompareFunc) gimp_settings_compare); settings_file = gimp_tool_info_get_options_file (tool_info, ".settings"); default_folder = gimp_directory_file (klass->settings_name, NULL); settings_ui = klass->get_settings_ui (im_tool, settings, settings_file, klass->import_dialog_title, klass->export_dialog_title, im_tool->help_id, default_folder, &im_tool->settings_box); g_object_unref (default_folder); g_object_unref (settings_file); gtk_box_pack_start (GTK_BOX (vbox), settings_ui, FALSE, FALSE, 0); gtk_widget_show (settings_ui); } /* The gamma hack toggle */ toggle = gtk_check_button_new_with_label ("Gamma hack (temp hack, please ignore)"); gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gamma_hack), im_tool); /* The preview and split view toggles */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options), "preview", NULL); gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 0); gtk_widget_show (toggle); toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options), "preview-split", NULL); gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0); gtk_widget_show (toggle); g_object_bind_property (G_OBJECT (tool_info->tool_options), "preview", toggle, "sensitive", G_BINDING_SYNC_CREATE); /* The area combo */ gegl_node_get (im_tool->operation, "operation", &operation_name, NULL); im_tool->region_combo = gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options), "region", 0, 0); gtk_box_pack_end (GTK_BOX (vbox), im_tool->region_combo, FALSE, FALSE, 0); if (operation_name && gegl_operation_get_key (operation_name, "position-dependent")) { gtk_widget_show (im_tool->region_combo); } g_free (operation_name); /* Fill in subclass widgets */ gimp_image_map_tool_dialog (im_tool); } else { gimp_tool_gui_set_title (im_tool->gui, im_tool->title); gimp_tool_gui_set_description (im_tool->gui, im_tool->description); gimp_tool_gui_set_icon_name (im_tool->gui, im_tool->icon_name); gimp_tool_gui_set_help_id (im_tool->gui, im_tool->help_id); } gimp_tool_gui_set_shell (im_tool->gui, shell); gimp_tool_gui_set_viewable (im_tool->gui, GIMP_VIEWABLE (drawable)); gimp_tool_gui_show (im_tool->gui); im_tool->drawable = drawable; gimp_image_map_tool_create_map (im_tool); gimp_image_map_tool_preview (im_tool); return TRUE; }
void gimp_image_map_tool_get_operation (GimpImageMapTool *im_tool) { GimpImageMapToolClass *klass; GimpToolInfo *tool_info; gchar *operation_name; g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool)); klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool); tool_info = GIMP_TOOL (im_tool)->tool_info; if (im_tool->image_map) { gimp_image_map_abort (im_tool->image_map); g_object_unref (im_tool->image_map); im_tool->image_map = NULL; } if (im_tool->operation) { g_object_unref (im_tool->operation); im_tool->operation = NULL; } if (im_tool->config) { g_signal_handlers_disconnect_by_func (im_tool->config, gimp_image_map_tool_config_notify, im_tool); g_object_unref (im_tool->config); im_tool->config = NULL; } if (im_tool->default_config) { g_object_unref (im_tool->default_config); im_tool->default_config = NULL; } if (im_tool->title) { g_free (im_tool->title); im_tool->title = NULL; } if (im_tool->description) { g_free (im_tool->description); im_tool->description = NULL; } if (im_tool->undo_desc) { g_free (im_tool->undo_desc); im_tool->undo_desc = NULL; } if (im_tool->icon_name) { g_free (im_tool->icon_name); im_tool->icon_name = NULL; } if (im_tool->help_id) { g_free (im_tool->help_id); im_tool->help_id = NULL; } operation_name = klass->get_operation (im_tool, &im_tool->title, &im_tool->description, &im_tool->undo_desc, &im_tool->icon_name, &im_tool->help_id); if (! operation_name) operation_name = g_strdup ("gegl:nop"); if (! im_tool->title) im_tool->title = g_strdup (tool_info->blurb); if (! im_tool->description) im_tool->description = g_strdup (im_tool->title); if (! im_tool->undo_desc) im_tool->undo_desc = g_strdup (tool_info->blurb); if (! im_tool->icon_name) im_tool->icon_name = g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info))); if (! im_tool->help_id) im_tool->help_id = g_strdup (tool_info->help_id); im_tool->operation = gegl_node_new_child (NULL, "operation", operation_name, NULL); im_tool->config = G_OBJECT (gimp_gegl_config_new (operation_name, im_tool->icon_name, GIMP_TYPE_SETTINGS)); gimp_gegl_config_sync_node (GIMP_OBJECT (im_tool->config), im_tool->operation); gimp_gegl_config_connect_node (GIMP_OBJECT (im_tool->config), im_tool->operation); if (im_tool->gui) { gimp_tool_gui_set_title (im_tool->gui, im_tool->title); gimp_tool_gui_set_description (im_tool->gui, im_tool->description); gimp_tool_gui_set_icon_name (im_tool->gui, im_tool->icon_name); gimp_tool_gui_set_help_id (im_tool->gui, im_tool->help_id); } if (gegl_operation_get_key (operation_name, "position-dependent")) { if (im_tool->gui) gtk_widget_show (im_tool->region_combo); } else { if (im_tool->gui) gtk_widget_hide (im_tool->region_combo); g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool), "region", GIMP_IMAGE_MAP_REGION_SELECTION, NULL); } g_free (operation_name); g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool), "preview-split", FALSE, "preview-position", 0.5, NULL); if (im_tool->config) g_signal_connect_object (im_tool->config, "notify", G_CALLBACK (gimp_image_map_tool_config_notify), G_OBJECT (im_tool), 0); if (GIMP_TOOL (im_tool)->drawable) gimp_image_map_tool_create_map (im_tool); }
void gimp_image_map_tool_get_operation (GimpImageMapTool *image_map_tool) { GimpImageMapToolClass *klass; gchar *operation_name; g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (image_map_tool)); klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool); if (image_map_tool->image_map) { gimp_image_map_abort (image_map_tool->image_map); g_object_unref (image_map_tool->image_map); image_map_tool->image_map = NULL; } if (image_map_tool->operation) { g_object_unref (image_map_tool->operation); image_map_tool->operation = NULL; } if (image_map_tool->config) { g_signal_handlers_disconnect_by_func (image_map_tool->config, gimp_image_map_tool_config_notify, image_map_tool); g_object_unref (image_map_tool->config); image_map_tool->config = NULL; } if (image_map_tool->undo_desc) { g_free (image_map_tool->undo_desc); image_map_tool->undo_desc = NULL; } image_map_tool->operation = klass->get_operation (image_map_tool, &image_map_tool->config, &image_map_tool->undo_desc); if (! image_map_tool->undo_desc) image_map_tool->undo_desc = g_strdup (GIMP_TOOL (image_map_tool)->tool_info->blurb); gegl_node_get (image_map_tool->operation, "operation", &operation_name, NULL); if (operation_name && gegl_operation_get_key (operation_name, "position-dependent")) { if (image_map_tool->region_combo) gtk_widget_show (image_map_tool->region_combo); } else { if (image_map_tool->region_combo) gtk_widget_show (image_map_tool->region_combo); g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (image_map_tool), "region", GIMP_IMAGE_MAP_REGION_SELECTION, NULL); } g_free (operation_name); if (image_map_tool->config) g_signal_connect_object (image_map_tool->config, "notify", G_CALLBACK (gimp_image_map_tool_config_notify), G_OBJECT (image_map_tool), 0); if (GIMP_TOOL (image_map_tool)->drawable) gimp_image_map_tool_create_map (image_map_tool); }