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); }
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); }