static void gimp_operation_tool_options_notify (GimpTool *tool, GimpToolOptions *options, const GParamSpec *pspec) { GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (tool); GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec); if (! strcmp (pspec->name, "region")) { GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool); /* when the region changes, do we want the operation's on-canvas * controller to move to a new position, or the operation to * change its properties to match the on-canvas controller? * * decided to leave the on-canvas controller where it is and * pretend it has changed, so the operation is updated * accordingly... */ if (filter_tool->widget) g_signal_emit_by_name (filter_tool->widget, "changed"); if (filter_tool->config && tool->drawable) gimp_operation_tool_sync_op (op_tool, FALSE); } }
static gboolean gimp_operation_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { if (GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool); GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (tool); if (filter_tool->config) { GtkWidget *options_gui; gimp_operation_tool_sync_op (op_tool, TRUE); options_gui = g_weak_ref_get (&op_tool->options_gui_ref); if (! options_gui) { gimp_operation_tool_create_gui (op_tool); gimp_operation_tool_add_gui (op_tool); } else { g_object_unref (options_gui); } } return TRUE; } return FALSE; }
static void gimp_operation_tool_reset (GimpImageMapTool *im_tool) { GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool); GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool); if (im_tool->config && GIMP_TOOL (tool)->drawable) gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable); }
static void gimp_operation_tool_reset (GimpFilterTool *filter_tool) { GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool); gimp_operation_tool_unlink_chains (op_tool); GIMP_FILTER_TOOL_CLASS (parent_class)->reset (filter_tool); if (filter_tool->config && GIMP_TOOL (op_tool)->drawable) gimp_operation_tool_sync_op (op_tool, TRUE); gimp_operation_tool_relink_chains (op_tool); }
static gboolean gimp_operation_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { if (GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (op_tool->config) gimp_operation_tool_sync_op (op_tool, drawable); return TRUE; } return FALSE; }
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); } }
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); } }
void gimp_operation_tool_set_operation (GimpOperationTool *op_tool, const gchar *operation, const gchar *title, const gchar *description, const gchar *undo_desc, const gchar *icon_name, const gchar *help_id) { GimpTool *tool; GimpFilterTool *filter_tool; GtkWidget *options_gui; g_return_if_fail (GIMP_IS_OPERATION_TOOL (op_tool)); tool = GIMP_TOOL (op_tool); filter_tool = GIMP_FILTER_TOOL (op_tool); g_free (op_tool->operation); g_free (op_tool->description); op_tool->operation = g_strdup (operation); op_tool->description = g_strdup (description); gimp_tool_set_label (tool, title); gimp_tool_set_undo_desc (tool, undo_desc); gimp_tool_set_icon_name (tool, icon_name); gimp_tool_set_help_id (tool, help_id); g_list_free_full (op_tool->aux_inputs, (GDestroyNotify) gimp_operation_tool_aux_input_free); op_tool->aux_inputs = NULL; gimp_filter_tool_set_widget (filter_tool, NULL); options_gui = g_weak_ref_get (&op_tool->options_gui_ref); if (options_gui) { gimp_filter_tool_disable_color_picking (filter_tool); g_object_unref (options_gui); gtk_widget_destroy (options_gui); } if (! operation) return; gimp_filter_tool_get_operation (filter_tool); if (tool->drawable) gimp_operation_tool_sync_op (op_tool, TRUE); if (filter_tool->config && tool->display) { GtkWidget *options_box; gimp_operation_tool_create_gui (op_tool); options_box = g_weak_ref_get (&op_tool->options_box_ref); if (options_box) { gimp_operation_tool_add_gui (op_tool); g_object_unref (options_box); } } }