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_controller_list_init (GimpControllerList *list) { GtkWidget *hbox; GtkWidget *sw; GtkWidget *tv; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkWidget *vbox; GtkWidget *image; GtkIconSize icon_size; gint icon_width; gint icon_height; GType *controller_types; guint n_controller_types; gint i; gtk_orientable_set_orientation (GTK_ORIENTABLE (list), GTK_ORIENTATION_VERTICAL); list->gimp = NULL; list->hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (list), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0); gtk_widget_show (sw); list->src = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_GTYPE); tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list->src)); g_object_unref (list->src); gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (tv), FALSE); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Available Controllers")); gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column); cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, "icon-name", COLUMN_ICON, NULL); g_object_get (cell, "stock-size", &icon_size, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_set_attributes (column, cell, "text", COLUMN_NAME, NULL); gtk_container_add (GTK_CONTAINER (sw), tv); gtk_widget_show (tv); g_signal_connect_object (tv, "row-activated", G_CALLBACK (gimp_controller_list_row_activated), G_OBJECT (list), 0); list->src_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv)); gtk_tree_selection_set_mode (list->src_sel, GTK_SELECTION_BROWSE); g_signal_connect_object (list->src_sel, "changed", G_CALLBACK (gimp_controller_list_src_sel_changed), G_OBJECT (list), 0); controller_types = g_type_children (GIMP_TYPE_CONTROLLER, &n_controller_types); for (i = 0; i < n_controller_types; i++) { GimpControllerClass *controller_class; GtkTreeIter iter; controller_class = g_type_class_ref (controller_types[i]); gtk_list_store_append (list->src, &iter); gtk_list_store_set (list->src, &iter, COLUMN_ICON, controller_class->icon_name, COLUMN_NAME, controller_class->name, COLUMN_TYPE, controller_types[i], -1); g_type_class_unref (controller_class); } g_free (controller_types); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); list->add_button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (vbox), list->add_button, TRUE, FALSE, 0); gtk_widget_set_sensitive (list->add_button, FALSE); gtk_widget_show (list->add_button); image = gtk_image_new_from_icon_name ("go-next", GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (list->add_button), image); gtk_widget_show (image); g_signal_connect (list->add_button, "clicked", G_CALLBACK (gimp_controller_list_add_clicked), list); g_object_add_weak_pointer (G_OBJECT (list->add_button), (gpointer) &list->add_button); list->remove_button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (vbox), list->remove_button, TRUE, FALSE, 0); gtk_widget_set_sensitive (list->remove_button, FALSE); gtk_widget_show (list->remove_button); image = gtk_image_new_from_icon_name ("go-previous", GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (list->remove_button), image); gtk_widget_show (image); g_signal_connect (list->remove_button, "clicked", G_CALLBACK (gimp_controller_list_remove_clicked), list); g_object_add_weak_pointer (G_OBJECT (list->remove_button), (gpointer) &list->remove_button); gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (list)), icon_size, &icon_width, &icon_height); list->dest = gimp_container_tree_view_new (NULL, NULL, icon_height, 0); gimp_container_tree_view_set_main_column_title (GIMP_CONTAINER_TREE_VIEW (list->dest), _("Active Controllers")); gtk_tree_view_set_headers_visible (GIMP_CONTAINER_TREE_VIEW (list->dest)->view, TRUE); gtk_box_pack_start (GTK_BOX (list->hbox), list->dest, TRUE, TRUE, 0); gtk_widget_show (list->dest); g_signal_connect_object (list->dest, "select-item", G_CALLBACK (gimp_controller_list_select_item), G_OBJECT (list), 0); g_signal_connect_object (list->dest, "activate-item", G_CALLBACK (gimp_controller_list_activate_item), G_OBJECT (list), 0); list->edit_button = gimp_editor_add_button (GIMP_EDITOR (list->dest), "document-properties", _("Configure the selected controller"), NULL, G_CALLBACK (gimp_controller_list_edit_clicked), NULL, list); list->up_button = gimp_editor_add_button (GIMP_EDITOR (list->dest), "go-up", _("Move the selected controller up"), NULL, G_CALLBACK (gimp_controller_list_up_clicked), NULL, list); list->down_button = gimp_editor_add_button (GIMP_EDITOR (list->dest), "go-down", _("Move the selected controller down"), NULL, G_CALLBACK (gimp_controller_list_down_clicked), NULL, list); gtk_widget_set_sensitive (list->edit_button, FALSE); gtk_widget_set_sensitive (list->up_button, FALSE); gtk_widget_set_sensitive (list->down_button, FALSE); }
gboolean gimp_container_editor_construct (GimpContainerEditor *editor, GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory, const gchar *menu_identifier, const gchar *ui_identifier) { g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE); g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); g_return_val_if_fail (view_size > 0 && view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH, FALSE); g_return_val_if_fail (menu_factory == NULL || GIMP_IS_MENU_FACTORY (menu_factory), FALSE); switch (view_type) { case GIMP_VIEW_TYPE_GRID: #if 0 editor->view = GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (container, context, view_size, view_border_width)); #else editor->view = GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (container, context, view_size, view_border_width)); #endif break; case GIMP_VIEW_TYPE_LIST: editor->view = GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (container, context, view_size, view_border_width)); break; default: g_warning ("%s: unknown GimpViewType passed", G_STRFUNC); return FALSE; } if (GIMP_IS_LIST (container)) gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view), ! GIMP_LIST (container)->sort_func); if (menu_factory && menu_identifier && ui_identifier) gimp_editor_create_menu (GIMP_EDITOR (editor->view), menu_factory, menu_identifier, ui_identifier, editor); gtk_box_pack_start (GTK_BOX (editor), GTK_WIDGET (editor->view), TRUE, TRUE, 0); gtk_widget_show (GTK_WIDGET (editor->view)); g_signal_connect_object (editor->view, "select-item", G_CALLBACK (gimp_container_editor_select_item), editor, 0); g_signal_connect_object (editor->view, "activate-item", G_CALLBACK (gimp_container_editor_activate_item), editor, 0); g_signal_connect_object (editor->view, "context-item", G_CALLBACK (gimp_container_editor_context_item), editor, 0); { GimpObject *object = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); gimp_container_editor_select_item (GTK_WIDGET (editor->view), (GimpViewable *) object, NULL, editor); } return TRUE; }
LayerOptionsDialog * layer_options_dialog_new (GimpImage *image, GimpLayer *layer, GimpContext *context, GtkWidget *parent, const gchar *layer_name, GimpFillType layer_fill_type, const gchar *title, const gchar *role, const gchar *stock_id, const gchar *desc, const gchar *help_id) { LayerOptionsDialog *options; GimpViewable *viewable; GtkWidget *vbox; GtkWidget *table; GtkWidget *label; GtkObject *adjustment; GtkWidget *spinbutton; GtkWidget *frame; GtkWidget *button; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL); options = g_slice_new0 (LayerOptionsDialog); options->image = image; options->context = context; options->layer = layer; options->fill_type = layer_fill_type; if (layer) viewable = GIMP_VIEWABLE (layer); else viewable = GIMP_VIEWABLE (image); options->dialog = gimp_viewable_dialog_new (viewable, context, title, role, stock_id, desc, parent, gimp_standard_help_func, help_id, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_object_weak_ref (G_OBJECT (options->dialog), (GWeakNotify) layer_options_dialog_free, options); gtk_dialog_set_alternative_button_order (GTK_DIALOG (options->dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_set_spacing (GTK_BOX (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (options->dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); table = gtk_table_new (layer ? 1 : 3, 2, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 6); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); /* The name label and entry */ options->name_entry = gtk_entry_new (); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Layer _name:"), 0.0, 0.5, options->name_entry, 1, FALSE); gtk_entry_set_activates_default (GTK_ENTRY (options->name_entry), TRUE); gtk_entry_set_text (GTK_ENTRY (options->name_entry), layer_name); if (! layer) { gdouble xres; gdouble yres; gimp_image_get_resolution (image, &xres, &yres); /* The size labels */ label = gtk_label_new (_("Width:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0); gtk_widget_show (label); label = gtk_label_new (_("Height:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0); gtk_widget_show (label); /* The size sizeentry */ spinbutton = gimp_spin_button_new (&adjustment, 1, 1, 1, 1, 10, 0, 1, 2); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10); options->size_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 10, GIMP_SIZE_ENTRY_UPDATE_SIZE); gtk_table_set_col_spacing (GTK_TABLE (options->size_se), 1, 4); gtk_table_set_row_spacing (GTK_TABLE (options->size_se), 0, 2); gimp_size_entry_add_field (GIMP_SIZE_ENTRY (options->size_se), GTK_SPIN_BUTTON (spinbutton), NULL); gtk_table_attach_defaults (GTK_TABLE (options->size_se), spinbutton, 1, 2, 0, 1); gtk_widget_show (spinbutton); gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->size_se); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se), GIMP_UNIT_PIXEL); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0, xres, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 1, yres, FALSE); gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 0, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE); gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 1, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 0, 0, gimp_image_get_width (image)); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 1, 0, gimp_image_get_height (image)); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 0, gimp_image_get_width (image)); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 1, gimp_image_get_height (image)); /* The radio frame */ frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE, GIMP_FOREGROUND_FILL, GIMP_TRANSPARENT_FILL, gtk_label_new (_("Layer Fill Type")), G_CALLBACK (gimp_radio_button_update), &options->fill_type, &button); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), options->fill_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } else { GimpContainer *filters; GtkWidget *frame; GtkWidget *view; /* For text layers add a toggle to control "auto-rename" */ if (gimp_item_is_text_layer (GIMP_ITEM (layer))) { options->rename_toggle = gtk_check_button_new_with_mnemonic (_("Set name from _text")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->rename_toggle), GIMP_TEXT_LAYER (layer)->auto_rename); gtk_table_attach (GTK_TABLE (table), options->rename_toggle, 1, 2, 1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->rename_toggle); g_signal_connect (options->rename_toggle, "toggled", G_CALLBACK (layer_options_dialog_toggle_rename), options); } frame = gimp_frame_new ("Active Filters"); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); filters = gimp_drawable_get_filters (GIMP_DRAWABLE (layer)); view = gimp_container_tree_view_new (filters, context, GIMP_VIEW_SIZE_SMALL, 0); gtk_container_add (GTK_CONTAINER (frame), view); gtk_widget_show (view); } return options; }