static gboolean gimp_display_shell_close_time_changed (GimpMessageBox *box) { GimpImage *image = g_object_get_data (G_OBJECT (box), "gimp-image"); gint dirty_time = gimp_image_get_dirty_time (image); if (dirty_time) { gint hours = 0; gint minutes = 0; gimp_time_since (dirty_time, &hours, &minutes); if (hours > 0) { if (hours > 1 || minutes == 0) gimp_message_box_set_text (box, ngettext ("If you don't save the image, " "changes from the last hour " "will be lost.", "If you don't save the image, " "changes from the last %d " "hours will be lost.", hours), hours); else gimp_message_box_set_text (box, ngettext ("If you don't save the image, " "changes from the last hour " "and %d minute will be lost.", "If you don't save the image, " "changes from the last hour " "and %d minutes will be lost.", minutes), minutes); } else { gimp_message_box_set_text (box, ngettext ("If you don't save the image, " "changes from the last minute " "will be lost.", "If you don't save the image, " "changes from the last %d " "minutes will be lost.", minutes), minutes); } } else { gimp_message_box_set_text (box, NULL); } return TRUE; }
void gui_abort (const gchar *abort_message) { GtkWidget *dialog; GtkWidget *box; g_return_if_fail (abort_message != NULL); dialog = gimp_dialog_new (_("GIMP Message"), "gimp-abort", NULL, GTK_DIALOG_MODAL, NULL, NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); box = g_object_new (GIMP_TYPE_MESSAGE_BOX, "icon-name", GIMP_STOCK_WILBER_EEK, "border-width", 12, NULL); gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), "%s", abort_message); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), box, TRUE, TRUE, 0); gtk_widget_show (box); gimp_dialog_run (GIMP_DIALOG (dialog)); exit (EXIT_FAILURE); }
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; }
static void image_scale_confirm_small (ImageScaleDialog *dialog) { GtkWidget *widget = image_scale_confirm_dialog (dialog); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (widget)->box, _("Scaling the image to the chosen size " "will shrink some layers completely " "away.")); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (widget)->box, _("Is this what you want to do?")); gtk_widget_show (widget); }
static void image_scale_confirm_large (ImageScaleDialog *dialog, gint64 new_memsize, gint64 max_memsize) { GtkWidget *widget = image_scale_confirm_dialog (dialog); gchar *size; size = g_format_size_for_display (new_memsize); gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (widget)->box, _("You are trying to create an image " "with a size of %s."), size); g_free (size); size = g_format_size_for_display (max_memsize); gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (widget)->box, _("Scaling the image to the chosen size will " "make it use more memory than what is " "configured as \"Maximum Image Size\" in the " "Preferences dialog (currently %s)."), size); g_free (size); gtk_widget_show (widget); }
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_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); }
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 gimp_error_dialog_add (GimpErrorDialog *dialog, const gchar *stock_id, const gchar *domain, const gchar *message) { GtkWidget *box; gboolean overflow = FALSE; g_return_if_fail (GIMP_IS_ERROR_DIALOG (dialog)); g_return_if_fail (domain != NULL); g_return_if_fail (message != NULL); if (dialog->last_box && dialog->last_domain && strcmp (dialog->last_domain, domain) == 0 && dialog->last_message && strcmp (dialog->last_message, message) == 0) { if (gimp_message_box_repeat (GIMP_MESSAGE_BOX (dialog->last_box))) return; } if (dialog->num_messages >= GIMP_ERROR_DIALOG_MAX_MESSAGES) { g_printerr ("%s: %s\n\n", domain, message); overflow = TRUE; stock_id = GIMP_STOCK_WILBER_EEK; domain = _("Too many error messages!"); message = _("Messages are redirected to stderr."); if (dialog->last_domain && strcmp (dialog->last_domain, domain) == 0 && dialog->last_message && strcmp (dialog->last_message, message) == 0) { return; } } box = g_object_new (GIMP_TYPE_MESSAGE_BOX, "stock-id", stock_id, NULL); dialog->num_messages++; if (overflow) gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), "%s", domain); else gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), /* %s is a message domain, * like "GIMP Message" or * "PNG Message" */ _("%s Message"), domain); gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), "%s", message); gtk_box_pack_start (GTK_BOX (dialog->vbox), box, TRUE, TRUE, 0); gtk_widget_show (box); dialog->last_box = box; g_free (dialog->last_domain); dialog->last_domain = g_strdup (domain); g_free (dialog->last_message); dialog->last_message = g_strdup (message); }
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 gboolean gimp_display_shell_close_time_changed (GimpMessageBox *box) { GimpImage *image = g_object_get_data (G_OBJECT (box), "gimp-image"); gint64 dirty_time = gimp_image_get_dirty_time (image); gchar *time_text = NULL; gchar *export_text = NULL; if (dirty_time) { gint hours = 0; gint minutes = 0; gimp_time_since (dirty_time, &hours, &minutes); if (hours > 0) { if (hours > 1 || minutes == 0) { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last hour " "will be lost.", "If you don't save the image, " "changes from the last %d " "hours will be lost.", hours), hours); } else { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last hour " "and %d minute will be lost.", "If you don't save the image, " "changes from the last hour " "and %d minutes will be lost.", minutes), minutes); } } else { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last minute " "will be lost.", "If you don't save the image, " "changes from the last %d " "minutes will be lost.", minutes), minutes); } } if (! gimp_image_is_export_dirty (image)) { GFile *file; file = gimp_image_get_exported_file (image); if (! file) file = gimp_image_get_imported_file (image); export_text = g_strdup_printf (_("The image has been exported to '%s'."), gimp_file_get_utf8_name (file)); } if (time_text && export_text) gimp_message_box_set_text (box, "%s\n\n%s", time_text, export_text); else if (time_text || export_text) gimp_message_box_set_text (box, "%s", time_text ? time_text : export_text); else gimp_message_box_set_text (box, "%s", time_text); g_free (time_text); g_free (export_text); return TRUE; }