static void image_preview_set_viewable (GimpView *view, GimpViewable *old_viewable, GimpViewable *new_viewable) { if (! old_viewable && new_viewable) { gimp_dnd_xds_source_add (GTK_WIDGET (view), (GimpDndDragViewableFunc) gimp_view_get_viewable, NULL); } else if (old_viewable && ! new_viewable) { gimp_dnd_xds_source_remove (GTK_WIDGET (view)); } }
GtkWidget * gimp_image_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpImageView *image_view; GimpContainerEditor *editor; image_view = g_object_new (GIMP_TYPE_IMAGE_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (image_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Images>", "/images-popup")) { g_object_unref (image_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (image_view); image_view->raise_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-raise-views", NULL); image_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-new-view", NULL); image_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-delete", NULL); if (view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *dnd_widget; dnd_widget = gimp_container_view_get_dnd_widget (editor->view); gimp_dnd_xds_source_add (dnd_widget, (GimpDndDragViewableFunc) gimp_dnd_get_drag_data, NULL); } gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->raise_button), GIMP_TYPE_IMAGE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->new_button), GIMP_TYPE_IMAGE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->delete_button), GIMP_TYPE_IMAGE); gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return GTK_WIDGET (image_view); }
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; }