gnome-utils r7973 - trunk/gnome-screenshot
- From: cosimoc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-utils r7973 - trunk/gnome-screenshot
- Date: Tue, 22 Jul 2008 15:00:11 +0000 (UTC)
Author: cosimoc
Date: Tue Jul 22 15:00:10 2008
New Revision: 7973
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=7973&view=rev
Log:
2008-07-22 Cosimo Cecchi <cosimoc gnome org>
* Makefile.am:
* gnome-screenshot.c: (error_dialog_response_cb), (save_callback),
(try_to_save), (screenshot_dialog_response_cb), (run_dialog),
(finish_prepare_screenshot), (check_file_done), (build_uri),
(try_check_file), (prepare_screenshot),
(prepare_screenshot_timeout), (expand_initial_tilde),
(load_options), (screenshooter_init_stock_icons), (main):
* screenshot-dialog.c: (screenshot_dialog_new),
(screenshot_dialog_focus_entry), (screenshot_dialog_get_uri):
* screenshot-dialog.h:
* screenshot-save.c: (screenshot_sanitize_filename):
* screenshot-shadow.c:
* screenshot-shadow.h:
* screenshot-xfer.c: (do_run_overwrite_confirm_dialog),
(transfer_dialog_response_cb), (transfer_progress_dialog_new),
(transfer_progress_dialog_start), (run_overwrite_confirm_dialog),
(transfer_progress_dialog_update), (transfer_job_done),
(transfer_progress_cb), (get_file_size), (transfer_file),
(screenshot_xfer_uri):
* screenshot-xfer.h:
Port gnome-screenshot to GIO, clean up some code and add licence
headers (#526834).
Modified:
trunk/gnome-screenshot/ChangeLog
trunk/gnome-screenshot/Makefile.am
trunk/gnome-screenshot/gnome-screenshot.c
trunk/gnome-screenshot/screenshot-dialog.c
trunk/gnome-screenshot/screenshot-dialog.h
trunk/gnome-screenshot/screenshot-save.c
trunk/gnome-screenshot/screenshot-shadow.c
trunk/gnome-screenshot/screenshot-shadow.h
trunk/gnome-screenshot/screenshot-xfer.c
trunk/gnome-screenshot/screenshot-xfer.h
Modified: trunk/gnome-screenshot/Makefile.am
==============================================================================
--- trunk/gnome-screenshot/Makefile.am (original)
+++ trunk/gnome-screenshot/Makefile.am Tue Jul 22 15:00:10 2008
@@ -29,9 +29,6 @@
screenshot-shadow.h \
screenshot-utils.c \
screenshot-utils.h \
- gnome-egg-xfer-dialog.c \
- gnome-egg-xfer-dialog.h \
- gnome-egg-xfer-dialog-icons.h \
screenshot-save.c \
screenshot-save.h \
screenshot-xfer.c \
Modified: trunk/gnome-screenshot/gnome-screenshot.c
==============================================================================
--- trunk/gnome-screenshot/gnome-screenshot.c (original)
+++ trunk/gnome-screenshot/gnome-screenshot.c Tue Jul 22 15:00:10 2008
@@ -2,6 +2,7 @@
*
* Copyright (C) 2001 Jonathan Blandford <jrb alum mit edu>
* Copyright (C) 2006 Emmanuele Bassi <ebassi gnome org>
+ * Copyright (C) 2008 Cosimo Cecchi <cosimoc gnome org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -37,9 +38,8 @@
#include <errno.h>
#include <locale.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gio/gio.h>
+#include <pwd.h>
#include <X11/Xutil.h>
#include "screenshot-shadow.h"
@@ -71,6 +71,21 @@
SCREENSHOT_EFFECT_BORDER
} ScreenshotEffectType;
+typedef enum
+{
+ TEST_LAST_DIR = 0,
+ TEST_DESKTOP = 1,
+ TEST_TMP = 2,
+} TestType;
+
+typedef struct
+{
+ char *base_uris[3];
+ char *retval;
+ int iteration;
+ TestType type;
+} AsyncExistenceJob;
+
static GdkPixbuf *screenshot = NULL;
/* Global variables*/
@@ -491,84 +506,6 @@
return retval;
}
-/* We assume that uri is valid and has been tested elsewhere
- */
-static char *
-generate_filename_for_uri (const char *uri)
-{
- char *retval;
- char *file_name;
- int i = 1;
-
- if (window_title)
- {
- /* translators: this is the name of the file that gets made up
- * with the screenshot if a specific window is taken */
- file_name = g_strdup_printf (_("Screenshot-%s.png"), window_title);
- }
- else
- {
- /* translators: this is the name of the file that gets made up
- * with the screenshot if the entire screen is taken */
- file_name = g_strdup (_("Screenshot.png"));
- }
-
- retval = g_build_filename (uri, file_name, NULL);
- g_free (file_name);
-
- do
- {
- GnomeVFSFileInfo *info;
- GnomeVFSResult result;
-
- info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info (retval, info,
- GNOME_VFS_FILE_INFO_DEFAULT |
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- gnome_vfs_file_info_unref (info);
-
- switch (result)
- {
- case GNOME_VFS_ERROR_NOT_FOUND:
- return retval;
- case GNOME_VFS_OK:
- g_free (retval);
- break;
- case GNOME_VFS_ERROR_PROTOCOL_ERROR:
- /* try again? I'm getting these errors sporadically */
- default:
- g_warning ("ERROR: %s:%s\n",
- retval,
- gnome_vfs_result_to_string (result));
- g_free (retval);
- return NULL;
- }
-
- /* We had a hit. We need to make a new file */
- if (window_title)
- {
- /* translators: this is the name of the file that gets
- * made up with the screenshot if a specific window is
- * taken */
- file_name = g_strdup_printf (_("Screenshot-%s-%d.png"),
- window_title, i);
- }
- else
- {
- /* translators: this is the name of the file that gets
- * made up with the screenshot if the entire screen is
- * taken */
- file_name = g_strdup_printf (_("Screenshot-%d.png"), i);
- }
-
- retval = g_build_filename (uri, file_name, NULL);
- g_free (file_name);
-
- i++;
- }
- while (TRUE);
-}
-
static void
save_folder_to_gconf (ScreenshotDialog *dialog)
{
@@ -586,37 +523,95 @@
g_object_unref (gconf_client);
}
-static gboolean
-try_to_save (ScreenshotDialog *dialog,
- const char *target)
+static void
+error_dialog_response_cb (GtkDialog *d,
+ gint response,
+ ScreenshotDialog *dialog)
{
- GnomeVFSResult result;
- GnomeVFSURI *source_uri;
- GnomeVFSURI *target_uri;
-
- g_assert (temporary_file);
-
- screenshot_dialog_set_busy (dialog, TRUE);
-
- source_uri = gnome_vfs_uri_new (temporary_file);
- target_uri = gnome_vfs_uri_new (target);
-
- result = screenshot_xfer_uri (source_uri,
- target_uri,
- screenshot_dialog_get_toplevel (dialog));
-
- gnome_vfs_uri_unref (source_uri);
- gnome_vfs_uri_unref (target_uri);
+ gtk_widget_destroy (GTK_WIDGET (d));
+
+ screenshot_dialog_focus_entry (dialog);
+}
+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 == GNOME_VFS_OK)
+ if (result == TRANSFER_OK)
{
save_folder_to_gconf (dialog);
- return TRUE;
+ 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);
- return FALSE;
+ g_free (uri);
+ }
+
+}
+
+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);
}
static void
@@ -637,54 +632,61 @@
}
static void
-run_dialog (ScreenshotDialog *dialog)
+screenshot_dialog_response_cb (GtkDialog *d,
+ gint response_id,
+ ScreenshotDialog *dialog)
{
- GtkWidget *toplevel;
- int result;
- int keep_going;
char *uri;
- toplevel = screenshot_dialog_get_toplevel (dialog);
-
- do
+ if (response_id == GTK_RESPONSE_HELP)
{
- keep_going = FALSE;
- result = gtk_dialog_run (GTK_DIALOG (toplevel));
- switch (result)
- {
- case GTK_RESPONSE_HELP:
- display_help (GTK_WINDOW (toplevel));
- keep_going = TRUE;
- break;
- case GTK_RESPONSE_OK:
- uri = screenshot_dialog_get_uri (dialog);
- if (temporary_file == NULL)
- {
- save_immediately = TRUE;
- screenshot_dialog_set_busy (dialog, TRUE);
- keep_going = TRUE;
- }
- else
- {
- /* We've saved the temporary file. Lets try to copy it to the
- * correct location */
- if (! try_to_save (dialog, uri))
- keep_going = TRUE;
- }
- break;
- default:
- break;
- }
+ display_help (GTK_WINDOW (d));
+ }
+ else if (response_id == GTK_RESPONSE_OK)
+ {
+ uri = screenshot_dialog_get_uri (dialog);
+ if (temporary_file == NULL)
+ {
+ save_immediately = TRUE;
+ screenshot_dialog_set_busy (dialog, TRUE);
+ }
+ else
+ {
+ /* we've saved the temporary file, lets try to copy it to the
+ * correct location.
+ */
+ try_to_save (dialog, uri);
+ }
+ g_free (uri);
+ }
+ else /* dialog was canceled */
+ {
+ gtk_widget_destroy (GTK_WIDGET (d));
+ gtk_main_quit ();
}
- while (keep_going);
}
+
static void
-prepare_screenshot (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
+finish_prepare_screenshot (char *initial_uri)
+{
ScreenshotDialog *dialog;
Window win;
- char *initial_uri;
if (!screenshot_grab_lock ())
exit (0);
@@ -739,41 +741,168 @@
exit (1);
}
+ dialog = screenshot_dialog_new (screenshot, initial_uri, take_window_shot);
+ g_free (initial_uri);
- /* If uri isn't local, we should do this async before taking the sshot */
- initial_uri = generate_filename_for_uri (last_save_dir);
- if (initial_uri == NULL)
- {
- gchar *desktop_dir;
+ screenshot_save_start (screenshot, save_done_notification, dialog);
- /* We failed to make a new name for the last save dir. We try again
- * with our Desktop directory.
- */
- desktop_dir = get_desktop_dir ();
- initial_uri = generate_filename_for_uri (desktop_dir);
- g_free (desktop_dir);
- }
+ run_dialog (dialog);
+}
+
+static gboolean
+check_file_done (gpointer user_data)
+{
+ char *retval;
+ AsyncExistenceJob *job = user_data;
+
+ retval = job->retval;
+ g_free (job->base_uris[1]);
+ g_slice_free (AsyncExistenceJob, job);
+
+ finish_prepare_screenshot (retval);
+
+ return FALSE;
+}
+
+static char *
+build_uri (AsyncExistenceJob *job)
+{
+ char *retval, *file_name;
- /* desperate fallback: /tmp */
- if (initial_uri == NULL)
+ if (window_title)
{
- const gchar *tmp_dir = g_get_tmp_dir ();
- initial_uri = generate_filename_for_uri (tmp_dir);
+ /* translators: this is the name of the file that gets made up
+ * with the screenshot if a specific window is taken */
+ if (job->iteration == 0)
+ {
+ file_name = g_strdup_printf (_("Screenshot-%s.png"), window_title);
+ }
+ else
+ {
+ /* translators: this is the name of the file that gets
+ * made up with the screenshot if a specific window is
+ * taken */
+ file_name = g_strdup_printf (_("Screenshot-%s-%d.png"),
+ window_title, job->iteration);
+ }
+ }
+ else
+ {
+ if (job->iteration == 0)
+ {
+ /* translators: this is the name of the file that gets made up
+ * with the screenshot if the entire screen is taken */
+ file_name = g_strdup (_("Screenshot.png"));
+ }
+ else
+ {
+ /* translators: this is the name of the file that gets
+ * made up with the screenshot if the entire screen is
+ * taken */
+ file_name = g_strdup_printf (_("Screenshot-%d.png"), job->iteration);
+ }
}
- dialog = screenshot_dialog_new (screenshot, initial_uri, take_window_shot);
- g_free (initial_uri);
+ retval = g_build_filename (job->base_uris[job->type], file_name, NULL);
+ g_free (file_name);
+
+ return retval;
+}
- screenshot_save_start (screenshot, save_done_notification, dialog);
+static gboolean
+try_check_file (GIOSchedulerJob *io_job,
+ GCancellable *cancellable,
+ gpointer data)
+{
+ AsyncExistenceJob *job = data;
+ GFile *file;
+ GFileInfo *info;
+ GError *error;
+ char *uri;
- run_dialog (dialog);
+retry:
+ error = NULL;
+ uri = build_uri (job);
+ file = g_file_new_for_uri (uri);
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_QUERY_INFO_NONE, cancellable, &error);
+ if (info != NULL)
+ {
+ /* file already exists, iterate again */
+ g_object_unref (info);
+ g_object_unref (file);
+ (job->iteration)++;
+ goto retry;
+ }
+ else
+ {
+ /* see the error to check whether the location is not accessible
+ * or the file does not exist.
+ */
+ if (error->code == G_IO_ERROR_NOT_FOUND)
+ {
+ job->retval = uri;
+ goto out;
+ }
+ else
+ {
+ /* another kind of error, assume this location is not
+ * accessible.
+ */
+ g_free (uri);
+ if (job->type == TEST_TMP)
+ {
+ job->retval = NULL;
+ goto out;
+ }
+ else
+ {
+ (job->type)++;
+ job->iteration = 0;
+
+ g_error_free (error);
+ g_object_unref (file);
+ goto retry;
+ }
+ }
+ }
+
+out:
+ g_error_free (error);
+ g_object_unref (file);
+
+ g_io_scheduler_job_send_to_mainloop_async (io_job,
+ check_file_done,
+ job,
+ NULL);
+ return FALSE;
+}
+
+static void
+prepare_screenshot (void)
+{
+ AsyncExistenceJob *job;
+
+ job = g_slice_new0 (AsyncExistenceJob);
+ job->base_uris[0] = last_save_dir;
+ /* we'll have to free this */
+ job->base_uris[1] = get_desktop_dir ();
+ job->base_uris[2] = (char *) g_get_tmp_dir ();
+ job->iteration = 0;
+ job->type = TEST_LAST_DIR;
+
+ g_io_scheduler_push_job (try_check_file,
+ job,
+ NULL,
+ 0, NULL);
+
}
static gboolean
prepare_screenshot_timeout (gpointer data)
{
- gtk_main_quit ();
prepare_screenshot ();
return FALSE;
@@ -801,6 +930,36 @@
return desktop_dir;
}
+/* Taken from gnome-vfs-utils.c */
+static char *
+expand_initial_tilde (const char *path)
+{
+ char *slash_after_user_name, *user_name;
+ struct passwd *passwd_file_entry;
+
+ if (path[1] == '/' || path[1] == '\0') {
+ return g_strconcat (g_get_home_dir (), &path[1], NULL);
+ }
+
+ slash_after_user_name = strchr (&path[1], '/');
+ if (slash_after_user_name == NULL) {
+ user_name = g_strdup (&path[1]);
+ } else {
+ user_name = g_strndup (&path[1],
+ slash_after_user_name - &path[1]);
+ }
+ passwd_file_entry = getpwnam (user_name);
+ g_free (user_name);
+
+ if (passwd_file_entry == NULL || passwd_file_entry->pw_dir == NULL) {
+ return g_strdup (path);
+ }
+
+ return g_strconcat (passwd_file_entry->pw_dir,
+ slash_after_user_name,
+ NULL);
+}
+
/* Load options */
static void
load_options (void)
@@ -823,7 +982,7 @@
}
else if (last_save_dir[0] == '~')
{
- char *tmp = gnome_vfs_expand_initial_tilde (last_save_dir);
+ char *tmp = expand_initial_tilde (last_save_dir);
g_free (last_save_dir);
last_save_dir = tmp;
}
@@ -865,12 +1024,8 @@
static void
screenshooter_init_stock_icons (void)
{
- GtkIconFactory * factory;
- GtkIconSize screenshooter_icon_size;
+ GtkIconFactory *factory;
- screenshooter_icon_size = gtk_icon_size_register ("panel-menu",
- GTK_ICON_SIZE_DIALOG,
- GTK_ICON_SIZE_DIALOG);
factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory);
@@ -916,8 +1071,6 @@
g_option_context_set_help_enabled (context, TRUE);
g_option_context_set_main_group (context, group);
- gnome_authentication_manager_init ();
-
program = gnome_program_init ("gnome-screenshot", VERSION,
LIBGNOMEUI_MODULE,
argc, argv,
@@ -974,13 +1127,15 @@
g_timeout_add (delay * 1000,
prepare_screenshot_timeout,
NULL);
- gtk_main ();
}
else
{
- prepare_screenshot ();
+ /* start this in an idle anyway and fire up the mainloop */
+ g_idle_add (prepare_screenshot_timeout, NULL);
}
+ gtk_main ();
+
g_object_unref (program);
return EXIT_SUCCESS;
Modified: trunk/gnome-screenshot/screenshot-dialog.c
==============================================================================
--- trunk/gnome-screenshot/screenshot-dialog.c (original)
+++ trunk/gnome-screenshot/screenshot-dialog.c Tue Jul 22 15:00:10 2008
@@ -1,14 +1,32 @@
+/* screenshot-dialog.c - main GNOME Screenshot dialog
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include "screenshot-dialog.h"
#include "screenshot-save.h"
-#include <libgnomevfs/gnome-vfs.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
enum {
TYPE_IMAGE_PNG,
@@ -195,16 +213,16 @@
char *current_name;
char *ext;
gint pos;
- GnomeVFSURI *tmp_uri;
- GnomeVFSURI *parent_uri;
+ GFile *tmp_file;
+ GFile *parent_file;
- tmp_uri = gnome_vfs_uri_new (initial_uri);
- parent_uri = gnome_vfs_uri_get_parent (tmp_uri);
+ tmp_file = g_file_new_for_uri (initial_uri);
+ parent_file = g_file_get_parent (tmp_file);
- current_name = gnome_vfs_uri_extract_short_name (tmp_uri);
- current_folder = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (tmp_uri);
- gnome_vfs_uri_unref (parent_uri);
+ current_name = g_file_get_basename (tmp_file);
+ current_folder = g_file_get_uri (parent_file);
+ g_object_unref (tmp_file);
+ g_object_unref (parent_file);
dialog = g_new0 (ScreenshotDialog, 1);
@@ -287,6 +305,12 @@
}
void
+screenshot_dialog_focus_entry (ScreenshotDialog *dialog)
+{
+ gtk_widget_grab_focus (dialog->filename_entry);
+}
+
+void
screenshot_dialog_enable_dnd (ScreenshotDialog *dialog)
{
GtkWidget *preview_darea;
@@ -329,7 +353,7 @@
tmp = g_strdup (_("Screenshot.png"));
}
- file = gnome_vfs_escape_host_and_path_string (tmp);
+ file = g_uri_escape_string (tmp, NULL, FALSE);
uri = g_build_filename (folder, file, NULL);
g_free (folder);
Modified: trunk/gnome-screenshot/screenshot-dialog.h
==============================================================================
--- trunk/gnome-screenshot/screenshot-dialog.h (original)
+++ trunk/gnome-screenshot/screenshot-dialog.h Tue Jul 22 15:00:10 2008
@@ -1,3 +1,22 @@
+/* screenshot-dialog.h - main GNOME Screenshot dialog
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
#ifndef __SCREENSHOT_DIALOG_H__
#define __SCREENSHOT_DIALOG_H__
@@ -15,4 +34,5 @@
char *screenshot_dialog_get_folder (ScreenshotDialog *dialog);
void screenshot_dialog_set_busy (ScreenshotDialog *dialog,
gboolean busy);
+void screenshot_dialog_focus_entry (ScreenshotDialog *dialog);
#endif /* __SCREENSHOT_DIALOG_H__ */
Modified: trunk/gnome-screenshot/screenshot-save.c
==============================================================================
--- trunk/gnome-screenshot/screenshot-save.c (original)
+++ trunk/gnome-screenshot/screenshot-save.c Tue Jul 22 15:00:10 2008
@@ -18,12 +18,12 @@
*/
#include <config.h>
-#include <gnome.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "screenshot-save.h"
@@ -271,7 +271,9 @@
g_assert (filename);
g_assert (g_utf8_validate (filename, -1, NULL));
- retval = gnome_vfs_escape_host_and_path_string (filename);
+ retval = g_uri_escape_string (filename,
+ NULL,
+ TRUE);
for (p = retval; *p != '\000'; p = g_utf8_next_char (p))
{
Modified: trunk/gnome-screenshot/screenshot-shadow.c
==============================================================================
--- trunk/gnome-screenshot/screenshot-shadow.c (original)
+++ trunk/gnome-screenshot/screenshot-shadow.c Tue Jul 22 15:00:10 2008
@@ -1,3 +1,22 @@
+/* screenshot-shadow.c - part of GNOME Screenshot
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
/* Shadow code from anders */
#include "screenshot-shadow.h"
Modified: trunk/gnome-screenshot/screenshot-shadow.h
==============================================================================
--- trunk/gnome-screenshot/screenshot-shadow.h (original)
+++ trunk/gnome-screenshot/screenshot-shadow.h Tue Jul 22 15:00:10 2008
@@ -1,3 +1,22 @@
+/* screenshot-shadow.h - part of GNOME Screenshot
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
#ifndef __SCREENSHOT_SHADOW_H__
#define __SCREENSHOT_SHADOW_H__
Modified: trunk/gnome-screenshot/screenshot-xfer.c
==============================================================================
--- trunk/gnome-screenshot/screenshot-xfer.c (original)
+++ trunk/gnome-screenshot/screenshot-xfer.c Tue Jul 22 15:00:10 2008
@@ -1,189 +1,82 @@
+/* screenshot-xfer.c - file transfer functions for GNOME Screenshot
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ * Copyright (C) 2008 Cosimo Cecchi <cosimoc gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
#include "config.h"
#include "screenshot-xfer.h"
-#include "gnome-egg-xfer-dialog.h"
#include <time.h>
#include <glib/gi18n.h>
typedef struct
{
- GnomeVFSAsyncHandle *handle;
- const char *operation_title; /* "Copying files" */
- const char *action_label; /* "Files copied:" */
- const char *progress_verb; /* "Copying" */
- const char *preparation_name; /* "Preparing To Copy..." */
- const char *cleanup_name; /* "Finishing Move..." */
- GtkWidget *parent_dialog;
- GtkWidget *progress_dialog;
- gboolean delete_target;
- guint timeout_id;
- gboolean canceled;
-} TransferInfo;
-
-static gboolean show_dialog_timeout (TransferInfo *transfer_info);
-
-static void
-remove_timeout (TransferInfo *transfer_info)
-{
- g_assert (transfer_info);
-
- if (transfer_info->timeout_id)
- {
- g_source_remove (transfer_info->timeout_id);
- transfer_info->timeout_id = 0;
- }
-}
-
-static void
-add_timeout (TransferInfo *transfer_info)
-{
- if (transfer_info->timeout_id == 0)
- transfer_info->timeout_id = g_timeout_add (1000, (GSourceFunc) show_dialog_timeout, transfer_info);
-}
+ GtkWidget *dialog;
+ GtkWidget *progress_bar;
+ GCancellable *cancellable;
+} TransferDialog;
-static GtkWidget *
-transfer_info_get_parent (TransferInfo *transfer_info)
+typedef struct
{
- g_assert (transfer_info);
+ GFile *source;
+ GFile *dest;
+ GFileCopyFlags flags;
+ TransferCallback callback;
+ gpointer callback_data;
+ GCancellable *cancellable;
+ GtkWidget *parent;
+ TransferDialog *dialog;
+ TransferResult result;
+ GIOSchedulerJob *io_job;
+ char *error;
+ gint dialog_timeout_id;
+ goffset total_bytes;
+ goffset current_bytes;
+} TransferJob;
- if (transfer_info->progress_dialog)
- return transfer_info->progress_dialog;
- if (transfer_info->parent_dialog)
- return transfer_info->parent_dialog;
- return NULL;
-}
-
-static int
-handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+typedef struct
{
- if (transfer_info->canceled
- && progress_info->phase != GNOME_VFS_XFER_PHASE_COMPLETED)
- {
- /* If cancelled, delete any partially copied files that are laying
- * around and return. Don't delete the source though..
- */
- if (progress_info->target_name != NULL
- && progress_info->source_name != NULL
- && strcmp (progress_info->source_name, progress_info->target_name) != 0
- && progress_info->bytes_total != progress_info->bytes_copied)
- {
- transfer_info->delete_target = TRUE;
- }
-
- gtk_main_quit ();
- return 0;
- }
-
- if (progress_info->phase == GNOME_VFS_XFER_PHASE_COMPLETED)
- {
- remove_timeout (transfer_info);
- if (transfer_info->progress_dialog)
- {
- gtk_widget_destroy (transfer_info->progress_dialog);
- transfer_info->progress_dialog = NULL;
- }
- gtk_main_quit ();
- return 0;
- }
-
- /* Update the dialog, if need be */
- if (transfer_info->progress_dialog == NULL)
- return 1;
-
- switch (progress_info->phase)
- {
- /* Initial phase */
- case GNOME_VFS_XFER_PHASE_INITIAL:
- /* Checking if destination can handle move/copy */
- return 1;
- case GNOME_VFS_XFER_PHASE_COLLECTING:
- case GNOME_VFS_XFER_CHECKING_DESTINATION:
- gnome_egg_xfer_dialog_set_operation_string (GNOME_EGG_XFER_DIALOG (transfer_info->progress_dialog),
- _("Preparing to copy"));
- return 1;
- case GNOME_VFS_XFER_PHASE_READYTOGO:
- gnome_egg_xfer_dialog_set_operation_string
- (GNOME_EGG_XFER_DIALOG (transfer_info->progress_dialog),
- transfer_info->action_label);
- gnome_egg_xfer_dialog_set_total
- (GNOME_EGG_XFER_DIALOG (transfer_info->progress_dialog),
- progress_info->files_total,
- progress_info->bytes_total);
- return 1;
- case GNOME_VFS_XFER_PHASE_OPENSOURCE:
- case GNOME_VFS_XFER_PHASE_OPENTARGET:
- case GNOME_VFS_XFER_PHASE_COPYING:
- case GNOME_VFS_XFER_PHASE_WRITETARGET:
- case GNOME_VFS_XFER_PHASE_CLOSETARGET:
- if (progress_info->bytes_copied == 0)
- {
- }
- else
- {
- gnome_egg_xfer_dialog_update_sizes
- (GNOME_EGG_XFER_DIALOG (transfer_info->progress_dialog),
- MIN (progress_info->bytes_copied,
- progress_info->bytes_total),
- MIN (progress_info->total_bytes_copied,
- progress_info->bytes_total));
- }
- return 1;
- case GNOME_VFS_XFER_PHASE_FILECOMPLETED:
- case GNOME_VFS_XFER_PHASE_CLEANUP:
- return 1;
- /* Phases we don't expect to see */
- case GNOME_VFS_XFER_PHASE_COMPLETED:
- case GNOME_VFS_XFER_PHASE_SETATTRIBUTES:
- case GNOME_VFS_XFER_PHASE_CLOSESOURCE:
- case GNOME_VFS_XFER_PHASE_MOVING:
- case GNOME_VFS_XFER_PHASE_DELETESOURCE:
- case GNOME_VFS_XFER_PHASE_READSOURCE:
- default:
- g_print ("Unexpected phase (%d) hit\n", progress_info->phase);
- g_assert_not_reached ();
- return 0;
- }
- return 1;
-}
+ int resp;
+ GtkWidget *parent;
+ char *basename;
+} ErrorDialogData;
-static gint
-handle_transfer_vfs_error (GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
-{
- g_print ("handle_transfer_vfs_error!\n");
- remove_timeout (transfer_info);
- if (transfer_info->progress_dialog)
- {
- gtk_widget_destroy (transfer_info->progress_dialog);
- transfer_info->progress_dialog = NULL;
- }
- gtk_main_quit ();
- return 1;
-}
+static goffset total_size = 0;
-static int
-handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+static gboolean
+do_run_overwrite_confirm_dialog (gpointer _data)
{
+ ErrorDialogData *data = _data;
GtkWidget *dialog;
gint response;
- gint need_timeout;
-
- need_timeout = (transfer_info->timeout_id > 0);
- remove_timeout (transfer_info);
- /* We need to ask the user if they want to overrwrite this file */
- dialog = gtk_message_dialog_new (GTK_WINDOW (transfer_info_get_parent (transfer_info)),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ /* we need to ask the user if they want to overwrite this file */
+ dialog = gtk_message_dialog_new (GTK_WINDOW (data->parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
_("File already exists"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("The file \"%s\" already exists. Would you like to replace it?"),
- progress_info->target_name);
+ _("The file \"%s\" already exists. "
+ "Would you like to replace it?"),
+ data->basename);
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
@@ -193,91 +86,312 @@
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_OK)
- return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
- else
- return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
- if (need_timeout)
- add_timeout (transfer_info);
+ data->resp = response;
+
+ return FALSE;
+}
+
+static void
+transfer_dialog_response_cb (GtkDialog *d,
+ gint response,
+ GCancellable *cancellable)
+{
+ if (response == GTK_RESPONSE_CANCEL)
+ {
+ if (!g_cancellable_is_cancelled (cancellable))
+ {
+ g_cancellable_cancel (cancellable);
+ }
+ }
}
-static gint
-handle_transfer_duplicate (GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+static gboolean
+transfer_progress_dialog_new (TransferJob *job)
+{
+ TransferDialog *dialog;
+ GtkWidget *gdialog;
+ GtkWidget *widget;
+
+ dialog = g_new0 (TransferDialog, 1);
+
+ gdialog = gtk_message_dialog_new (GTK_WINDOW (job->parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_OTHER,
+ GTK_BUTTONS_CANCEL,
+ _("Saving file..."),
+ NULL);
+ widget = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (GTK_MESSAGE_DIALOG (gdialog)->label->parent),
+ widget, FALSE, 0, 0);
+ gtk_widget_show (widget);
+ dialog->progress_bar = widget;
+ dialog->dialog = gdialog;
+
+ g_signal_connect (gdialog,
+ "response",
+ G_CALLBACK (transfer_dialog_response_cb),
+ job->cancellable);
+
+ job->dialog = dialog;
+ gtk_widget_show (gdialog);
+
+ return FALSE;
+}
+
+static void
+transfer_progress_dialog_start (TransferJob *job)
{
- g_print ("handle_transfer_duplicate!\n");
- return 1;
+ /* sends to the mainloop and schedules show */
+ if (job->dialog_timeout_id == 0)
+ job->dialog_timeout_id = g_timeout_add_seconds (1,
+ (GSourceFunc) transfer_progress_dialog_new,
+ job);
}
-static gint
-screenshot_async_xfer_progress (GnomeVFSAsyncHandle *handle,
- GnomeVFSXferProgressInfo *progress_info,
- gpointer data)
+static int
+run_overwrite_confirm_dialog (TransferJob *job)
{
- TransferInfo *transfer_info = data;
+ ErrorDialogData *data;
+ gboolean need_timeout;
+ int response;
+ char *basename;
+
+ basename = g_file_get_basename (job->dest);
+
+ data = g_slice_new0 (ErrorDialogData);
+ data->parent = job->parent;
+ data->basename = basename;
- switch (progress_info->status)
+ need_timeout = (job->dialog_timeout_id > 0);
+
+ if (need_timeout)
{
- case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
- return handle_transfer_ok (progress_info, transfer_info);
- case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
- return handle_transfer_vfs_error (progress_info, transfer_info);
- case GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE:
- return handle_transfer_overwrite (progress_info, transfer_info);
- case GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE:
- return handle_transfer_duplicate (progress_info, transfer_info);
- default:
- g_warning (_("Unknown GnomeVFSXferProgressStatus %d"),
- progress_info->status);
- return 0;
- }
+ g_source_remove (job->dialog_timeout_id);
+ job->dialog_timeout_id = 0;
+ }
+
+ g_io_scheduler_job_send_to_mainloop (job->io_job,
+ do_run_overwrite_confirm_dialog,
+ data,
+ NULL);
+ response = data->resp;
+
+ if (need_timeout)
+ transfer_progress_dialog_start (job);
+
+ g_free (basename);
+ g_slice_free (ErrorDialogData, data);
+
+ return response;
}
static gboolean
-show_dialog_timeout (TransferInfo *transfer_info)
+transfer_progress_dialog_update (TransferJob *job)
{
- transfer_info->progress_dialog =
- gnome_egg_xfer_dialog_new (NULL, NULL, NULL, NULL, 0, 0, FALSE);
- gtk_widget_show (transfer_info->progress_dialog);
- transfer_info->timeout_id = 0;
+ TransferDialog *dialog = job->dialog;
+ double fraction;
+
+ fraction = ((double) job->current_bytes) / ((double) job->total_bytes);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (dialog->progress_bar),
+ fraction);
+
+ return FALSE;
+}
+static gboolean
+transfer_job_done (gpointer user_data)
+{
+ TransferJob *job = user_data;
+ TransferDialog *dialog;
+
+ dialog = job->dialog;
+
+ if (job->dialog_timeout_id)
+ {
+ g_source_remove (job->dialog_timeout_id);
+ job->dialog_timeout_id = 0;
+ }
+ if (dialog)
+ gtk_widget_destroy (dialog->dialog);
+
+ if (job->callback)
+ {
+ (job->callback) (job->result,
+ job->error,
+ job->callback_data);
+ }
+
+ g_object_unref (job->source);
+ g_object_unref (job->dest);
+ g_object_unref (job->cancellable);
+
+ g_free (dialog);
+ g_free (job->error);
+ g_slice_free (TransferJob, job);
+
return FALSE;
}
-GnomeVFSResult
-screenshot_xfer_uri (GnomeVFSURI *source_uri,
- GnomeVFSURI *target_uri,
- GtkWidget *parent)
-{
- GnomeVFSResult result;
- GList *source_uri_list = NULL;
- GList *target_uri_list = NULL;
- TransferInfo *transfer_info;
-
- source_uri_list = g_list_prepend (source_uri_list, source_uri);
- target_uri_list = g_list_prepend (target_uri_list, target_uri);
-
- transfer_info = g_new0 (TransferInfo, 1);
- transfer_info->parent_dialog = parent;
- add_timeout (transfer_info);
-
- result = gnome_vfs_async_xfer (&transfer_info->handle,
- source_uri_list, target_uri_list,
- GNOME_VFS_XFER_DEFAULT,
- GNOME_VFS_XFER_ERROR_MODE_QUERY,
- GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
- GNOME_VFS_PRIORITY_DEFAULT,
- screenshot_async_xfer_progress, transfer_info,
- NULL, NULL);
- gtk_main ();
- remove_timeout (transfer_info);
- g_list_free (source_uri_list);
- g_list_free (target_uri_list);
+static void
+transfer_progress_cb (goffset current_num_bytes,
+ goffset total_num_bytes,
+ TransferJob *job)
+{
+ job->current_bytes = current_num_bytes;
+
+ if (!job->dialog)
+ return;
+
+ g_io_scheduler_job_send_to_mainloop_async (job->io_job,
+ (GSourceFunc) transfer_progress_dialog_update,
+ job,
+ NULL);
+}
+
+static goffset
+get_file_size (GFile *file)
+{
+ GFileInfo *file_info;
+ goffset size;
+
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ 0, NULL, NULL);
+ if (file_info != NULL)
+ {
+ size = g_file_info_get_size (file_info);
+ g_object_unref (file_info);
+ }
+ else
+ {
+ /* this should never fail as the source file is always local and in /tmp,
+ * but you never know.
+ */
+ size = -1;
+ }
+
+ return size;
+}
+
+static gboolean
+transfer_file (GIOSchedulerJob *io_job,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ TransferJob *job = user_data;
+ GError *error;
+ gboolean result;
+
+ job->io_job = io_job;
+ job->total_bytes = get_file_size (job->source);
+ if (job->total_bytes == -1)
+ {
+ /* we can't access the source file, abort early */
+ error = NULL;
+ job->result = TRANSFER_ERROR;
+ job->error = g_strdup (_("Can't access source file"));
+
+ goto out;
+ }
+
+ transfer_progress_dialog_start (job);
+
+retry:
+ error = NULL;
+ if (!g_file_copy (job->source,
+ job->dest,
+ job->flags,
+ job->cancellable,
+ (GFileProgressCallback) transfer_progress_cb,
+ job,
+ &error))
+ {
+ if (error->code == G_IO_ERROR_EXISTS)
+ {
+ int response;
+ /* ask the user if he wants to overwrite, otherwise
+ * return and report what happened.
+ */
+ response = run_overwrite_confirm_dialog (job);
+ if (response == GTK_RESPONSE_OK)
+ {
+ job->flags |= G_FILE_COPY_OVERWRITE;
+ g_error_free (error);
+
+ goto retry;
+ }
+ else
+ {
+ g_cancellable_cancel (job->cancellable);
+ job->result = TRANSFER_OVERWRITE;
+ goto out;
+ }
+ }
+ else if (error->code == G_IO_ERROR_CANCELLED)
+ {
+ job->result = TRANSFER_CANCELLED;
+
+ goto out;
+ }
+ else
+ {
+ /* other vfs error, abort the transfer and report
+ * the error.
+ */
+ g_cancellable_cancel (job->cancellable);
+ job->result = TRANSFER_ERROR;
+ job->error = g_strdup (error->message);
+
+ goto out;
+ }
+ }
+ else
+ {
+ /* success */
+ job->result = TRANSFER_OK;
+
+ goto out;
+ }
- if (transfer_info->delete_target)
- ;/* try to delete the target, iff it started writing */
+out:
+ if (error)
+ g_error_free (error);
+
+ g_io_scheduler_job_send_to_mainloop_async (io_job,
+ transfer_job_done,
+ job,
+ NULL);
+ return FALSE;
+}
- return GNOME_VFS_OK;
+void
+screenshot_xfer_uri (GFile *source_file,
+ GFile *target_file,
+ GtkWidget *parent,
+ TransferCallback done_callback,
+ gpointer done_callback_data)
+{
+ TransferJob *job;
+ GCancellable *cancellable;
+
+ cancellable = g_cancellable_new ();
+
+ job = g_slice_new0 (TransferJob);
+ job->parent = parent;
+ job->source = g_object_ref (source_file);
+ job->dest = g_object_ref (target_file);
+ job->flags = 0;
+ job->error = NULL;
+ job->dialog = NULL;
+ job->callback = done_callback;
+ job->callback_data = done_callback_data;
+ job->cancellable = cancellable;
+
+ g_io_scheduler_push_job (transfer_file,
+ job,
+ NULL, 0,
+ job->cancellable);
}
Modified: trunk/gnome-screenshot/screenshot-xfer.h
==============================================================================
--- trunk/gnome-screenshot/screenshot-xfer.h (original)
+++ trunk/gnome-screenshot/screenshot-xfer.h Tue Jul 22 15:00:10 2008
@@ -1,11 +1,45 @@
+/* screenshot-xfer.h - file transfer functions for GNOME Screenshot
+ *
+ * Copyright (C) 2001-2006 Jonathan Blandford <jrb alum mit edu>
+ * Copyright (C) 2008 Cosimo Cecchi <cosimoc gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ */
+
#ifndef __SCREENSHOT_XFER_H__
#define __SCREENSHOT_XFER_H__
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
+
+typedef enum
+{
+ TRANSFER_OK,
+ TRANSFER_OVERWRITE,
+ TRANSFER_CANCELLED,
+ TRANSFER_ERROR
+} TransferResult;
+
+typedef void (* TransferCallback) (TransferResult result,
+ char *error_message,
+ gpointer data);
-GnomeVFSResult screenshot_xfer_uri (GnomeVFSURI *source_uri,
- GnomeVFSURI *target_uri,
- GtkWidget *parent);
+void screenshot_xfer_uri (GFile *source_file,
+ GFile *target_file,
+ GtkWidget *parent,
+ TransferCallback done_callback,
+ gpointer done_callback_data);
#endif /* __SCREENSHOT_XFER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]