static void build_filename_ready_cb (GObject *source, GAsyncResult *res, gpointer user_data) { GtkWidget *toplevel; ScreenshotDialog *dialog; GdkPixbuf *screenshot = user_data; gchar *save_uri; GError *error = NULL; save_uri = screenshot_build_filename_finish (res, &error); if (error != NULL) { g_critical ("Impossible to find a valid location to save the screenshot: %s", error->message); g_error_free (error); exit(1); } dialog = screenshot_dialog_new (screenshot, save_uri); toplevel = screenshot_dialog_get_toplevel (dialog); gtk_widget_show (toplevel); g_signal_connect (toplevel, "response", G_CALLBACK (screenshot_dialog_response_cb), dialog); g_free (save_uri); }
static void save_file_failed_error (ScreenshotDialog *dialog, GError *error) { GtkWidget *toplevel; GtkWidget *error_dialog; char *folder; toplevel = screenshot_dialog_get_toplevel (dialog); screenshot_dialog_set_busy (dialog, FALSE); /* we had an error, display a dialog to the user and let him choose * another name/location to save the screenshot. */ folder = screenshot_dialog_get_folder (dialog); error_dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error while saving screenshot")); /* translators: first %s is the folder URI, second %s is the VFS error */ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog), _("Impossible to save the screenshot " "to %s.\n Error was %s.\n Please choose another " "location and retry."), folder, error->message); gtk_widget_show (error_dialog); g_signal_connect (error_dialog, "response", G_CALLBACK (error_dialog_response_cb), dialog); g_free (folder); }
static void save_callback (TransferResult result, char *error_message, gpointer data) { ScreenshotDialog *dialog = data; GtkWidget *toplevel; toplevel = screenshot_dialog_get_toplevel (dialog); screenshot_dialog_set_busy (dialog, FALSE); if (result == TRANSFER_OK) { save_folder_to_gconf (dialog); set_recent_entry (dialog); gtk_widget_destroy (toplevel); /* we're done, stop the mainloop now */ gtk_main_quit (); } else if (result == TRANSFER_OVERWRITE || result == TRANSFER_CANCELLED) { /* user has canceled the overwrite dialog or the transfer itself, let him * choose another name. */ screenshot_dialog_focus_entry (dialog); } else /* result == TRANSFER_ERROR */ { /* we had an error, display a dialog to the user and let him choose * another name/location to save the screenshot. */ GtkWidget *error_dialog; char *uri; uri = screenshot_dialog_get_uri (dialog); error_dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error while saving screenshot"), NULL); /* translators: first %s is the file path, second %s is the VFS error */ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog), _("Impossible to save the screenshot " "to %s.\n Error was %s.\n Please choose another " "location and retry."), uri, error_message); gtk_widget_show (error_dialog); g_signal_connect (error_dialog, "response", G_CALLBACK (error_dialog_response_cb), dialog); g_free (uri); } }
static void run_dialog (ScreenshotDialog *dialog) { GtkWidget *toplevel; toplevel = screenshot_dialog_get_toplevel (dialog); gtk_widget_show (toplevel); g_signal_connect (toplevel, "response", G_CALLBACK (screenshot_dialog_response_cb), dialog); }
static void save_file_completed (ScreenshotDialog *dialog) { GtkWidget *toplevel; toplevel = screenshot_dialog_get_toplevel (dialog); save_folder_to_settings (dialog); set_recent_entry (dialog); gtk_widget_destroy (toplevel); /* we're done, stop the mainloop now */ gtk_main_quit (); }
static void save_done_notification (gpointer data) { ScreenshotDialog *dialog = data; temporary_file = g_strdup (screenshot_save_get_filename ()); screenshot_dialog_enable_dnd (dialog); if (save_immediately) { GtkWidget *toplevel; toplevel = screenshot_dialog_get_toplevel (dialog); gtk_dialog_response (GTK_DIALOG (toplevel), GTK_RESPONSE_OK); } }
static void try_to_save (ScreenshotDialog *dialog, const char *target) { GFile *source_file, *target_file; g_assert (temporary_file); screenshot_dialog_set_busy (dialog, TRUE); source_file = g_file_new_for_path (temporary_file); target_file = g_file_new_for_uri (target); screenshot_xfer_uri (source_file, target_file, screenshot_dialog_get_toplevel (dialog), save_callback, dialog); /* screenshot_xfer_uri () holds a ref, so we can unref now */ g_object_unref (source_file); g_object_unref (target_file); }