static void gimp_selection_editor_set_image (GimpImageEditor *image_editor, GimpImage *image) { GimpSelectionEditor *editor = GIMP_SELECTION_EDITOR (image_editor); if (image_editor->image) { g_signal_handlers_disconnect_by_func (image_editor->image, gimp_selection_editor_mask_changed, editor); } GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, image); if (image) { g_signal_connect (image, "mask-changed", G_CALLBACK (gimp_selection_editor_mask_changed), editor); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (gimp_image_get_mask (image))); } else { gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL); } }
static void gimp_navigation_editor_set_shell (GimpNavigationEditor *editor, GimpDisplayShell *shell) { g_return_if_fail (GIMP_IS_NAVIGATION_EDITOR (editor)); g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell)); if (shell == editor->shell) return; if (editor->shell) { g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_scaled, editor); g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_scrolled, editor); g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_reconnect, editor); } else if (shell) { gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE); } editor->shell = shell; if (editor->shell) { GimpImage *image = gimp_display_get_image (shell->display); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (image)); g_signal_connect (editor->shell, "scaled", G_CALLBACK (gimp_navigation_editor_shell_scaled), editor); g_signal_connect (editor->shell, "scrolled", G_CALLBACK (gimp_navigation_editor_shell_scrolled), editor); g_signal_connect (editor->shell, "reconnect", G_CALLBACK (gimp_navigation_editor_shell_reconnect), editor); gimp_navigation_editor_shell_scaled (editor->shell, editor); } else { gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); } if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor))) gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_editor_get_popup_data (GIMP_EDITOR (editor))); }
GtkWidget * gimp_view_new_full (GimpContext *context, GimpViewable *viewable, gint width, gint height, gint border_width, gboolean is_popup, gboolean clickable, gboolean show_popup) { GtkWidget *view; g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, G_TYPE_FROM_INSTANCE (viewable), width, height, border_width, is_popup, clickable, show_popup); if (view) gimp_view_set_viewable (GIMP_VIEW (view), viewable); gimp_view_renderer_remove_idle (GIMP_VIEW (view)->renderer); return view; }
static void gimp_color_selector_palette_palette_changed (GimpContext *context, GimpPalette *palette, GimpColorSelectorPalette *select) { gimp_view_set_viewable (GIMP_VIEW (select->view), GIMP_VIEWABLE (palette)); }
static void gimp_brush_editor_set_data (GimpDataEditor *editor, GimpData *data) { GimpBrushEditor *brush_editor = GIMP_BRUSH_EDITOR (editor); GimpBrushGeneratedShape shape = GIMP_BRUSH_GENERATED_CIRCLE; gdouble radius = 0.0; gint spikes = 2; gdouble hardness = 0.0; gdouble ratio = 0.0; gdouble angle = 0.0; gdouble spacing = 0.0; if (editor->data) g_signal_handlers_disconnect_by_func (editor->data, gimp_brush_editor_notify_brush, editor); GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data); if (editor->data) g_signal_connect (editor->data, "notify", G_CALLBACK (gimp_brush_editor_notify_brush), editor); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (data)); if (editor->data) { spacing = gimp_brush_get_spacing (GIMP_BRUSH (editor->data)); if (GIMP_IS_BRUSH_GENERATED (editor->data)) { GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (editor->data); shape = gimp_brush_generated_get_shape (brush); 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); } } gtk_widget_set_sensitive (brush_editor->options_box, editor->data_editable); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (brush_editor->shape_group), shape); gtk_adjustment_set_value (brush_editor->radius_data, radius); gtk_adjustment_set_value (brush_editor->spikes_data, spikes); gtk_adjustment_set_value (brush_editor->hardness_data, hardness); gtk_adjustment_set_value (brush_editor->aspect_ratio_data, ratio); gtk_adjustment_set_value (brush_editor->angle_data, angle); gtk_adjustment_set_value (brush_editor->spacing_data, spacing); }
GtkWidget * gimp_toolbox_image_area_create (GimpToolbox *toolbox, gint width, gint height) { GimpContext *context; GtkWidget *image_view; gchar *tooltip; g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL); context = gimp_toolbox_get_context (toolbox); image_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_IMAGE, width, height, 0, FALSE, TRUE, TRUE); g_signal_connect (image_view, "set-viewable", G_CALLBACK (image_preview_set_viewable), NULL); gimp_view_set_viewable (GIMP_VIEW (image_view), GIMP_VIEWABLE (gimp_context_get_image (context))); gtk_widget_show (image_view); #ifdef GDK_WINDOWING_X11 tooltip = g_strdup_printf ("%s\n%s", _("The active image.\n" "Click to open the Image Dialog."), _("Drag to an XDS enabled file-manager to " "save the image.")); #else tooltip = g_strdup (_("The active image.\n" "Click to open the Image Dialog.")); #endif gimp_help_set_help_data (image_view, tooltip, GIMP_HELP_TOOLBOX_IMAGE_AREA); g_free (tooltip); g_signal_connect_object (context, "image-changed", G_CALLBACK (gimp_view_set_viewable), image_view, G_CONNECT_SWAPPED); g_signal_connect (image_view, "clicked", G_CALLBACK (image_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (image_view, GIMP_TYPE_IMAGE, image_preview_drop_image, context); return image_view; }
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell, GimpNavigationEditor *editor) { GimpImage *image = gimp_display_get_image (shell->display); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (image)); if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor))) gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_editor_get_popup_data (GIMP_EDITOR (editor))); }
static void gimp_palette_editor_set_data (GimpDataEditor *editor, GimpData *data) { GimpPaletteEditor *palette_editor = GIMP_PALETTE_EDITOR (editor); g_signal_handlers_block_by_func (palette_editor->columns_adj, palette_editor_columns_changed, editor); if (editor->data) { if (palette_editor->color_dialog) { gtk_widget_destroy (palette_editor->color_dialog); palette_editor->color_dialog = NULL; } g_signal_handlers_disconnect_by_func (editor->data, palette_editor_invalidate_preview, editor); gtk_adjustment_set_value (palette_editor->columns_adj, 0); } GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data); gimp_view_set_viewable (GIMP_VIEW (palette_editor->view), GIMP_VIEWABLE (data)); if (editor->data) { GimpPalette *palette = GIMP_PALETTE (editor->data); g_signal_connect (editor->data, "invalidate-preview", G_CALLBACK (palette_editor_invalidate_preview), editor); gtk_adjustment_set_value (palette_editor->columns_adj, gimp_palette_get_columns (palette)); palette_editor_scroll_top_left (palette_editor); palette_editor_invalidate_preview (GIMP_PALETTE (editor->data), palette_editor); } g_signal_handlers_unblock_by_func (palette_editor->columns_adj, palette_editor_columns_changed, editor); }
static void layer_select_advance (LayerSelect *layer_select, gint move) { GimpLayer *active_layer; GimpLayer *next_layer; GList *layers; gint n_layers; gint index; if (move == 0) return; /* If there is a floating selection, allow no advancement */ if (gimp_image_get_floating_selection (layer_select->image)) return; active_layer = gimp_image_get_active_layer (layer_select->image); layers = gimp_image_get_layer_list (layer_select->image); n_layers = g_list_length (layers); index = g_list_index (layers, active_layer); index += move; if (index < 0) index = n_layers - 1; else if (index >= n_layers) index = 0; next_layer = g_list_nth_data (layers, index); g_list_free (layers); if (next_layer && next_layer != active_layer) { active_layer = gimp_image_set_active_layer (layer_select->image, next_layer); if (active_layer) { gimp_view_set_viewable (GIMP_VIEW (layer_select->view), GIMP_VIEWABLE (active_layer)); gtk_label_set_text (GTK_LABEL (layer_select->label), gimp_object_get_name (active_layer)); } } }
static void gimp_view_dispose (GObject *object) { GimpView *view = GIMP_VIEW (object); if (view->viewable) gimp_view_set_viewable (view, NULL); if (view->renderer) { g_object_unref (view->renderer); view->renderer = NULL; } G_OBJECT_CLASS (parent_class)->dispose (object); }
static void gimp_buffer_view_buffer_changed (Gimp *gimp, GimpBufferView *buffer_view) { gimp_view_set_viewable (GIMP_VIEW (buffer_view->global_view), (GimpViewable *) gimp->global_buffer); if (gimp->global_buffer) { gchar *desc; desc = gimp_viewable_get_description (GIMP_VIEWABLE (gimp->global_buffer), NULL); gtk_label_set_text (GTK_LABEL (buffer_view->global_label), desc); g_free (desc); } else { gtk_label_set_text (GTK_LABEL (buffer_view->global_label), _("(None)")); } }
static LayerSelect * layer_select_new (GimpImage *image, GimpLayer *layer, gint view_size) { LayerSelect *layer_select; GtkWidget *frame1; GtkWidget *frame2; GtkWidget *hbox; GtkWidget *alignment; layer_select = g_slice_new0 (LayerSelect); layer_select->image = image; layer_select->orig_layer = layer; layer_select->window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_role (GTK_WINDOW (layer_select->window), "gimp-layer-select"); gtk_window_set_title (GTK_WINDOW (layer_select->window), _("Layer Select")); gtk_window_set_position (GTK_WINDOW (layer_select->window), GTK_WIN_POS_MOUSE); gtk_widget_set_events (layer_select->window, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_PRESS_MASK); g_signal_connect (layer_select->window, "event", G_CALLBACK (layer_select_events), layer_select); frame1 = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (layer_select->window), frame1); gtk_widget_show (frame1); frame2 = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (frame1), frame2); gtk_widget_show (frame2); hbox = gtk_hbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_container_add (GTK_CONTAINER (frame2), hbox); gtk_widget_show (hbox); /* The view */ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); gtk_widget_show (alignment); layer_select->view = gimp_view_new_by_types (gimp_get_user_context (image->gimp), GIMP_TYPE_VIEW, GIMP_TYPE_LAYER, view_size, 1, FALSE); gimp_view_set_viewable (GIMP_VIEW (layer_select->view), GIMP_VIEWABLE (layer)); gtk_container_add (GTK_CONTAINER (alignment), layer_select->view); gtk_widget_show (layer_select->view); gtk_widget_show (alignment); /* the layer name label */ layer_select->label = gtk_label_new (gimp_object_get_name (layer)); gtk_box_pack_start (GTK_BOX (hbox), layer_select->label, FALSE, FALSE, 0); gtk_widget_show (layer_select->label); return layer_select; }
static void palette_import_make_palette (ImportDialog *dialog) { GimpPalette *palette = NULL; const gchar *palette_name; gint n_colors; gint n_columns; gint threshold; palette_name = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); if (! palette_name || ! strlen (palette_name)) palette_name = _("Untitled"); n_colors = ROUND (gtk_adjustment_get_value (dialog->num_colors)); n_columns = ROUND (gtk_adjustment_get_value (dialog->columns)); threshold = ROUND (gtk_adjustment_get_value (dialog->threshold)); switch (dialog->import_type) { case GRADIENT_IMPORT: { GimpGradient *gradient; gradient = gimp_context_get_gradient (dialog->context); palette = gimp_palette_import_from_gradient (gradient, dialog->context, FALSE, palette_name, n_colors); } break; case IMAGE_IMPORT: { GimpImage *image = gimp_context_get_image (dialog->context); gboolean sample_merged; gboolean selection_only; sample_merged = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle)); selection_only = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->selection_only_toggle)); if (gimp_image_get_base_type (image) == GIMP_INDEXED) { palette = gimp_palette_import_from_indexed_image (image, dialog->context, palette_name); } else if (sample_merged) { palette = gimp_palette_import_from_image (image, dialog->context, palette_name, n_colors, threshold, selection_only); } else { GimpDrawable *drawable; drawable = GIMP_DRAWABLE (gimp_image_get_active_layer (image)); palette = gimp_palette_import_from_drawable (drawable, dialog->context, palette_name, n_colors, threshold, selection_only); } } break; case FILE_IMPORT: { GFile *file; GError *error = NULL; file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog->file_chooser)); palette = gimp_palette_import_from_file (dialog->context, file, palette_name, &error); g_object_unref (file); if (! palette) { gimp_message_literal (dialog->context->gimp, G_OBJECT (dialog->dialog), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } } break; } if (palette) { if (dialog->palette) g_object_unref (dialog->palette); gimp_palette_set_columns (palette, n_columns); gimp_view_set_viewable (GIMP_VIEW (dialog->preview), GIMP_VIEWABLE (palette)); dialog->palette = palette; } gtk_widget_set_visible (dialog->no_colors_label, dialog->palette && gimp_palette_get_n_colors (dialog->palette) > 0); }
static void gimp_action_set_proxy (GimpAction *action, GtkWidget *proxy) { if (! GTK_IS_IMAGE_MENU_ITEM (proxy)) return; if (action->color) { GtkWidget *area; area = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy)); if (GIMP_IS_COLOR_AREA (area)) { gimp_color_area_set_color (GIMP_COLOR_AREA (area), action->color); } else { gint width, height; area = gimp_color_area_new (action->color, GIMP_COLOR_AREA_SMALL_CHECKS, 0); gimp_color_area_set_draw_border (GIMP_COLOR_AREA (area), TRUE); gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (proxy), GTK_ICON_SIZE_MENU, &width, &height); gtk_widget_set_size_request (area, width, height); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), area); gtk_widget_show (area); } } else if (action->viewable) { GtkWidget *view; view = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy)); if (GIMP_IS_VIEW (view) && g_type_is_a (G_TYPE_FROM_INSTANCE (action->viewable), GIMP_VIEW (view)->renderer->viewable_type)) { gimp_view_set_viewable (GIMP_VIEW (view), action->viewable); } else { GtkIconSize size; gint width, height; gint border_width; if (GIMP_IS_IMAGEFILE (action->viewable)) { size = GTK_ICON_SIZE_LARGE_TOOLBAR; border_width = 0; } else { size = GTK_ICON_SIZE_MENU; border_width = 1; } gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (proxy), size, &width, &height); view = gimp_view_new_full (action->context, action->viewable, width, height, border_width, FALSE, FALSE, FALSE); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), view); gtk_widget_show (view); } } else { GtkWidget *image; image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy)); if (GIMP_IS_VIEW (image) || GIMP_IS_COLOR_AREA (image)) { gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL); g_object_notify (G_OBJECT (action), "stock-id"); } } { GtkWidget *child = gtk_bin_get_child (GTK_BIN (proxy)); if (GTK_IS_LABEL (child)) { GtkLabel *label = GTK_LABEL (child); gtk_label_set_ellipsize (label, action->ellipsize); gtk_label_set_max_width_chars (label, action->max_width_chars); } } }
GtkWidget * gimp_toolbox_indicator_area_create (GimpToolbox *toolbox) { GimpContext *context; GtkWidget *indicator_table; GtkWidget *brush_view; GtkWidget *pattern_view; GtkWidget *gradient_view; g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL); context = GIMP_DOCK (toolbox)->context; indicator_table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_SPACING); gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_SPACING); /* brush view */ brush_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH, CELL_SIZE, CELL_SIZE, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (brush_view), GIMP_VIEWABLE (gimp_context_get_brush (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_view, 0, 1, 0, 1); gtk_widget_show (brush_view); gimp_help_set_help_data (brush_view, _("The active brush.\n" "Click to open the Brush Dialog."), NULL); g_signal_connect_object (context, "brush-changed", G_CALLBACK (gimp_view_set_viewable), brush_view, G_CONNECT_SWAPPED); g_signal_connect (brush_view, "clicked", G_CALLBACK (brush_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (brush_view, GIMP_TYPE_BRUSH, brush_preview_drop_brush, context); /* pattern view */ pattern_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_PATTERN, CELL_SIZE, CELL_SIZE, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (pattern_view), GIMP_VIEWABLE (gimp_context_get_pattern (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_view, 1, 2, 0, 1); gtk_widget_show (pattern_view); gimp_help_set_help_data (pattern_view, _("The active pattern.\n" "Click to open the Pattern Dialog."), NULL); g_signal_connect_object (context, "pattern-changed", G_CALLBACK (gimp_view_set_viewable), pattern_view, G_CONNECT_SWAPPED); g_signal_connect (pattern_view, "clicked", G_CALLBACK (pattern_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (pattern_view, GIMP_TYPE_PATTERN, pattern_preview_drop_pattern, context); /* gradient view */ gradient_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_GRADIENT, GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (gradient_view), GIMP_VIEWABLE (gimp_context_get_gradient (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_view, 0, 2, 1, 2); gtk_widget_show (gradient_view); gimp_help_set_help_data (gradient_view, _("The active gradient.\n" "Click to open the Gradient Dialog."), NULL); g_signal_connect_object (context, "gradient-changed", G_CALLBACK (gimp_view_set_viewable), gradient_view, G_CONNECT_SWAPPED); g_signal_connect (gradient_view, "clicked", G_CALLBACK (gradient_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (gradient_view, GIMP_TYPE_GRADIENT, gradient_preview_drop_gradient, context); gtk_widget_show (indicator_table); return indicator_table; }