static void gimp_color_selector_palette_set_config (GimpColorSelector *selector, GimpColorConfig *config) { GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (selector); if (select->context) { g_signal_handlers_disconnect_by_func (select->context, gimp_color_selector_palette_palette_changed, select); select->context = NULL; } if (config) select->context = g_object_get_data (G_OBJECT (config), "gimp-context"); if (select->context) { if (! select->view) { GtkWidget *frame; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (select), frame); gtk_widget_show (frame); select->view = gimp_view_new_full_by_types (select->context, GIMP_TYPE_PALETTE_VIEW, GIMP_TYPE_PALETTE, 100, 100, 0, FALSE, TRUE, FALSE); gimp_view_set_expand (GIMP_VIEW (select->view), TRUE); gimp_view_renderer_palette_set_cell_size (GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer), -1); gimp_view_renderer_palette_set_draw_grid (GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer), TRUE); gtk_container_add (GTK_CONTAINER (frame), select->view); gtk_widget_show (select->view); g_signal_connect (select->view, "entry-clicked", G_CALLBACK (gimp_color_selector_palette_entry_clicked), select); } g_signal_connect_object (select->context, "palette-changed", G_CALLBACK (gimp_color_selector_palette_palette_changed), select, 0); gimp_color_selector_palette_palette_changed (select->context, gimp_context_get_palette (select->context), select); } }
static void gimp_palette_editor_init (GimpPaletteEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); GtkWidget *hbox; GtkWidget *label; GtkWidget *spinbutton; editor->zoom_factor = 1.0; editor->col_width = 0; editor->last_width = 0; editor->columns = COLUMNS; data_editor->view = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request (data_editor->view, -1, PREVIEW_HEIGHT); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (data_editor->view), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (editor), data_editor->view, TRUE, TRUE, 0); gtk_widget_show (data_editor->view); editor->view = gimp_view_new_full_by_types (NULL, GIMP_TYPE_PALETTE_VIEW, GIMP_TYPE_PALETTE, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0, FALSE, TRUE, FALSE); gimp_view_renderer_palette_set_cell_size (GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (editor->view)->renderer), -1); gimp_view_renderer_palette_set_draw_grid (GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (editor->view)->renderer), TRUE); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (data_editor->view), editor->view); gtk_widget_show (editor->view); g_signal_connect (gtk_widget_get_parent (editor->view), "size-allocate", G_CALLBACK (palette_editor_viewport_size_allocate), editor); g_signal_connect (editor->view, "entry-clicked", G_CALLBACK (palette_editor_entry_clicked), editor); g_signal_connect (editor->view, "entry-selected", G_CALLBACK (palette_editor_entry_selected), editor); g_signal_connect (editor->view, "entry-activated", G_CALLBACK (palette_editor_entry_activated), editor); g_signal_connect (editor->view, "entry-context", G_CALLBACK (palette_editor_entry_context), editor); g_signal_connect (editor->view, "color-dropped", G_CALLBACK (palette_editor_color_dropped), editor); gimp_dnd_viewable_dest_add (editor->view, GIMP_TYPE_PALETTE, palette_editor_drop_palette, editor); gimp_dnd_viewable_dest_add (gtk_widget_get_parent (editor->view), GIMP_TYPE_PALETTE, palette_editor_drop_palette, editor); gimp_dnd_color_dest_add (gtk_widget_get_parent (editor->view), palette_editor_drop_color, editor); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* The color name entry */ editor->color_name = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (hbox), editor->color_name, TRUE, TRUE, 0); gtk_entry_set_text (GTK_ENTRY (editor->color_name), _("Undefined")); gtk_editable_set_editable (GTK_EDITABLE (editor->color_name), FALSE); gtk_widget_show (editor->color_name); g_signal_connect (editor->color_name, "changed", G_CALLBACK (palette_editor_color_name_changed), editor); label = gtk_label_new (_("Columns:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); editor->columns_adj = (GtkAdjustment *) gtk_adjustment_new (0, 0, 64, 1, 4, 0); spinbutton = gtk_spin_button_new (editor->columns_adj, 1.0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); g_signal_connect (editor->columns_adj, "value-changed", G_CALLBACK (palette_editor_columns_changed), editor); }