void gimp_container_popup_set_view_size (GimpContainerPopup *popup, gint view_size) { GtkWidget *scrolled_win; GtkWidget *viewport; GtkAllocation allocation; g_return_if_fail (GIMP_IS_CONTAINER_POPUP (popup)); scrolled_win = GIMP_CONTAINER_BOX (popup->editor->view)->scrolled_win; viewport = gtk_bin_get_child (GTK_BIN (scrolled_win)); gtk_widget_get_allocation (viewport, &allocation); view_size = CLAMP (view_size, GIMP_VIEW_SIZE_TINY, MIN (GIMP_VIEW_SIZE_GIGANTIC, allocation.width - 2 * popup->view_border_width)); if (view_size != popup->view_size) { popup->view_size = view_size; gimp_container_view_set_view_size (popup->editor->view, popup->view_size, popup->view_border_width); } }
static void gimp_container_grid_view_init (GimpContainerGridView *grid_view) { GimpContainerBox *box = GIMP_CONTAINER_BOX (grid_view); GtkWidget *viewport; grid_view->rows = 1; grid_view->columns = 1; grid_view->visible_rows = 0; grid_view->selected_item = NULL; gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box->scrolled_win), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box->scrolled_win), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gimp_editor_set_show_name (GIMP_EDITOR (grid_view), TRUE); grid_view->wrap_box = gtk_hwrap_box_new (FALSE); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (box->scrolled_win), grid_view->wrap_box); viewport = gtk_widget_get_parent (grid_view->wrap_box); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); gtk_widget_show (grid_view->wrap_box); g_signal_connect (viewport, "size-allocate", G_CALLBACK (gimp_container_grid_view_viewport_resized), grid_view); g_signal_connect (viewport, "button-press-event", G_CALLBACK (gimp_container_grid_view_button_press), grid_view); gtk_widget_set_can_focus (GTK_WIDGET (grid_view), TRUE); }
static void gimp_pattern_select_constructed (GObject *object) { GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object); GtkWidget *content_area; if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); dialog->view = gimp_pattern_factory_view_new (GIMP_VIEW_TYPE_GRID, dialog->context->gimp->pattern_factory, dialog->context, GIMP_VIEW_SIZE_MEDIUM, 1, dialog->menu_factory); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view), 6 * (GIMP_VIEW_SIZE_MEDIUM + 2), 6 * (GIMP_VIEW_SIZE_MEDIUM + 2)); gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_box_pack_start (GTK_BOX (content_area), dialog->view, TRUE, TRUE, 0); gtk_widget_show (dialog->view); }
static GObject * gimp_font_select_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpPdbDialog *dialog; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); dialog = GIMP_PDB_DIALOG (object); dialog->view = gimp_font_view_new (GIMP_VIEW_TYPE_LIST, dialog->context->gimp->fonts, dialog->context, GIMP_VIEW_SIZE_MEDIUM, 1, dialog->menu_factory); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view), 6 * (GIMP_VIEW_SIZE_MEDIUM + 2), 6 * (GIMP_VIEW_SIZE_MEDIUM + 2)); gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view); gtk_widget_show (dialog->view); return object; }
static void gimp_container_popup_create_view (GimpContainerPopup *popup) { GimpEditor *editor; GtkWidget *button; popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL); gimp_container_editor_construct (popup->editor, popup->view_type, popup->container, popup->context, popup->view_size, popup->view_border_width, NULL, NULL, NULL); gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view), FALSE); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view), 6 * (popup->default_view_size + 2 * popup->view_border_width), 10 * (popup->default_view_size + 2 * popup->view_border_width)); if (GIMP_IS_EDITOR (popup->editor->view)) gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE); gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor)); gtk_widget_show (GTK_WIDGET (popup->editor)); editor = GIMP_EDITOR (popup->editor->view); gimp_editor_add_button (editor, GTK_STOCK_ZOOM_OUT, _("Smaller Previews"), NULL, G_CALLBACK (gimp_container_popup_smaller_clicked), NULL, popup); gimp_editor_add_button (editor, GTK_STOCK_ZOOM_IN, _("Larger Previews"), NULL, G_CALLBACK (gimp_container_popup_larger_clicked), NULL, popup); button = gimp_editor_add_stock_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp", G_CALLBACK (gimp_container_popup_view_type_toggled), popup); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type); if (popup->dialog_factory) gimp_editor_add_button (editor, popup->dialog_stock_id, popup->dialog_tooltip, NULL, G_CALLBACK (gimp_container_popup_dialog_clicked), NULL, popup); gtk_widget_grab_focus (GTK_WIDGET (popup->editor)); }
static GtkWidget * gimp_container_box_get_preview (GimpDocked *docked, GimpContext *context, GtkIconSize size) { GimpContainerBox *box = GIMP_CONTAINER_BOX (docked); GimpContainerView *view = GIMP_CONTAINER_VIEW (docked); GimpContainer *container; GtkWidget *preview; gint width; gint height; gint border_width = 1; const gchar *prop_name; container = gimp_container_view_get_container (view); g_return_val_if_fail (container != NULL, NULL); gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (box)), size, &width, &height); prop_name = gimp_context_type_to_prop_name (container->children_type); preview = gimp_prop_view_new (G_OBJECT (context), prop_name, context, height); GIMP_VIEW (preview)->renderer->size = -1; gimp_container_view_get_view_size (view, &border_width); border_width = MIN (1, border_width); gimp_view_renderer_set_size_full (GIMP_VIEW (preview)->renderer, width, height, border_width); return preview; }
static GtkWidget * quit_close_all_dialog_new (Gimp *gimp, gboolean do_quit) { GimpContainer *images; GimpContext *context; GimpMessageBox *box; GtkWidget *dialog; GtkWidget *label; GtkWidget *button; GtkWidget *view; GtkWidget *dnd_widget; gint rows; gint view_size; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); #ifdef __GNUC__ #warning FIXME: need container of dirty images #endif images = gimp_displays_get_dirty_images (gimp); context = gimp_context_new (gimp, "close-all-dialog", gimp_get_user_context (gimp)); g_return_val_if_fail (images != NULL, NULL); dialog = gimp_message_dialog_new (do_quit ? _("Quit GIMP") : _("Close All Images"), GIMP_STOCK_WARNING, NULL, 0, gimp_standard_help_func, do_quit ? GIMP_HELP_FILE_QUIT : GIMP_HELP_FILE_CLOSE_ALL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); g_object_set_data_full (G_OBJECT (dialog), "dirty-images", images, (GDestroyNotify) g_object_unref); g_object_set_data_full (G_OBJECT (dialog), "dirty-images-context", context, (GDestroyNotify) g_object_unref); g_signal_connect (dialog, "response", G_CALLBACK (quit_close_all_dialog_response), gimp); box = GIMP_MESSAGE_DIALOG (dialog)->box; button = gtk_dialog_add_button (GTK_DIALOG (dialog), "", GTK_RESPONSE_OK); g_object_set_data (G_OBJECT (box), "ok-button", button); g_object_set_data (G_OBJECT (box), "do-quit", GINT_TO_POINTER (do_quit)); g_signal_connect_object (images, "add", G_CALLBACK (quit_close_all_dialog_container_changed), box, 0); g_signal_connect_object (images, "remove", G_CALLBACK (quit_close_all_dialog_container_changed), box, 0); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); view_size = gimp->config->layer_preview_size; rows = CLAMP (gimp_container_num_children (images), 3, 6); view = gimp_container_tree_view_new (images, context, view_size, 1); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (view), -1, rows * (view_size + 2)); gtk_box_pack_start (GTK_BOX (box), view, TRUE, TRUE, 0); gtk_widget_show (view); g_signal_connect (view, "activate-item", G_CALLBACK (quit_close_all_dialog_image_activated), gimp); dnd_widget = gimp_container_view_get_dnd_widget (GIMP_CONTAINER_VIEW (view)); gimp_dnd_xds_source_add (dnd_widget, (GimpDndDragViewableFunc) gimp_dnd_get_drag_data, NULL); if (do_quit) label = gtk_label_new (_("If you quit GIMP now, " "these changes will be lost.")); else label = gtk_label_new (_("If you close these images now, " "changes will be lost.")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_widget_show (label); g_object_set_data (G_OBJECT (box), "lost-label", label); quit_close_all_dialog_container_changed (images, NULL, GIMP_MESSAGE_DIALOG (dialog)->box); return dialog; }
static void gimp_container_grid_view_highlight_item (GimpContainerView *container_view, GimpViewable *viewable, gpointer insert_data) { GimpContainerGridView *grid_view = GIMP_CONTAINER_GRID_VIEW (container_view); GimpContainerBox *box = GIMP_CONTAINER_BOX (container_view); GimpContainer *container; GimpView *view = NULL; container = gimp_container_view_get_container (container_view); if (insert_data) view = GIMP_VIEW (insert_data); if (grid_view->selected_item && grid_view->selected_item != view) { gimp_view_renderer_set_border_type (grid_view->selected_item->renderer, GIMP_VIEW_BORDER_WHITE); gimp_view_renderer_update (grid_view->selected_item->renderer); } if (view) { GtkRequisition view_requisition; GtkAdjustment *adj; gint item_height; gint index; gint row; gchar *name; adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (box->scrolled_win)); gtk_widget_size_request (GTK_WIDGET (view), &view_requisition); item_height = view_requisition.height; index = gimp_container_get_child_index (container, GIMP_OBJECT (viewable)); row = index / grid_view->columns; if (row * item_height < gtk_adjustment_get_value (adj)) { gtk_adjustment_set_value (adj, row * item_height); } else if ((row + 1) * item_height > (gtk_adjustment_get_value (adj) + gtk_adjustment_get_page_size (adj))) { gtk_adjustment_set_value (adj, (row + 1) * item_height - gtk_adjustment_get_page_size (adj)); } gimp_view_renderer_set_border_type (view->renderer, GIMP_VIEW_BORDER_BLACK); gimp_view_renderer_update (view->renderer); name = gimp_viewable_get_description (view->renderer->viewable, NULL); gimp_editor_set_name (GIMP_EDITOR (grid_view), name); g_free (name); } else { gimp_editor_set_name (GIMP_EDITOR (grid_view), NULL); } grid_view->selected_item = view; }
static GObject * gimp_brush_select_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpPdbDialog *dialog; GimpBrushSelect *select; GtkWidget *table; GtkAdjustment *spacing_adj; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); dialog = GIMP_PDB_DIALOG (object); select = GIMP_BRUSH_SELECT (object); gimp_context_set_opacity (dialog->context, select->initial_opacity); gimp_context_set_paint_mode (dialog->context, select->initial_mode); g_signal_connect (dialog->context, "opacity-changed", G_CALLBACK (gimp_brush_select_opacity_changed), dialog); g_signal_connect (dialog->context, "paint-mode-changed", G_CALLBACK (gimp_brush_select_mode_changed), dialog); dialog->view = gimp_brush_factory_view_new (GIMP_VIEW_TYPE_GRID, dialog->context->gimp->brush_factory, dialog->context, FALSE, GIMP_VIEW_SIZE_MEDIUM, 1, dialog->menu_factory); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view), 5 * (GIMP_VIEW_SIZE_MEDIUM + 2), 5 * (GIMP_VIEW_SIZE_MEDIUM + 2)); gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view); gtk_widget_show (dialog->view); /* Create the frame and the table for the options */ table = GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_scale->parent; gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 2); /* Create the opacity scale widget */ select->opacity_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("Opacity:"), -1, 5, gimp_context_get_opacity (dialog->context) * 100.0, 0.0, 100.0, 1.0, 10.0, 1, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (select->opacity_data, "value-changed", G_CALLBACK (gimp_brush_select_opacity_update), select); /* Create the paint mode option menu */ select->paint_mode_menu = gimp_paint_mode_menu_new (TRUE, FALSE); gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, _("Mode:"), 0.0, 0.5, select->paint_mode_menu, 2, FALSE); gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (select->paint_mode_menu), gimp_context_get_paint_mode (dialog->context), G_CALLBACK (gimp_brush_select_mode_update), select); spacing_adj = GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_adjustment; /* Use passed spacing instead of brushes default */ if (select->spacing >= 0) gtk_adjustment_set_value (spacing_adj, select->spacing); g_signal_connect (spacing_adj, "value-changed", G_CALLBACK (gimp_brush_select_spacing_update), select); gtk_widget_show (table); return object; }
static void gimp_container_popup_create_view (GimpContainerPopup *popup) { GimpEditor *editor; GtkWidget *button; popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, "view-type", popup->view_type, "container", popup->container, "context", popup->context, "view-size", popup->view_size, "view-border-width", popup->view_border_width, NULL); gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view), FALSE); if (popup->view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *search_entry; search_entry = gtk_entry_new (); gtk_box_pack_end (GTK_BOX (popup->editor->view), search_entry, FALSE, FALSE, 0); gtk_tree_view_set_search_entry (GTK_TREE_VIEW (GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_VIEW (popup->editor->view))->view), GTK_ENTRY (search_entry)); gtk_widget_show (search_entry); } gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view), 6 * (popup->default_view_size + 2 * popup->view_border_width), 10 * (popup->default_view_size + 2 * popup->view_border_width)); if (GIMP_IS_EDITOR (popup->editor->view)) gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE); gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor)); gtk_widget_show (GTK_WIDGET (popup->editor)); editor = GIMP_EDITOR (popup->editor->view); gimp_editor_add_button (editor, "zoom-out", _("Smaller Previews"), NULL, G_CALLBACK (gimp_container_popup_smaller_clicked), NULL, popup); gimp_editor_add_button (editor, "zoom-in", _("Larger Previews"), NULL, G_CALLBACK (gimp_container_popup_larger_clicked), NULL, popup); button = gimp_editor_add_icon_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp", G_CALLBACK (gimp_container_popup_view_type_toggled), popup); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type); if (popup->dialog_factory) gimp_editor_add_button (editor, popup->dialog_icon_name, popup->dialog_tooltip, NULL, G_CALLBACK (gimp_container_popup_dialog_clicked), NULL, popup); gtk_widget_grab_focus (GTK_WIDGET (popup->editor)); }