static void file_export_dialog_response (GtkWidget *dialog, gint response_id, gpointer data) { if (response_id == FILE_SAVE_RESPONSE_OTHER_DIALOG) { GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog); GtkWindow *parent; GtkWidget *other; gchar *folder; gchar *uri; gchar *name; parent = gtk_window_get_transient_for (GTK_WINDOW (dialog)); folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)); uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); name = file_utils_uri_display_basename (uri); g_free (uri); other = file_save_dialog_show (file_dialog->image->gimp, file_dialog->image, GTK_WIDGET (parent), _("Save Image"), FALSE, FALSE, NULL); gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (other), folder); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), name); g_free (folder); g_free (name); } }
static void gimp_file_dialog_help_func (const gchar *help_id, gpointer help_data) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (help_data); GtkWidget *focus; focus = gtk_window_get_focus (GTK_WINDOW (dialog)); if (focus == dialog->proc_view) { gchar *proc_help_id; proc_help_id = gimp_file_proc_view_get_help_id (GIMP_FILE_PROC_VIEW (dialog->proc_view)); gimp_standard_help_func (proc_help_id, NULL); g_free (proc_help_id); } else { gimp_standard_help_func (help_id, NULL); } }
GtkWidget * file_open_dialog_new (Gimp *gimp) { GtkWidget *dialog; GimpFileDialogState *state; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); dialog = gimp_file_dialog_new (gimp, GIMP_FILE_CHOOSER_ACTION_OPEN, _("Open Image"), "gimp-file-open", GTK_STOCK_OPEN, GIMP_HELP_FILE_OPEN); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); state = g_object_get_data (G_OBJECT (gimp), "gimp-file-open-dialog-state"); if (state) gimp_file_dialog_set_state (GIMP_FILE_DIALOG (dialog), state); g_signal_connect (dialog, "response", G_CALLBACK (file_open_dialog_response), gimp); return dialog; }
static void file_open_dialog_show (Gimp *gimp, GtkWidget *parent, const gchar *title, GimpImage *image, const gchar *uri, gboolean open_as_layers) { GtkWidget *dialog; dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (), gtk_widget_get_screen (parent), NULL /*ui_manager*/, "gimp-file-open-dialog", -1, FALSE); if (dialog) { if (! uri && image) uri = gimp_image_get_uri (image); if (! uri) uri = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY); if (uri) gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri); gimp_file_dialog_set_open_image (GIMP_FILE_DIALOG (dialog), image, open_as_layers); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_widget_get_toplevel (parent))); gtk_window_present (GTK_WINDOW (dialog)); } }
static void gimp_file_dialog_progress_pulse (GimpProgress *progress) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); gimp_progress_pulse (GIMP_PROGRESS (dialog->progress)); }
static guint32 gimp_file_dialog_progress_get_window (GimpProgress *progress) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); return (guint32) gimp_window_get_native (GTK_WINDOW (dialog)); }
static gboolean gimp_file_dialog_progress_is_active (GimpProgress *progress) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); return gimp_progress_is_active (GIMP_PROGRESS (dialog->progress)); }
static gdouble gimp_file_dialog_progress_get_value (GimpProgress *progress) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); return gimp_progress_get_value (GIMP_PROGRESS (dialog->progress)); }
static void file_export_dialog_destroyed (GtkWidget *dialog, GimpImage *image) { if (GIMP_FILE_DIALOG (dialog)->image == image) g_object_set_data (G_OBJECT (image), "gimp-file-export-dialog", NULL); }
static void gimp_file_dialog_progress_set_value (GimpProgress *progress, gdouble percentage) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); gimp_progress_set_value (GIMP_PROGRESS (dialog->progress), percentage); }
static void gimp_file_dialog_progress_set_text (GimpProgress *progress, const gchar *message) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); gimp_progress_set_text (GIMP_PROGRESS (dialog->progress), message); }
static void gimp_file_dialog_progress_end (GimpProgress *progress) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); gimp_progress_end (GIMP_PROGRESS (dialog->progress)); gtk_widget_hide (dialog->progress); }
static GtkWidget * file_save_dialog_show (Gimp *gimp, GimpImage *image, GtkWidget *parent, const gchar *title, gboolean save_a_copy, gboolean close_after_saving, GimpDisplay *display) { GtkWidget *dialog; dialog = g_object_get_data (G_OBJECT (image), "gimp-file-save-dialog"); if (! dialog) { dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (), gtk_widget_get_screen (parent), NULL /*ui_manager*/, "gimp-file-save-dialog", -1, FALSE); if (dialog) { gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_widget_get_toplevel (parent))); g_object_set_data_full (G_OBJECT (image), "gimp-file-save-dialog", dialog, (GDestroyNotify) gtk_widget_destroy); g_signal_connect (dialog, "response", G_CALLBACK (file_save_dialog_response), image); g_signal_connect (dialog, "destroy", G_CALLBACK (file_save_dialog_destroyed), image); } } if (dialog) { gtk_window_set_title (GTK_WINDOW (dialog), title); gimp_file_dialog_set_save_image (GIMP_FILE_DIALOG (dialog), gimp, image, save_a_copy, FALSE, close_after_saving, GIMP_OBJECT (display)); gtk_window_present (GTK_WINDOW (dialog)); } return dialog; }
static void file_open_dialog_show (GtkWidget *parent, GimpImage *image, const gchar *uri, gboolean open_as_layers) { GtkWidget *dialog; dialog = gimp_dialog_factory_dialog_new (global_dialog_factory, gtk_widget_get_screen (parent), "gimp-file-open-dialog", -1, FALSE); if (dialog) { if (uri) gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri); if (open_as_layers) { gtk_window_set_title (GTK_WINDOW (dialog), _("Open Image as Layers")); GIMP_FILE_DIALOG (dialog)->image = image; } else { gtk_window_set_title (GTK_WINDOW (dialog), _("Open Image")); GIMP_FILE_DIALOG (dialog)->image = NULL; } parent = gtk_widget_get_toplevel (parent); if (GTK_IS_WINDOW (parent)) gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); gtk_window_present (GTK_WINDOW (dialog)); } }
static GimpProgress * gimp_file_dialog_progress_start (GimpProgress *progress, const gchar *message, gboolean cancelable) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress); GimpProgress *retval; retval = gimp_progress_start (GIMP_PROGRESS (dialog->progress), message, cancelable); gtk_widget_show (dialog->progress); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL, cancelable); return retval; }
static void gimp_file_dialog_response (GtkDialog *dialog, gint response_id) { GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog); if (response_id != GTK_RESPONSE_OK && file_dialog->busy) { file_dialog->canceled = TRUE; if (GIMP_PROGRESS_BOX (file_dialog->progress)->active && GIMP_PROGRESS_BOX (file_dialog->progress)->cancelable) { gimp_progress_cancel (GIMP_PROGRESS (dialog)); } } }
static GtkWidget * file_export_dialog_show (Gimp *gimp, GimpImage *image, GtkWidget *parent) { GtkWidget *dialog; dialog = g_object_get_data (G_OBJECT (image), "gimp-file-export-dialog"); if (! dialog) { dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (), gtk_widget_get_screen (parent), NULL /*ui_manager*/, "gimp-file-export-dialog", -1, FALSE); if (dialog) { gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_widget_get_toplevel (parent))); g_object_set_data_full (G_OBJECT (image), "gimp-file-export-dialog", dialog, (GDestroyNotify) gtk_widget_destroy); g_signal_connect (dialog, "response", G_CALLBACK (file_export_dialog_response), image); g_signal_connect (dialog, "destroy", G_CALLBACK (file_export_dialog_destroyed), image); } } if (dialog) { gimp_file_dialog_set_save_image (GIMP_FILE_DIALOG (dialog), gimp, image, FALSE, TRUE, FALSE, NULL); gtk_window_present (GTK_WINDOW (dialog)); } return dialog; }
static void file_save_dialog_show (GimpImage *image, GtkWidget *parent, const gchar *title, gboolean save_a_copy, gboolean close_after_saving) { GtkWidget *dialog; dialog = g_object_get_data (G_OBJECT (image), "gimp-file-save-dialog"); if (! dialog) { dialog = gimp_dialog_factory_dialog_new (global_dialog_factory, gtk_widget_get_screen (parent), "gimp-file-save-dialog", -1, FALSE); if (dialog) { gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); g_object_set_data_full (G_OBJECT (image), "gimp-file-save-dialog", dialog, (GDestroyNotify) gtk_widget_destroy); g_signal_connect (dialog, "destroy", G_CALLBACK (file_save_dialog_destroyed), image); } } if (dialog) { gtk_window_set_title (GTK_WINDOW (dialog), title); gimp_file_dialog_set_image (GIMP_FILE_DIALOG (dialog), image, save_a_copy, close_after_saving); gtk_window_present (GTK_WINDOW (dialog)); } }
GtkWidget * file_open_dialog_new (Gimp *gimp) { GtkWidget *dialog; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); dialog = gimp_open_dialog_new (gimp); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); gimp_file_dialog_load_state (GIMP_FILE_DIALOG (dialog), "gimp-file-open-dialog-state"); g_signal_connect (dialog, "response", G_CALLBACK (file_open_dialog_response), gimp); return dialog; }
static void file_open_dialog_response (GtkWidget *dialog, gint response_id, Gimp *gimp) { GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog); GimpOpenDialog *open_dialog = GIMP_OPEN_DIALOG (dialog); GSList *files; GSList *list; gboolean success = FALSE; gimp_file_dialog_save_state (GIMP_FILE_DIALOG (dialog), "gimp-file-open-dialog-state"); if (response_id != GTK_RESPONSE_OK) { if (! file_dialog->busy) gtk_widget_destroy (dialog); return; } files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog)); if (files) g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY, g_object_ref (files->data), (GDestroyNotify) g_object_unref); gimp_file_dialog_set_sensitive (file_dialog, FALSE); /* When we are going to open new image windows, unset the transient * window. We don't need it since we will use gdk_window_raise() to * keep the dialog on top. And if we don't do it, then the dialog * will pull the image window it was invoked from on top of all the * new opened image windows, and we don't want that to happen. */ if (! open_dialog->open_as_layers) gtk_window_set_transient_for (GTK_WINDOW (dialog), NULL); for (list = files; list; list = g_slist_next (list)) { GFile *file = list->data; if (open_dialog->open_as_layers) { if (! file_dialog->image) { file_dialog->image = file_open_dialog_open_image (dialog, gimp, file, file_dialog->file_proc); if (file_dialog->image) success = TRUE; } else if (file_open_dialog_open_layers (dialog, file_dialog->image, file, file_dialog->file_proc)) { success = TRUE; } } else { if (file_open_dialog_open_image (dialog, gimp, file, file_dialog->file_proc)) { success = TRUE; /* Make the dialog stay on top of all images we open if * we open say 10 at once */ gdk_window_raise (gtk_widget_get_window (dialog)); } } if (file_dialog->canceled) break; } if (success) { if (open_dialog->open_as_layers && file_dialog->image) gimp_image_flush (file_dialog->image); gtk_widget_destroy (dialog); } else { gimp_file_dialog_set_sensitive (file_dialog, TRUE); } g_slist_free_full (files, (GDestroyNotify) g_object_unref); }
void gimp_export_dialog_set_image (GimpExportDialog *dialog, Gimp *gimp, GimpImage *image) { GFile *dir_file = NULL; GFile *name_file = NULL; GFile *ext_file = NULL; gchar *basename; g_return_if_fail (GIMP_IS_EXPORT_DIALOG (dialog)); g_return_if_fail (GIMP_IS_IMAGE (image)); GIMP_FILE_DIALOG (dialog)->image = image; gimp_file_dialog_set_file_proc (GIMP_FILE_DIALOG (dialog), NULL); /* * Priority of default paths for Export: * * 1. Last Export path * 2. Path of import source * 3. Path of XCF source * 4. Last path of any save to XCF * 5. Last Export path of any document * 6. The default path (usually the OS 'Documents' path) */ dir_file = gimp_image_get_exported_file (image); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (image), "gimp-image-source-file"); if (! dir_file) dir_file = gimp_image_get_imported_file (image); if (! dir_file) dir_file = gimp_image_get_file (image); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_SAVE_LAST_FILE_KEY); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_EXPORT_LAST_FILE_KEY); if (! dir_file) dir_file = gimp_export_dialog_get_default_folder (gimp); /* Priority of default basenames for Export: * * 1. Last Export name * 3. Save URI * 2. Source file name * 3. 'Untitled' */ name_file = gimp_image_get_exported_file (image); if (! name_file) name_file = gimp_image_get_file (image); if (! name_file) name_file = gimp_image_get_imported_file (image); if (! name_file) name_file = gimp_image_get_untitled_file (image); /* Priority of default type/extension for Export: * * 1. Type of last Export * 2. Type of the image Import * 3. Type of latest Export of any document * 4. .png */ ext_file = gimp_image_get_exported_file (image); if (! ext_file) ext_file = gimp_image_get_imported_file (image); if (! ext_file) ext_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_EXPORT_LAST_FILE_KEY); if (ext_file) g_object_ref (ext_file); else ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.png"); if (ext_file) { GFile *tmp_file = file_utils_file_with_new_ext (name_file, ext_file); basename = g_path_get_basename (gimp_file_get_utf8_name (tmp_file)); g_object_unref (tmp_file); g_object_unref (ext_file); } else { basename = g_path_get_basename (gimp_file_get_utf8_name (name_file)); } if (g_file_query_file_type (dir_file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY) { gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), dir_file, NULL); } else { GFile *parent_file = g_file_get_parent (dir_file); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), parent_file, NULL); g_object_unref (parent_file); } gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); }
static void file_open_dialog_response (GtkWidget *open_dialog, gint response_id, Gimp *gimp) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (open_dialog); GSList *uris; GSList *list; gboolean success = FALSE; g_object_set_data_full (G_OBJECT (gimp), "gimp-file-open-dialog-state", gimp_file_dialog_get_state (dialog), (GDestroyNotify) gimp_file_dialog_state_destroy); if (response_id != GTK_RESPONSE_OK) { if (! dialog->busy) gtk_widget_destroy (open_dialog); return; } uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (open_dialog)); if (uris) g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY, g_strdup (uris->data), (GDestroyNotify) g_free); gimp_file_dialog_set_sensitive (dialog, FALSE); /* When we are going to open new image windows, unset the transient * window. We don't need it since we will use gdk_window_raise() to * keep the dialog on top. And if we don't do it, then the dialog * will pull the image window it was invoked from on top of all the * new opened image windows, and we don't want that to happen. */ if (! dialog->open_as_layers) gtk_window_set_transient_for (GTK_WINDOW (open_dialog), NULL); for (list = uris; list; list = g_slist_next (list)) { gchar *filename = file_utils_filename_from_uri (list->data); if (filename) { gboolean regular = g_file_test (filename, G_FILE_TEST_IS_REGULAR); g_free (filename); if (! regular) continue; } if (dialog->open_as_layers) { if (! dialog->image) { dialog->image = file_open_dialog_open_image (open_dialog, gimp, list->data, dialog->file_proc); if (dialog->image) success = TRUE; } else if (file_open_dialog_open_layers (open_dialog, dialog->image, list->data, dialog->file_proc)) { success = TRUE; } } else { if (file_open_dialog_open_image (open_dialog, gimp, list->data, dialog->file_proc)) { success = TRUE; /* Make the dialog stay on top of all images we open if * we open say 10 at once */ gdk_window_raise (gtk_widget_get_window (open_dialog)); } } if (dialog->canceled) break; } if (success) { if (dialog->open_as_layers && dialog->image) gimp_image_flush (dialog->image); gtk_widget_destroy (open_dialog); } else { gimp_file_dialog_set_sensitive (dialog, TRUE); } g_slist_free_full (uris, (GDestroyNotify) g_free); }
static void gimp_thumb_box_create_thumbnails (GimpThumbBox *box, gboolean force) { Gimp *gimp = box->imagefile->gimp; GimpProgress *progress = GIMP_PROGRESS (box); GimpFileDialog *dialog = NULL; GtkWidget *toplevel; GSList *list; gint n_uris; gint i; if (gimp->config->thumbnail_size == GIMP_THUMBNAIL_SIZE_NONE) return; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box)); if (GIMP_IS_FILE_DIALOG (toplevel)) dialog = GIMP_FILE_DIALOG (toplevel); gimp_set_busy (gimp); if (dialog) gimp_file_dialog_set_sensitive (dialog, FALSE); else gtk_widget_set_sensitive (toplevel, FALSE); if (box->uris) { gtk_widget_hide (box->info); gtk_widget_show (box->progress); } n_uris = g_slist_length (box->uris); if (n_uris > 1) { gchar *str; gimp_progress_start (GIMP_PROGRESS (box), "", TRUE); progress = gimp_sub_progress_new (GIMP_PROGRESS (box)); gimp_sub_progress_set_step (GIMP_SUB_PROGRESS (progress), 0, n_uris); for (list = box->uris->next, i = 1; list; list = g_slist_next (list), i++) { str = g_strdup_printf (_("Thumbnail %d of %d"), i, n_uris); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (box->progress), str); g_free (str); gimp_progress_set_value (progress, 0.0); while (gtk_events_pending ()) gtk_main_iteration (); gimp_thumb_box_create_thumbnail (box, list->data, gimp->config->thumbnail_size, force, progress); if (dialog && dialog->canceled) goto canceled; gimp_sub_progress_set_step (GIMP_SUB_PROGRESS (progress), i, n_uris); } str = g_strdup_printf (_("Thumbnail %d of %d"), n_uris, n_uris); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (box->progress), str); g_free (str); gimp_progress_set_value (progress, 0.0); while (gtk_events_pending ()) gtk_main_iteration (); } if (box->uris) { gimp_thumb_box_create_thumbnail (box, box->uris->data, gimp->config->thumbnail_size, force, progress); gimp_progress_set_value (progress, 1.0); } canceled: if (n_uris > 1) { g_object_unref (progress); gimp_progress_end (GIMP_PROGRESS (box)); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (box->progress), ""); } if (box->uris) { gtk_widget_hide (box->progress); gtk_widget_show (box->info); } if (dialog) gimp_file_dialog_set_sensitive (dialog, TRUE); else gtk_widget_set_sensitive (toplevel, TRUE); gimp_unset_busy (gimp); }