static GtkWidget * image_scale_confirm_dialog (ImageScaleDialog *dialog) { GtkWidget *widget; widget = gimp_message_dialog_new (_("Confirm Scaling"), GIMP_STOCK_WARNING, dialog->dialog, GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, GIMP_HELP_IMAGE_SCALE_WARNING, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GIMP_STOCK_SCALE, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (widget), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect (widget, "response", G_CALLBACK (image_scale_confirm_response), dialog); return widget; }
void plug_in_reset_all_cmd_callback (GtkAction *action, gpointer data) { Gimp *gimp; GtkWidget *dialog; return_if_no_gimp (gimp, data); dialog = gimp_message_dialog_new (_("Reset all Filters"), GIMP_STOCK_QUESTION, NULL, 0, gimp_standard_help_func, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GIMP_STOCK_RESET, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "response", G_CALLBACK (plug_in_reset_all_response), gimp); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Do you really want to reset all " "filters to default values?")); gtk_widget_show (dialog); }
GtkWidget * data_delete_dialog_new (GimpDataFactory *factory, GimpData *data, GimpContext *context, GtkWidget *parent) { DataDeleteDialog *delete_data; GtkWidget *dialog; g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL); g_return_val_if_fail (GIMP_IS_DATA (data), NULL); g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL); delete_data = g_slice_new0 (DataDeleteDialog); delete_data->factory = factory; delete_data->data = data; delete_data->context = context; delete_data->parent = parent; dialog = gimp_message_dialog_new (_("Delete Object"), GTK_STOCK_DELETE, gtk_widget_get_toplevel (parent), 0, gimp_standard_help_func, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_DELETE, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (data, "disconnect", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); g_signal_connect (dialog, "response", G_CALLBACK (data_delete_dialog_response), delete_data); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Delete '%s'?"), gimp_object_get_name (data)); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Are you sure you want to remove '%s' " "from the list and delete it on disk?"), gimp_object_get_name (data)); return dialog; }
void tool_options_reset_all_cmd_callback (GtkAction *action, gpointer data) { GimpEditor *editor = GIMP_EDITOR (data); GtkWidget *dialog; dialog = gimp_message_dialog_new (_("Reset All Tool Options"), GIMP_STOCK_QUESTION, GTK_WIDGET (editor), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GIMP_STOCK_RESET, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (gtk_widget_get_toplevel (GTK_WIDGET (editor)), "unmap", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Do you really want to reset all " "tool options to default values?")); if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) { Gimp *gimp = gimp_editor_get_ui_manager (editor)->gimp; GList *list; for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = list->data; gimp_config_reset (GIMP_CONFIG (tool_info->tool_options)); } } gtk_widget_destroy (dialog); }
static void gimp_help_browser_error (Gimp *gimp, const gchar *title, const gchar *primary, const gchar *text) { GtkWidget *dialog; dialog = gimp_message_dialog_new (title, GIMP_STOCK_WARNING, NULL, 0, NULL, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Use _web browser instead"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, primary); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, text); if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) { g_object_set (gimp->config, "help-browser", GIMP_HELP_BROWSER_WEB_BROWSER, NULL); } gtk_widget_destroy (dialog); }
static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, GimpImage *image) { GtkWidget *dialog; GtkWidget *button; GimpMessageBox *box; GClosure *closure; GSource *source; gchar *name; gchar *title; if (shell->close_dialog) { gtk_window_present (GTK_WINDOW (shell->close_dialog)); return; } name = file_utils_uri_display_basename (gimp_image_get_uri (image)); title = g_strdup_printf (_("Close %s"), name); g_free (name); shell->close_dialog = dialog = gimp_message_dialog_new (title, GTK_STOCK_SAVE, GTK_WIDGET (shell), GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, NULL, NULL); g_free (title); button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("Do_n't Save"), GTK_RESPONSE_CLOSE); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON)); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, RESPONSE_SAVE, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), RESPONSE_SAVE, GTK_RESPONSE_CLOSE, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &shell->close_dialog); g_signal_connect (dialog, "response", G_CALLBACK (gimp_display_shell_close_response), shell); box = GIMP_MESSAGE_DIALOG (dialog)->box; g_signal_connect_object (image, "name-changed", G_CALLBACK (gimp_display_shell_close_name_changed), box, 0); gimp_display_shell_close_name_changed (image, box); closure = g_cclosure_new_object (G_CALLBACK (gimp_display_shell_close_time_changed), G_OBJECT (box)); /* update every 10 seconds */ source = g_timeout_source_new (10 * 1000); g_source_set_closure (source, closure); g_source_attach (source, NULL); g_source_unref (source); /* The dialog is destroyed with the shell, so it should be safe * to hold an image pointer for the lifetime of the dialog. */ g_object_set_data (G_OBJECT (box), "gimp-image", image); gimp_display_shell_close_time_changed (box); gtk_widget_show (dialog); }
static void gimp_action_view_conflict_confirm (GimpActionView *view, GtkAction *action, guint accel_key, GdkModifierType accel_mask, const gchar *accel_path) { GimpActionGroup *group; gchar *label; gchar *accel_string; ConfirmData *confirm_data; GtkWidget *dialog; GimpMessageBox *box; g_object_get (action, "action-group", &group, NULL); label = gimp_strip_uline (gtk_action_get_label (action)); accel_string = gtk_accelerator_get_label (accel_key, accel_mask); confirm_data = g_slice_new (ConfirmData); confirm_data->manager = view->manager; confirm_data->accel_path = g_strdup (accel_path); confirm_data->accel_key = accel_key; confirm_data->accel_mask = accel_mask; dialog = gimp_message_dialog_new (_("Conflicting Shortcuts"), GIMP_STOCK_WARNING, gtk_widget_get_toplevel (GTK_WIDGET (view)), 0, gimp_standard_help_func, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Reassign shortcut"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "response", G_CALLBACK (gimp_action_view_conflict_response), confirm_data); box = GIMP_MESSAGE_DIALOG (dialog)->box; gimp_message_box_set_primary_text (box, _("Shortcut \"%s\" is already taken " "by \"%s\" from the \"%s\" group."), accel_string, label, group->label); gimp_message_box_set_text (box, _("Reassigning the shortcut will cause it " "to be removed from \"%s\"."), label); g_free (label); g_free (accel_string); g_object_unref (group); gtk_widget_show (dialog); }
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; }
void file_revert_cmd_callback (GtkAction *action, gpointer data) { GimpDisplay *display; GimpImage *image; GtkWidget *dialog; const gchar *uri; return_if_no_display (display, data); image = gimp_display_get_image (display); uri = gimp_image_get_uri (image); if (! uri) uri = gimp_image_get_imported_uri (image); dialog = g_object_get_data (G_OBJECT (image), REVERT_DATA_KEY); if (! uri) { gimp_message_literal (image->gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Revert failed. " "No file name associated with this image.")); } else if (dialog) { gtk_window_present (GTK_WINDOW (dialog)); } else { gchar *filename; dialog = gimp_message_dialog_new (_("Revert Image"), GTK_STOCK_REVERT_TO_SAVED, GTK_WIDGET (gimp_display_get_shell (display)), 0, gimp_standard_help_func, GIMP_HELP_FILE_REVERT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_REVERT_TO_SAVED, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (display, "disconnect", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); g_signal_connect (dialog, "response", G_CALLBACK (file_revert_confirm_response), display); filename = file_utils_uri_display_name (uri); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Revert '%s' to '%s'?"), gimp_image_get_display_name (image), filename); g_free (filename); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("By reverting the image to the state saved " "on disk, you will lose all changes, " "including all undo information.")); g_object_set_data (G_OBJECT (image), REVERT_DATA_KEY, dialog); gtk_widget_show (dialog); } }
static void gimp_controller_list_remove_clicked (GtkWidget *button, GimpControllerList *list) { GtkWidget *dialog; const gchar *name; #define RESPONSE_DISABLE 1 dialog = gimp_message_dialog_new (_("Remove Controller?"), GIMP_STOCK_WARNING, GTK_WIDGET (list), GTK_DIALOG_MODAL, NULL, NULL, _("Disable Controller"), RESPONSE_DISABLE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Remove Controller"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, RESPONSE_DISABLE, -1); name = gimp_object_get_name (list->dest_info); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Remove Controller '%s'?"), name); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, "%s", _("Removing this controller from the list of " "active controllers will permanently delete " "all event mappings you have configured.\n\n" "Selecting \"Disable Controller\" will disable " "the controller without removing it.")); switch (gimp_dialog_run (GIMP_DIALOG (dialog))) { case RESPONSE_DISABLE: gimp_controller_info_set_enabled (list->dest_info, FALSE); break; case GTK_RESPONSE_OK: { GtkWidget *editor_dialog; GimpContainer *container; editor_dialog = g_object_get_data (G_OBJECT (list->dest_info), "gimp-controller-editor-dialog"); if (editor_dialog) gtk_dialog_response (GTK_DIALOG (editor_dialog), GTK_RESPONSE_DELETE_EVENT); container = gimp_controllers_get_list (list->gimp); gimp_container_remove (container, GIMP_OBJECT (list->dest_info)); } break; default: break; } gtk_widget_destroy (dialog); }
void edit_undo_clear_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpUndoStack *undo_stack; GimpUndoStack *redo_stack; GtkWidget *widget; GtkWidget *dialog; gchar *size; gint64 memsize; gint64 guisize; return_if_no_image (image, data); return_if_no_widget (widget, data); dialog = gimp_message_dialog_new (_("Clear Undo History"), GIMP_STOCK_WARNING, widget, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, GIMP_HELP_EDIT_UNDO_CLEAR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CLEAR, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (gtk_widget_get_toplevel (widget), "unmap", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); g_signal_connect_object (image, "disconnect", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Really clear image's undo history?")); undo_stack = gimp_image_get_undo_stack (image); redo_stack = gimp_image_get_redo_stack (image); memsize = gimp_object_get_memsize (GIMP_OBJECT (undo_stack), &guisize); memsize += guisize; memsize += gimp_object_get_memsize (GIMP_OBJECT (redo_stack), &guisize); memsize += guisize; size = g_format_size (memsize); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Clearing the undo history of this " "image will gain %s of memory."), size); g_free (size); if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) { gimp_image_undo_disable (image); gimp_image_undo_enable (image); gimp_image_flush (image); } gtk_widget_destroy (dialog); }
void documents_clear_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContext *context = gimp_container_view_get_context (editor->view); Gimp *gimp = context->gimp; GtkWidget *dialog; dialog = gimp_message_dialog_new (_("Clear Document History"), GIMP_STOCK_SHRED, GTK_WIDGET (editor), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CLEAR, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect_object (gtk_widget_get_toplevel (GTK_WIDGET (editor)), "unmap", G_CALLBACK (gtk_widget_destroy), dialog, G_CONNECT_SWAPPED); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Clear the Recent Documents list?")); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, _("Clearing the document history will " "permanently remove all images from " "the recent documents list.")); if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) { GtkRecentManager *manager = gtk_recent_manager_get_default (); GList *items; GList *list; items = gtk_recent_manager_get_items (manager); for (list = items; list; list = list->next) { GtkRecentInfo *info = list->data; if (gtk_recent_info_has_application (info, "GNU Image Manipulation Program")) { gtk_recent_manager_remove_item (manager, gtk_recent_info_get_uri (info), NULL); } gtk_recent_info_unref (info); } g_list_free (items); gimp_container_clear (gimp->documents); } gtk_widget_destroy (dialog); }
void window_open_display_cmd_callback (GtkAction *action, gpointer data) { GtkWidget *widget; GtkWidget *dialog; GtkWidget *entry; return_if_no_widget (widget, data); dialog = gimp_message_dialog_new ("Open Display", GIMP_STOCK_WILBER_EEK, widget, GTK_DIALOG_MODAL, NULL, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, "Experimental multi-display stuff!\n" "Click OK and have fun crashing GIMP..."); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, "Please enter the name of the new display:"); entry = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_box_pack_start (GTK_BOX (GIMP_MESSAGE_DIALOG (dialog)->box), entry, TRUE, TRUE, 0); gtk_widget_grab_focus (entry); gtk_widget_show_all (dialog); while (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { gchar *screen_name; screen_name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); if (strcmp (screen_name, "")) { GdkDisplay *display; gtk_widget_set_sensitive (dialog, FALSE); display = gdk_display_open (screen_name); if (! display) gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, "Can't open display '%s'. " "Please try another one:", screen_name); g_free (screen_name); gtk_widget_set_sensitive (dialog, TRUE); if (display) break; } gtk_widget_grab_focus (entry); } gtk_widget_destroy (dialog); }
static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, GimpImage *image) { GtkWidget *dialog; GimpMessageBox *box; GtkWidget *label; GtkAccelGroup *accel_group; GClosure *closure; GSource *source; guint accel_key; GdkModifierType accel_mods; gchar *title; gchar *accel_string; gchar *hint; gchar *markup; GFile *file; if (shell->close_dialog) { gtk_window_present (GTK_WINDOW (shell->close_dialog)); return; } file = gimp_image_get_file (image); title = g_strdup_printf (_("Close %s"), gimp_image_get_display_name (image)); shell->close_dialog = dialog = gimp_message_dialog_new (title, "document-save", GTK_WIDGET (shell), GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, NULL, NULL); g_free (title); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Discard Changes"), GTK_RESPONSE_CLOSE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, (file ? GTK_STOCK_SAVE : GTK_STOCK_SAVE_AS), RESPONSE_SAVE, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), RESPONSE_SAVE, GTK_RESPONSE_CLOSE, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &shell->close_dialog); g_signal_connect (dialog, "response", G_CALLBACK (gimp_display_shell_close_response), shell); /* connect <Primary>D to the quit/close button */ accel_group = gtk_accel_group_new (); gtk_window_add_accel_group (GTK_WINDOW (shell->close_dialog), accel_group); g_object_unref (accel_group); closure = g_closure_new_object (sizeof (GClosure), G_OBJECT (shell->close_dialog)); g_closure_set_marshal (closure, gimp_display_shell_close_accel_marshal); gtk_accelerator_parse ("<Primary>D", &accel_key, &accel_mods); gtk_accel_group_connect (accel_group, accel_key, accel_mods, 0, closure); box = GIMP_MESSAGE_DIALOG (dialog)->box; accel_string = gtk_accelerator_get_label (accel_key, accel_mods); hint = g_strdup_printf (_("Press %s to discard all changes and close the image."), accel_string); markup = g_strdup_printf ("<i><small>%s</small></i>", hint); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_markup (GTK_LABEL (label), markup); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (markup); g_free (hint); g_free (accel_string); g_signal_connect_object (image, "name-changed", G_CALLBACK (gimp_display_shell_close_name_changed), box, 0); g_signal_connect_object (image, "exported", G_CALLBACK (gimp_display_shell_close_exported), box, 0); gimp_display_shell_close_name_changed (image, box); closure = g_cclosure_new_object (G_CALLBACK (gimp_display_shell_close_time_changed), G_OBJECT (box)); /* update every 10 seconds */ source = g_timeout_source_new_seconds (10); g_source_set_closure (source, closure); g_source_attach (source, NULL); g_source_unref (source); /* The dialog is destroyed with the shell, so it should be safe * to hold an image pointer for the lifetime of the dialog. */ g_object_set_data (G_OBJECT (box), "gimp-image", image); gimp_display_shell_close_time_changed (box); gtk_widget_show (dialog); }