static void palette_editor_columns_changed (GtkAdjustment *adj, GimpPaletteEditor *editor) { if (GIMP_DATA_EDITOR (editor)->data) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); gimp_palette_set_columns (palette, ROUND (gtk_adjustment_get_value (adj))); } }
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment, GimpBrushEditor *editor) { GimpBrushGenerated *brush; gdouble radius; gint spikes; gdouble hardness; gdouble ratio; gdouble angle; gdouble spacing; if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data)) return; brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data); radius = gtk_adjustment_get_value (editor->radius_data); spikes = ROUND (gtk_adjustment_get_value (editor->spikes_data)); hardness = gtk_adjustment_get_value (editor->hardness_data); ratio = gtk_adjustment_get_value (editor->aspect_ratio_data); angle = gtk_adjustment_get_value (editor->angle_data); spacing = gtk_adjustment_get_value (editor->spacing_data); if (radius != gimp_brush_generated_get_radius (brush) || spikes != gimp_brush_generated_get_spikes (brush) || hardness != gimp_brush_generated_get_hardness (brush) || ratio != gimp_brush_generated_get_aspect_ratio (brush) || angle != gimp_brush_generated_get_angle (brush) || spacing != gimp_brush_get_spacing (GIMP_BRUSH (brush))) { g_signal_handlers_block_by_func (brush, gimp_brush_editor_notify_brush, editor); gimp_data_freeze (GIMP_DATA (brush)); g_object_freeze_notify (G_OBJECT (brush)); gimp_brush_generated_set_radius (brush, radius); gimp_brush_generated_set_spikes (brush, spikes); gimp_brush_generated_set_hardness (brush, hardness); gimp_brush_generated_set_aspect_ratio (brush, ratio); gimp_brush_generated_set_angle (brush, angle); gimp_brush_set_spacing (GIMP_BRUSH (brush), spacing); g_object_thaw_notify (G_OBJECT (brush)); gimp_data_thaw (GIMP_DATA (brush)); g_signal_handlers_unblock_by_func (brush, gimp_brush_editor_notify_brush, editor); } }
static void palette_editor_color_name_changed (GtkWidget *widget, GimpPaletteEditor *editor) { if (GIMP_DATA_EDITOR (editor)->data) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); const gchar *name; name = gtk_entry_get_text (GTK_ENTRY (editor->color_name)); gimp_palette_set_entry_name (palette, editor->color->position, name); } }
static void palette_editor_entry_selected (GimpPaletteView *view, GimpPaletteEntry *entry, GimpPaletteEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); if (editor->color != entry) { editor->color = entry; g_signal_handlers_block_by_func (editor->color_name, palette_editor_color_name_changed, editor); gtk_entry_set_text (GTK_ENTRY (editor->color_name), entry ? entry->name : _("Undefined")); g_signal_handlers_unblock_by_func (editor->color_name, palette_editor_color_name_changed, editor); gtk_editable_set_editable (GTK_EDITABLE (editor->color_name), entry && data_editor->data_editable); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_editor_get_popup_data (GIMP_EDITOR (editor))); } }
static void palette_editor_edit_color_update (GimpColorDialog *dialog, const GimpRGB *color, GimpColorDialogState state, GimpPaletteEditor *editor) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); switch (state) { case GIMP_COLOR_DIALOG_UPDATE: break; case GIMP_COLOR_DIALOG_OK: if (editor->color) { editor->color->color = *color; gimp_data_dirty (GIMP_DATA (palette)); } /* Fallthrough */ case GIMP_COLOR_DIALOG_CANCEL: gtk_widget_hide (editor->color_dialog); break; } }
static void gimp_data_editor_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpDataEditor *editor = GIMP_DATA_EDITOR (object); switch (property_id) { case PROP_DATA_FACTORY: editor->data_factory = g_value_get_object (value); break; case PROP_CONTEXT: gimp_docked_set_context (GIMP_DOCKED (object), g_value_get_object (value)); break; case PROP_DATA: gimp_data_editor_set_data (editor, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static GList * gimp_data_editor_get_aux_info (GimpDocked *docked) { GimpDataEditor *editor = GIMP_DATA_EDITOR (docked); GList *aux_info; GimpSessionInfoAux *aux; aux_info = parent_docked_iface->get_aux_info (docked); aux = gimp_session_info_aux_new (AUX_INFO_EDIT_ACTIVE, editor->edit_active ? "true" : "false"); aux_info = g_list_append (aux_info, aux); if (editor->data) { const gchar *value; value = gimp_object_get_name (editor->data); aux = gimp_session_info_aux_new (AUX_INFO_CURRENT_DATA, value); aux_info = g_list_append (aux_info, aux); } return aux_info; }
gboolean gimp_palette_editor_set_index (GimpPaletteEditor *editor, gint index, GimpRGB *color) { GimpPalette *palette; g_return_val_if_fail (GIMP_IS_PALETTE_EDITOR (editor), FALSE); palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); if (palette && gimp_palette_get_n_colors (palette) > 0) { GimpPaletteEntry *entry; index = CLAMP (index, 0, gimp_palette_get_n_colors (palette) - 1); entry = gimp_palette_get_entry (palette, index); gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); if (color) *color = editor->color->color; return TRUE; } return FALSE; }
void dynamics_editor_actions_update (GimpActionGroup *group, gpointer user_data) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data); GimpData *data; gboolean editable = FALSE; gboolean edit_active = FALSE; data = data_editor->data; if (data) { if (data_editor->data_editable) editable = TRUE; } edit_active = gimp_data_editor_get_edit_active (data_editor); #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) #define SET_ACTIVE(action,condition) \ gimp_action_group_set_action_active (group, action, (condition) != 0) SET_ACTIVE ("dynamics-editor-edit-active", edit_active); #undef SET_SENSITIVE #undef SET_ACTIVE }
static void gimp_data_editor_constructed (GObject *object) { GimpDataEditor *editor = GIMP_DATA_EDITOR (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_DATA_FACTORY (editor->data_factory)); g_assert (GIMP_IS_CONTEXT (editor->context)); gimp_data_editor_set_edit_active (editor, TRUE); editor->save_button = gimp_editor_add_button (GIMP_EDITOR (editor), "document-save", _("Save"), NULL, G_CALLBACK (gimp_data_editor_save_clicked), NULL, editor); editor->revert_button = gimp_editor_add_button (GIMP_EDITOR (editor), "document-revert", _("Revert"), NULL, G_CALLBACK (gimp_data_editor_revert_clicked), NULL, editor); /* Hide because revert buttons are not yet implemented */ gtk_widget_hide (editor->revert_button); }
void gradient_editor_load_right_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); GimpGradient *gradient; GimpGradientSegment *seg; GimpRGB color; GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED; gradient = GIMP_GRADIENT (data_editor->data); switch (value) { case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT: if (editor->control_sel_r->next != NULL) seg = editor->control_sel_r->next; else seg = gimp_gradient_segment_get_first (editor->control_sel_r); color = seg->left_color; color_type = seg->left_color_type; break; case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT: color = editor->control_sel_l->left_color; color_type = editor->control_sel_l->left_color_type; break; case GRADIENT_EDITOR_COLOR_FOREGROUND: gimp_context_get_foreground (data_editor->context, &color); break; case GRADIENT_EDITOR_COLOR_BACKGROUND: gimp_context_get_background (data_editor->context, &color); break; default: /* Load a color */ color = editor->saved_colors[value - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM]; break; } gimp_data_freeze (GIMP_DATA (gradient)); gimp_gradient_segment_range_blend (gradient, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l->left_color, &color, TRUE, TRUE); gimp_gradient_segment_set_right_color_type (gradient, editor->control_sel_l, color_type); gimp_data_thaw (GIMP_DATA (gradient)); }
static void palette_editor_drop_palette (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { gimp_data_editor_set_data (GIMP_DATA_EDITOR (data), GIMP_DATA (viewable)); }
static void palette_editor_drop_color (GtkWidget *widget, gint x, gint y, const GimpRGB *color, gpointer data) { GimpPaletteEditor *editor = data; if (GIMP_DATA_EDITOR (editor)->data_editable) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); GimpPaletteEntry *entry; entry = gimp_palette_add_entry (palette, -1, NULL, color); gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); } }
static void palette_editor_color_dropped (GimpPaletteView *view, GimpPaletteEntry *entry, const GimpRGB *color, GimpPaletteEditor *editor) { if (GIMP_DATA_EDITOR (editor)->data_editable) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); gint pos = -1; if (entry) pos = entry->position; entry = gimp_palette_add_entry (palette, pos, NULL, color); gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); } }
void palette_editor_actions_update (GimpActionGroup *group, gpointer user_data) { GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (user_data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data); GimpData *data; gboolean editable = FALSE; GimpRGB fg; GimpRGB bg; gboolean edit_active = FALSE; data = data_editor->data; if (data) { if (data_editor->data_editable) editable = TRUE; } if (data_editor->context) { gimp_context_get_foreground (data_editor->context, &fg); gimp_context_get_background (data_editor->context, &bg); } edit_active = gimp_data_editor_get_edit_active (data_editor); #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) #define SET_ACTIVE(action,condition) \ gimp_action_group_set_action_active (group, action, (condition) != 0) #define SET_COLOR(action,color) \ gimp_action_group_set_action_color (group, action, color, FALSE); SET_SENSITIVE ("palette-editor-edit-color", editable && editor->color); SET_SENSITIVE ("palette-editor-delete-color", editable && editor->color); SET_SENSITIVE ("palette-editor-new-color-fg", editable); SET_SENSITIVE ("palette-editor-new-color-bg", editable); SET_COLOR ("palette-editor-new-color-fg", data_editor->context ? &fg : NULL); SET_COLOR ("palette-editor-new-color-bg", data_editor->context ? &bg : NULL); SET_SENSITIVE ("palette-editor-zoom-out", data); SET_SENSITIVE ("palette-editor-zoom-in", data); SET_SENSITIVE ("palette-editor-zoom-all", data); SET_ACTIVE ("palette-editor-edit-active", edit_active); #undef SET_SENSITIVE #undef SET_ACTIVE #undef SET_COLOR }
static gchar * gimp_data_editor_get_title (GimpDocked *docked) { GimpDataEditor *editor = GIMP_DATA_EDITOR (docked); GimpDataEditorClass *editor_class = GIMP_DATA_EDITOR_GET_CLASS (editor); if (editor->data_editable) return g_strdup (editor_class->title); else return g_strdup_printf (_("%s (read only)"), editor_class->title); }
static void gimp_brush_editor_set_context (GimpDocked *docked, GimpContext *context) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (docked); parent_docked_iface->set_context (docked, context); gimp_view_renderer_set_context (GIMP_VIEW (data_editor->view)->renderer, context); }
static void gimp_data_editor_constructed (GObject *object) { GimpDataEditor *editor = GIMP_DATA_EDITOR (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_DATA_FACTORY (editor->data_factory)); g_assert (GIMP_IS_CONTEXT (editor->context)); gimp_data_editor_set_edit_active (editor, TRUE); }
static void palette_editor_entry_activated (GimpPaletteView *view, GimpPaletteEntry *entry, GimpPaletteEditor *editor) { if (GIMP_DATA_EDITOR (editor)->data_editable && entry == editor->color) { gimp_ui_manager_activate_action (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), "palette-editor", "palette-editor-edit-color"); } }
void gradient_editor_redistribute_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gimp_gradient_segment_range_redistribute_handles (gradient, editor->control_sel_l, editor->control_sel_r); }
void gradient_editor_save_right_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gimp_gradient_segment_get_right_color (gradient, editor->control_sel_r, &editor->saved_colors[value]); }
static void gimp_brush_editor_update_shape (GtkWidget *widget, GimpBrushEditor *editor) { GimpBrushGenerated *brush; if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data)) return; brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { GimpBrushGeneratedShape shape; shape = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gimp-item-data")); if (gimp_brush_generated_get_shape (brush) != shape) gimp_brush_generated_set_shape (brush, shape); } }
void gradient_editor_left_color_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); editor->left_saved_dirty = gimp_data_is_dirty (GIMP_DATA (gradient)); editor->left_saved_segments = gradient_editor_save_selection (editor); editor->color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (gradient), GIMP_DATA_EDITOR (editor)->context, _("Left Endpoint Color"), GIMP_STOCK_GRADIENT, _("Gradient Segment's Left Endpoint Color"), GTK_WIDGET (editor), gimp_dialog_factory_get_singleton (), "gimp-gradient-editor-color-dialog", &editor->control_sel_l->left_color, TRUE, TRUE); g_signal_connect (editor->color_dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &editor->color_dialog); g_signal_connect (editor->color_dialog, "update", G_CALLBACK (gradient_editor_left_color_update), editor); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); gtk_window_present (GTK_WINDOW (editor->color_dialog)); }
void gradient_editor_right_color_type_cmd_callback (GtkAction *action, GtkAction *current, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gint value; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); if (gradient && value >= 0) { GimpGradientColor color_type = value; GimpRGB color; gimp_gradient_get_color_at (gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_r, editor->control_sel_r->right, FALSE, &color); gimp_data_freeze (GIMP_DATA (gradient)); gimp_gradient_segment_set_right_color_type (gradient, editor->control_sel_r, color_type); if (color_type == GIMP_GRADIENT_COLOR_FIXED) gimp_gradient_segment_set_right_color (gradient, editor->control_sel_r, &color); gimp_data_thaw (GIMP_DATA (gradient)); } }
void palette_editor_delete_color_cmd_callback (GtkAction *action, gpointer data) { GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); if (data_editor->data_editable && editor->color) { GimpPalette *palette = GIMP_PALETTE (data_editor->data); gimp_palette_delete_entry (palette, editor->color); } }
void gradient_editor_split_midpoint_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); GimpGradient *gradient = GIMP_GRADIENT (data_editor->data); gimp_gradient_segment_range_split_midpoint (gradient, data_editor->context, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l, &editor->control_sel_r); }
void gimp_palette_editor_pick_color (GimpPaletteEditor *editor, const GimpRGB *color, GimpColorPickState pick_state) { g_return_if_fail (GIMP_IS_PALETTE_EDITOR (editor)); g_return_if_fail (color != NULL); if (GIMP_DATA_EDITOR (editor)->data_editable) { GimpPaletteEntry *entry; GimpData *data; gint index = -1; data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (editor)); switch (pick_state) { case GIMP_COLOR_PICK_STATE_NEW: if (editor->color) index = editor->color->position + 1; entry = gimp_palette_add_entry (GIMP_PALETTE (data), index, NULL, color); gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); break; case GIMP_COLOR_PICK_STATE_UPDATE: gimp_palette_set_entry_color (GIMP_PALETTE (data), editor->color->position, color); break; } } }
static void palette_editor_entry_clicked (GimpPaletteView *view, GimpPaletteEntry *entry, GdkModifierType state, GimpPaletteEditor *editor) { if (entry) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); if (state & gimp_get_toggle_behavior_mask ()) gimp_context_set_background (data_editor->context, &entry->color); else gimp_context_set_foreground (data_editor->context, &entry->color); } }
void gradient_editor_blend_opacity_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gimp_gradient_segment_range_blend (gradient, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l->left_color, &editor->control_sel_r->right_color, FALSE, TRUE); }
static void gimp_data_editor_style_set (GtkWidget *widget, GtkStyle *prev_style) { GimpDataEditor *editor = GIMP_DATA_EDITOR (widget); gint minimal_height; GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); gtk_widget_style_get (widget, "minimal-height", &minimal_height, NULL); if (editor->view) gtk_widget_set_size_request (editor->view, -1, minimal_height); }