eog r4421 - in trunk: . src



Author: lucasr
Date: Mon Mar  3 19:10:26 2008
New Revision: 4421
URL: http://svn.gnome.org/viewvc/eog?rev=4421&view=rev

Log:
2008-03-03  Lucas Rocha  <lucasr gnome org>

	* configure.ac: update glib dependency to 2.15.3 version.
	* src/eog-window.c (move_to_trash_real): use gio to move file to trash
	in order to be compliant with FD.o Trash spec. Full gio migration will
	come on next cycle. Patch from Cosimo Cecchi <anarki lilik it>


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/eog-window.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Mon Mar  3 19:10:26 2008
@@ -78,7 +78,7 @@
 # **********
 
 GTK_REQUIRED=2.11.6
-GLIB_REQUIRED=2.12.0
+GLIB_REQUIRED=2.15.3
 GNOME_VFS_REQUIRED=2.10.0
 LIBGNOMEUI_REQUIRED=2.6.0
 LIBGLADE_REQUIRED=2.3.6
@@ -95,6 +95,7 @@
 EOG_MODULES="gtk+-2.0 >= $GTK_REQUIRED \
              glib-2.0 >= $GLIB_REQUIRED \
              gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED \
+             gio-2.0 >= $GLIB_REQUIRED \
              libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \
              libglade-2.0 >= $LIBGLADE_REQUIRED \
              gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED \

Modified: trunk/src/eog-window.c
==============================================================================
--- trunk/src/eog-window.c	(original)
+++ trunk/src/eog-window.c	Mon Mar  3 19:10:26 2008
@@ -60,6 +60,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
+#include <gio/gio.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
 #include <gtk/gtkprintunixdialog.h>
@@ -3028,62 +3029,53 @@
 static gboolean
 move_to_trash_real (EogImage *image, GError **error)
 {
-	GnomeVFSURI *uri;
-	GnomeVFSURI *trash_dir;
-	GnomeVFSURI *trash_uri;
-	gint result;
-	char *name;
+	GFile *file;
+        GnomeVFSURI *uri;
+        char *string_uri;
+	GFileInfo *file_info;
+	gboolean can_trash, result;
 
 	g_return_val_if_fail (EOG_IS_IMAGE (image), FALSE);
+        
+        uri = eog_image_get_uri (image);
+        string_uri = gnome_vfs_uri_to_string (uri,
+                                              GNOME_VFS_URI_HIDE_USER_NAME | 
+                                              GNOME_VFS_URI_HIDE_PASSWORD);
+	file = g_file_new_for_uri (string_uri);
+        g_free (string_uri);
+	file_info = g_file_query_info (file,
+				       G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH,
+				       0, NULL, NULL);
+	if (file_info == NULL) {
+		g_set_error (error, 
+			     EOG_WINDOW_ERROR, 
+			     EOG_WINDOW_ERROR_TRASH_NOT_FOUND,
+			     _("Couldn't access trash."));
+		return FALSE;
+	}
 
-	uri = eog_image_get_uri (image);
-
-        result = gnome_vfs_find_directory (uri,
-					   GNOME_VFS_DIRECTORY_KIND_TRASH,
-					   &trash_dir, 
-					   FALSE, 
-					   TRUE, 
-					   0700);
-
-	if (result != GNOME_VFS_OK) {
-
-		result = gnome_vfs_find_directory (uri,
-						   GNOME_VFS_DIRECTORY_KIND_TRASH,
-						   &trash_dir, 
-						   TRUE, 
-						   FALSE, 
-						   0700);
-
-		if (result != GNOME_VFS_OK) {
-			gnome_vfs_uri_unref (uri);
-
+	can_trash = g_file_info_get_attribute_boolean (file_info,
+						       G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH);
+	g_object_unref (file_info);
+	if (can_trash)
+	{
+		result = g_file_trash (file, NULL, NULL);
+		if (result == FALSE) {
 			g_set_error (error, 
 				     EOG_WINDOW_ERROR, 
 				     EOG_WINDOW_ERROR_TRASH_NOT_FOUND,
 				     _("Couldn't access trash."));
-
-			return FALSE;
 		}
-	}
-
-	name = gnome_vfs_uri_extract_short_name (uri);
-	trash_uri = gnome_vfs_uri_append_file_name (trash_dir, name);
-	g_free (name);
-
-	result = gnome_vfs_move_uri (uri, trash_uri, TRUE);
-
-	gnome_vfs_uri_unref (uri);
-	gnome_vfs_uri_unref (trash_uri);
-	gnome_vfs_uri_unref (trash_dir);
-
-	if (result != GNOME_VFS_OK) {
+	} else {
 		g_set_error (error, 
-			     EOG_WINDOW_ERROR,
-			     EOG_WINDOW_ERROR_UNKNOWN,
-			     gnome_vfs_result_to_string (result));
+			     EOG_WINDOW_ERROR, 
+			     EOG_WINDOW_ERROR_TRASH_NOT_FOUND,
+			     _("Couldn't access trash."));
 	}
+        
+        g_object_unref (file);
 
-	return (result == GNOME_VFS_OK);
+	return (can_trash ? result : FALSE);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]