static void gimp_viewable_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GimpViewableDialog *dialog = GIMP_VIEWABLE_DIALOG (object); switch (property_id) { case PROP_VIEWABLE: g_value_set_object (value, dialog->view ? GIMP_VIEW (dialog->view)->viewable : NULL); break; case PROP_CONTEXT: g_value_set_object (value, dialog->context); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
void colormap_edit_color_cmd_callback (GtkAction *action, gpointer data) { GimpColormapEditor *editor; GimpImage *image; const guchar *colormap; GimpRGB color; gchar *desc; return_if_no_image (image, data); editor = GIMP_COLORMAP_EDITOR (data); colormap = gimp_image_get_colormap (image); gimp_rgba_set_uchar (&color, colormap[editor->col_index * 3], colormap[editor->col_index * 3 + 1], colormap[editor->col_index * 3 + 2], OPAQUE_OPACITY); desc = g_strdup_printf (_("Edit colormap entry #%d"), editor->col_index); if (! editor->color_dialog) { editor->color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (image), action_data_get_context (data), _("Edit Colormap Entry"), GIMP_STOCK_COLORMAP, desc, GTK_WIDGET (editor), gimp_dialog_factory_from_name ("toplevel"), "gimp-colormap-editor-color-dialog", (const GimpRGB *) &color, FALSE, FALSE); g_signal_connect (editor->color_dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &editor->color_dialog); g_signal_connect (editor->color_dialog, "update", G_CALLBACK (colormap_edit_color_update), editor); } else { gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog), GIMP_VIEWABLE (image), action_data_get_context (data)); g_object_set (editor->color_dialog, "description", desc, NULL); gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog), &color); } g_free (desc); gtk_window_present (GTK_WINDOW (editor->color_dialog)); }
static void gimp_viewable_dialog_dispose (GObject *object) { GimpViewableDialog *dialog = GIMP_VIEWABLE_DIALOG (object); if (dialog->view) gimp_viewable_dialog_set_viewable (dialog, NULL, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); }
void palette_editor_edit_color_cmd_callback (GtkAction *action, gpointer data) { GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); GimpPalette *palette; if (! (data_editor->data_editable && editor->color)) return; palette = GIMP_PALETTE (data_editor->data); if (! editor->color_dialog) { editor->color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (palette), data_editor->context, _("Edit Palette Color"), GIMP_STOCK_PALETTE, _("Edit Color Palette Entry"), GTK_WIDGET (editor), gimp_dialog_factory_get_singleton (), "gimp-palette-editor-color-dialog", &editor->color->color, FALSE, FALSE); g_signal_connect (editor->color_dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &editor->color_dialog); g_signal_connect (editor->color_dialog, "update", G_CALLBACK (palette_editor_edit_color_update), editor); } else { gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog), GIMP_VIEWABLE (palette), data_editor->context); gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog), &editor->color->color); } gtk_window_present (GTK_WINDOW (editor->color_dialog)); }
static void gimp_viewable_dialog_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpViewableDialog *dialog = GIMP_VIEWABLE_DIALOG (object); switch (property_id) { case PROP_VIEWABLE: gimp_viewable_dialog_set_viewable (dialog, g_value_get_object (value), dialog->context); break; case PROP_CONTEXT: gimp_viewable_dialog_set_viewable (dialog, dialog->view ? GIMP_VIEW (dialog->view)->viewable : NULL, g_value_get_object (value)); break; case PROP_ICON_NAME: gtk_image_set_from_icon_name (GTK_IMAGE (dialog->icon), g_value_get_string (value), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case PROP_DESC: gtk_label_set_text (GTK_LABEL (dialog->desc_label), g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
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; }
static void stroke_dialog_response (GtkWidget *widget, gint response_id, GtkWidget *dialog) { GimpStrokeDesc *desc; GimpItem *item; GimpImage *image; GimpContext *context; item = g_object_get_data (G_OBJECT (dialog), "gimp-item"); desc = g_object_get_data (G_OBJECT (dialog), "gimp-stroke-desc"); image = gimp_item_get_image (item); context = GIMP_VIEWABLE_DIALOG (dialog)->context; switch (response_id) { case RESPONSE_RESET: { GimpToolInfo *tool_info = gimp_context_get_tool (context); GtkWidget *combo = g_object_get_data (G_OBJECT (dialog), "gimp-tool-menu");; gimp_config_reset (GIMP_CONFIG (desc)); gimp_container_view_select_item (GIMP_CONTAINER_VIEW (combo), GIMP_VIEWABLE (tool_info->paint_info)); } break; case GTK_RESPONSE_OK: { GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpStrokeDesc *saved_desc; GError *error = NULL; if (! drawable) { gimp_message (context->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, _("There is no active layer or channel " "to stroke to.")); return; } saved_desc = g_object_get_data (G_OBJECT (context->gimp), "saved-stroke-desc"); if (saved_desc) g_object_ref (saved_desc); else saved_desc = gimp_stroke_desc_new (context->gimp, context); gimp_config_sync (G_OBJECT (desc), G_OBJECT (saved_desc), 0); g_object_set_data_full (G_OBJECT (context->gimp), "saved-stroke-desc", saved_desc, (GDestroyNotify) g_object_unref); if (! gimp_item_stroke (item, drawable, context, desc, FALSE, NULL, &error)) { gimp_message (context->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, "%s", error ? error->message : "NULL"); g_clear_error (&error); return; } gimp_image_flush (image); } /* fallthrough */ default: gtk_widget_destroy (dialog); break; } }
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool) { GimpTool *tool = GIMP_TOOL (picker_tool); GtkWidget *content_area; GtkWidget *hbox; GtkWidget *frame; GimpRGB color; g_return_if_fail (tool->drawable != NULL); picker_tool->dialog = gimp_tool_dialog_new (tool->tool_info, gimp_display_get_shell (tool->display), _("Color Picker Information"), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_window_set_focus_on_map (GTK_WINDOW (picker_tool->dialog), FALSE); gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (picker_tool->dialog), GIMP_VIEWABLE (tool->drawable), GIMP_CONTEXT (gimp_tool_get_options (tool))); g_signal_connect (picker_tool->dialog, "response", G_CALLBACK (gimp_color_picker_tool_info_response), picker_tool); content_area = gtk_dialog_get_content_area (GTK_DIALOG (picker_tool->dialog)); hbox = gtk_hbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); picker_tool->color_frame1 = gimp_color_frame_new (); gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame1), GIMP_COLOR_FRAME_MODE_PIXEL); gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame1, FALSE, FALSE, 0); gtk_widget_show (picker_tool->color_frame1); picker_tool->color_frame2 = gimp_color_frame_new (); gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame2), GIMP_COLOR_FRAME_MODE_RGB); gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame2, FALSE, FALSE, 0); gtk_widget_show (picker_tool->color_frame2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); picker_tool->color_area = gimp_color_area_new (&color, gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); gtk_widget_set_size_request (picker_tool->color_area, 48, -1); gtk_drag_dest_unset (picker_tool->color_area); gtk_container_add (GTK_CONTAINER (frame), picker_tool->color_area); gtk_widget_show (picker_tool->color_area); }
GtkWidget * gimp_color_dialog_new (GimpViewable *viewable, GimpContext *context, const gchar *title, const gchar *stock_id, const gchar *desc, GtkWidget *parent, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const GimpRGB *color, gboolean wants_updates, gboolean show_alpha) { GimpColorDialog *dialog; const gchar *role; g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL); g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL); g_return_val_if_fail (dialog_factory == NULL || GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL); g_return_val_if_fail (dialog_factory == NULL || dialog_identifier != NULL, NULL); g_return_val_if_fail (color != NULL, NULL); if (! context) g_warning ("gimp_color_dialog_new() called with a NULL context"); role = dialog_identifier ? dialog_identifier : "gimp-color-selector"; dialog = g_object_new (GIMP_TYPE_COLOR_DIALOG, "title", title, "role", role, "help-func", gimp_color_dialog_help_func, "help-id", GIMP_HELP_COLOR_DIALOG, "stock-id", stock_id, "description", desc, "parent", parent, NULL); if (viewable) { gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (dialog), viewable, context); } else { GtkWidget *parent; parent = gtk_widget_get_parent (GIMP_VIEWABLE_DIALOG (dialog)->icon); parent = gtk_widget_get_parent (parent); gtk_widget_hide (parent); } dialog->wants_updates = wants_updates; if (dialog_factory) gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier, GTK_WIDGET (dialog)); gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (dialog->selection), show_alpha); if (context) { g_object_set_data (G_OBJECT (context->gimp->config->color_management), "gimp-context", context); gimp_color_selection_set_config (GIMP_COLOR_SELECTION (dialog->selection), context->gimp->config->color_management); g_object_set_data (G_OBJECT (context->gimp->config->color_management), "gimp-context", NULL); } gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color); gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection), color); return GTK_WIDGET (dialog); }