[Xfce4-commits] <xfdesktop:jannis/port-to-gio> Use GFile lists instead of ThunarVfsPath lists in a few places.

Jannis Pohlmann noreply at xfce.org
Sun Oct 17 19:34:02 CEST 2010


Updating branch refs/heads/jannis/port-to-gio
         to e6e45d73bf0c89d7048203848babc33e4afc6e79 (commit)
       from d6fcc540bf3c942e165fcf097b1da3ad5d72d351 (commit)

commit e6e45d73bf0c89d7048203848babc33e4afc6e79
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Sun Oct 17 19:31:29 2010 +0200

    Use GFile lists instead of ThunarVfsPath lists in a few places.

 src/xfdesktop-clipboard-manager.c |   79 ++++++++++++++++++-------------------
 src/xfdesktop-clipboard-manager.h |   31 +++++++-------
 src/xfdesktop-file-icon-manager.c |    9 ++--
 src/xfdesktop-file-utils.c        |   44 ++++++++++++++++----
 src/xfdesktop-file-utils.h        |    4 +-
 5 files changed, 97 insertions(+), 70 deletions(-)

diff --git a/src/xfdesktop-clipboard-manager.c b/src/xfdesktop-clipboard-manager.c
index eb08ca7..1718a7f 100644
--- a/src/xfdesktop-clipboard-manager.c
+++ b/src/xfdesktop-clipboard-manager.c
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2010      Jannis Pohlmann <jannis at xfce.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
@@ -30,11 +31,9 @@
 #include <string.h>
 #endif
 
-#include <gtk/gtk.h>
+#include <gio/gio.h>
 
-#ifdef HAVE_THUNAR_VFS
-#include <thunar-vfs/thunar-vfs.h>
-#endif
+#include <gtk/gtk.h>
 
 #include "xfdesktop-clipboard-manager.h"
 #include "xfdesktop-file-icon.h"
@@ -66,36 +65,36 @@ enum
 
 
 
-static void xfdesktop_clipboard_manager_class_init         (XfdesktopClipboardManagerClass *klass);
-static void xfdesktop_clipboard_manager_init               (XfdesktopClipboardManager      *manager);
-static void xfdesktop_clipboard_manager_finalize           (GObject                        *object);
-static void xfdesktop_clipboard_manager_get_property       (GObject *object,
-                                                            guint prop_id,
-                                                            GValue *value,
-                                                            GParamSpec *pspec);
+static void xfdesktop_clipboard_manager_class_init        (XfdesktopClipboardManagerClass *klass);
+static void xfdesktop_clipboard_manager_init              (XfdesktopClipboardManager      *manager);
+static void xfdesktop_clipboard_manager_finalize          (GObject                        *object);
+static void xfdesktop_clipboard_manager_get_property      (GObject                        *object,
+                                                           guint                           prop_id,
+                                                           GValue                         *value,
+                                                           GParamSpec                     *pspec);
 
-static void xfdesktop_clipboard_manager_file_destroyed     (XfdesktopClipboardManager      *manager,
-                                                            XfdesktopFileIcon              *file);
-static void xfdesktop_clipboard_manager_owner_changed      (GtkClipboard                   *clipboard,
-                                                            GdkEventOwnerChange            *event,
-                                                            XfdesktopClipboardManager      *manager);
+static void xfdesktop_clipboard_manager_file_destroyed    (XfdesktopClipboardManager      *manager,
+                                                           XfdesktopFileIcon              *file);
+static void xfdesktop_clipboard_manager_owner_changed     (GtkClipboard                   *clipboard,
+                                                           GdkEventOwnerChange            *event,
+                                                           XfdesktopClipboardManager      *manager);
 #if 0
-static void xfdesktop_clipboard_manager_contents_received  (GtkClipboard *clipboard,
-                                                            GtkSelectionData *selection_data,
-                                                            gpointer user_data);
+static void xfdesktop_clipboard_manager_contents_received (GtkClipboard                   *clipboard,
+                                                           GtkSelectionData               *selection_data,
+                                                           gpointer                        user_data);
 #endif
-static void xfdesktop_clipboard_manager_targets_received   (GtkClipboard                   *clipboard,
-                                                            GtkSelectionData               *selection_data,
-                                                            gpointer                        user_data);
-static void xfdesktop_clipboard_manager_get_callback       (GtkClipboard                   *clipboard,
-                                                            GtkSelectionData               *selection_data,
-                                                            guint                           info,
-                                                            gpointer                        user_data);
-static void xfdesktop_clipboard_manager_clear_callback     (GtkClipboard                   *clipboard,
-                                                            gpointer                        user_data);
-static void xfdesktop_clipboard_manager_transfer_files     (XfdesktopClipboardManager      *manager,
-                                                            gboolean                        copy,
-                                                            GList                          *files);
+static void xfdesktop_clipboard_manager_targets_received  (GtkClipboard                   *clipboard,
+                                                           GtkSelectionData               *selection_data,
+                                                           gpointer                        user_data);
+static void xfdesktop_clipboard_manager_get_callback      (GtkClipboard                   *clipboard,
+                                                           GtkSelectionData               *selection_data,
+                                                           guint                           info,
+                                                           gpointer                        user_data);
+static void xfdesktop_clipboard_manager_clear_callback    (GtkClipboard                   *clipboard,
+                                                           gpointer                        user_data);
+static void xfdesktop_clipboard_manager_transfer_files    (XfdesktopClipboardManager      *manager,
+                                                           gboolean                        copy,
+                                                           GList                          *files);
 
 
 
@@ -121,9 +120,9 @@ struct _XfdesktopClipboardManager
 typedef struct
 {
   XfdesktopClipboardManager *manager;
-  ThunarVfsPath          *target_path;
-  GtkWidget              *widget;
-  GClosure               *new_files_closure;
+  GFile                     *target_file;
+  GtkWidget                 *widget;
+  GClosure                  *new_files_closure;
   XfdesktopFileIconManager *fmanager;
 } XfdesktopClipboardPasteRequest;
 
@@ -437,7 +436,7 @@ xfdesktop_clipboard_manager_get_callback (GtkClipboard     *clipboard,
                                           gpointer          user_data)
 {
   XfdesktopClipboardManager *manager = XFDESKTOP_CLIPBOARD_MANAGER (user_data);
-  GList                  *path_list = NULL;
+  GList                  *file_list = NULL;
   gchar                  *string_list;
   gchar                  *data;
 
@@ -445,11 +444,11 @@ xfdesktop_clipboard_manager_get_callback (GtkClipboard     *clipboard,
   g_return_if_fail (XFDESKTOP_IS_CLIPBOARD_MANAGER (manager));
   g_return_if_fail (manager->clipboard == clipboard);
 
-  /* determine the path list from the file list */
-  path_list = xfdesktop_file_utils_file_icon_list_to_path_list(manager->files);
+  /* determine the file list from the icon list */
+  file_list = xfdesktop_file_utils_file_icon_list_to_file_list (manager->files);
 
-  /* determine the string representation of the path list */
-  string_list = thunar_vfs_path_list_to_string (path_list);
+  /* determine the string representation of the file list */
+  string_list = xfdesktop_file_utils_file_list_to_string (file_list);
 
   switch (target_info)
     {
@@ -468,7 +467,7 @@ xfdesktop_clipboard_manager_get_callback (GtkClipboard     *clipboard,
     }
 
   /* cleanup */
-  thunar_vfs_path_list_free (path_list);
+  xfdesktop_file_utils_file_list_free (file_list);
   g_free (string_list);
 }
 
diff --git a/src/xfdesktop-clipboard-manager.h b/src/xfdesktop-clipboard-manager.h
index f29659b..0b268ad 100644
--- a/src/xfdesktop-clipboard-manager.h
+++ b/src/xfdesktop-clipboard-manager.h
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2010 Jannis Pohlmann <jannis at xfce.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
@@ -22,9 +23,7 @@
 #ifndef __XFDESKTOP_CLIPBOARD_MANAGER_H__
 #define __XFDESKTOP_CLIPBOARD_MANAGER_H__
 
-#ifdef HAVE_THUNAR_VFS
-#include <thunar-vfs/thunar-vfs.h>
-#endif
+#include <gio/gio.h>
 
 G_BEGIN_DECLS;
 
@@ -41,23 +40,23 @@ typedef struct _XfdesktopClipboardManager      XfdesktopClipboardManager;
 #define XFDESKTOP_IS_CLIPBAORD_MANAGER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), XFDESKTOP_TYPE_CLIPBOARD_MANAGER))
 #define XFDESKTOP_CLIPBOARD_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), XFDESKTOP_TYPE_CLIPBAORD_MANAGER, XfdesktopClipboardManagerClass))
 
-GType                   xfdesktop_clipboard_manager_get_type        (void) G_GNUC_CONST;
+GType                      xfdesktop_clipboard_manager_get_type        (void) G_GNUC_CONST;
 
-XfdesktopClipboardManager *xfdesktop_clipboard_manager_get_for_display (GdkDisplay             *display);
+XfdesktopClipboardManager *xfdesktop_clipboard_manager_get_for_display (GdkDisplay                      *display);
 
-gboolean                xfdesktop_clipboard_manager_get_can_paste   (XfdesktopClipboardManager *manager);
+gboolean                   xfdesktop_clipboard_manager_get_can_paste   (XfdesktopClipboardManager       *manager);
 
-gboolean                xfdesktop_clipboard_manager_has_cutted_file (XfdesktopClipboardManager *manager,
-                                                                     const struct _XfdesktopFileIcon       *file);
+gboolean                   xfdesktop_clipboard_manager_has_cutted_file (XfdesktopClipboardManager       *manager,
+                                                                        const struct _XfdesktopFileIcon *file);
 
-void                    xfdesktop_clipboard_manager_copy_files      (XfdesktopClipboardManager *manager,
-                                                                     GList                  *files);
-void                    xfdesktop_clipboard_manager_cut_files       (XfdesktopClipboardManager *manager,
-                                                                     GList                  *files);
-void                    xfdesktop_clipboard_manager_paste_files     (XfdesktopClipboardManager *manager,
-                                                                     ThunarVfsPath *target_path,
-                                                                     GtkWidget *widget,
-                                                                     GClosure *new_files_closure);
+void                       xfdesktop_clipboard_manager_copy_files      (XfdesktopClipboardManager       *manager,
+                                                                        GList                           *files);
+void                       xfdesktop_clipboard_manager_cut_files       (XfdesktopClipboardManager       *manager,
+                                                                        GList                           *files);
+void                       xfdesktop_clipboard_manager_paste_files     (XfdesktopClipboardManager       *manager,
+                                                                        GFile                           *target_file,
+                                                                        GtkWidget                       *widget,
+                                                                        GClosure                        *new_files_closure);
 
 G_END_DECLS;
 
diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index 4e3216f..079aafc 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -3484,7 +3484,7 @@ xfdesktop_file_icon_manager_drag_data_get(XfdesktopIconViewManager *manager,
                                           guint info,
                                           guint time_)
 {
-    GList *path_list;
+    GList *file_list;
     gchar *str;
     
     TRACE("entering");
@@ -3492,12 +3492,13 @@ xfdesktop_file_icon_manager_drag_data_get(XfdesktopIconViewManager *manager,
     g_return_if_fail(drag_icons);
     g_return_if_fail(info == TARGET_TEXT_URI_LIST);
     
-    path_list = xfdesktop_file_utils_file_icon_list_to_path_list(drag_icons);
-    str = thunar_vfs_path_list_to_string(path_list);
+    file_list = xfdesktop_file_utils_file_icon_list_to_file_list(drag_icons);
+    str = xfdesktop_file_utils_file_list_to_string(file_list);
+
     gtk_selection_data_set(data, data->target, 8, (guchar *)str, strlen(str));
     
     g_free(str);
-    thunar_vfs_path_list_free(path_list);
+    xfdesktop_file_utils_file_list_free(file_list);
 }
 
 
diff --git a/src/xfdesktop-file-utils.c b/src/xfdesktop-file-utils.c
index 3099664..62ef42b 100644
--- a/src/xfdesktop-file-utils.c
+++ b/src/xfdesktop-file-utils.c
@@ -155,22 +155,48 @@ xfdesktop_file_utils_get_file_kind(const ThunarVfsInfo *info,
 
 
 GList *
-xfdesktop_file_utils_file_icon_list_to_path_list(GList *icon_list)
+xfdesktop_file_utils_file_icon_list_to_file_list(GList *icon_list)
 {
-    GList *path_list = NULL, *l;
+    GList *file_list = NULL, *l;
     XfdesktopFileIcon *icon;
-    const ThunarVfsInfo *info;
+    GFile *file;
     
     for(l = icon_list; l; l = l->next) {
         icon = XFDESKTOP_FILE_ICON(l->data);
-        info = xfdesktop_file_icon_peek_info(icon);
-        if(info) {
-            path_list = g_list_prepend(path_list,
-                                       thunar_vfs_path_ref(info->path));
-        }
+        file = xfdesktop_file_icon_peek_file(icon);
+        file_list = g_list_prepend(file_list, g_object_ref(file));
     }
     
-    return g_list_reverse(path_list);
+    return g_list_reverse(file_list);
+}
+
+gchar *
+xfdesktop_file_utils_file_list_to_string(GList *list)
+{
+  GString *string;
+  GList *lp;
+  gchar *uri;
+
+  /* allocate initial string */
+  string = g_string_new(NULL);
+
+  for (lp = list; lp != NULL; lp = lp->next)
+    {
+      uri = g_file_get_uri(lp->data);
+      string = g_string_append(string, uri);
+      g_free(uri);
+
+      string = g_string_append(string, "\r\n");
+    }
+
+  return g_string_free(string, FALSE);
+}
+
+void
+xfdesktop_file_utils_file_list_free(GList *file_list)
+{
+  g_list_foreach(file_list, (GFunc) g_object_unref, NULL);
+  g_list_free(file_list);
 }
 
 static GdkPixbuf *xfdesktop_fallback_icon = NULL;
diff --git a/src/xfdesktop-file-utils.h b/src/xfdesktop-file-utils.h
index 6827cfb..1bb8f74 100644
--- a/src/xfdesktop-file-utils.h
+++ b/src/xfdesktop-file-utils.h
@@ -58,7 +58,9 @@ void xfdesktop_file_utils_move_into(GtkWindow *parent,
 gchar *xfdesktop_file_utils_get_file_kind(const ThunarVfsInfo *info,
                                           gboolean *is_link);
 
-GList *xfdesktop_file_utils_file_icon_list_to_path_list(GList *icon_list);
+GList *xfdesktop_file_utils_file_icon_list_to_file_list(GList *icon_list);
+gchar *xfdesktop_file_utils_file_list_to_string(GList *file_list);
+void xfdesktop_file_utils_file_list_free(GList *file_list);
 
 GdkPixbuf *xfdesktop_file_utils_get_fallback_icon(gint size);
 



More information about the Xfce4-commits mailing list