[gnome-commander] gnome_cmd_dir_ref() returns the file now



commit 4bdf36c3dcad67dde5c8f892293f8fe068e31685
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Thu Apr 21 20:03:23 2011 +0200

    gnome_cmd_dir_ref() returns the file now

 src/cap.cc                        |    6 ++----
 src/gnome-cmd-chmod-dialog.cc     |    3 +--
 src/gnome-cmd-chown-dialog.cc     |    3 +--
 src/gnome-cmd-dir.h               |    5 +++--
 src/gnome-cmd-file-list.cc        |    4 +---
 src/gnome-cmd-make-copy-dialog.cc |    6 ++----
 src/gnome-cmd-search-dialog.cc    |    5 +----
 7 files changed, 11 insertions(+), 21 deletions(-)
---
diff --git a/src/cap.cc b/src/cap.cc
index eec7318..d6d5937 100644
--- a/src/cap.cc
+++ b/src/cap.cc
@@ -56,9 +56,8 @@ inline void update_refs (GnomeCmdFileList *fl, GList *files)
 
 inline void cut_and_paste (GnomeCmdDir *to)
 {
-    gnome_cmd_dir_ref (to);
     gnome_cmd_xfer_start (_files,
-                          to,
+                          gnome_cmd_dir_ref (to),
                           _fl,
                           NULL,
                           GNOME_VFS_XFER_REMOVESOURCE,
@@ -72,9 +71,8 @@ inline void cut_and_paste (GnomeCmdDir *to)
 
 inline void copy_and_paste (GnomeCmdDir *to)
 {
-    gnome_cmd_dir_ref (to);
     gnome_cmd_xfer_start (_files,
-                          to,
+                          gnome_cmd_dir_ref (to),
                           _fl,
                           NULL,
                           GNOME_VFS_XFER_RECURSIVE,
diff --git a/src/gnome-cmd-chmod-dialog.cc b/src/gnome-cmd-chmod-dialog.cc
index 139b4ea..628f404 100644
--- a/src/gnome-cmd-chmod-dialog.cc
+++ b/src/gnome-cmd-chmod-dialog.cc
@@ -79,9 +79,8 @@ static void do_chmod (GnomeCmdFile *in, GnomeVFSFilePermissions perm, gboolean r
 
     if (in->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
     {
-        GnomeCmdDir *dir = GNOME_CMD_DIR (in);
+        GnomeCmdDir *dir = gnome_cmd_dir_ref (GNOME_CMD_DIR (in));
 
-        gnome_cmd_dir_ref (dir);
         gnome_cmd_dir_list_files (dir, FALSE);
 
         for (GList *i = gnome_cmd_dir_get_files (dir); i; i = i->next)
diff --git a/src/gnome-cmd-chown-dialog.cc b/src/gnome-cmd-chown-dialog.cc
index bf65455..11db2cb 100644
--- a/src/gnome-cmd-chown-dialog.cc
+++ b/src/gnome-cmd-chown-dialog.cc
@@ -64,9 +64,8 @@ static void do_chown (GnomeCmdFile *in, uid_t uid, gid_t gid, gboolean recurse)
 
     if (in->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
     {
-        GnomeCmdDir *dir = GNOME_CMD_DIR (in);
+        GnomeCmdDir *dir = gnome_cmd_dir_ref (GNOME_CMD_DIR (in));
 
-        gnome_cmd_dir_ref (dir);
         gnome_cmd_dir_list_files (dir, FALSE);
 
         for (GList *i = gnome_cmd_dir_get_files (dir); i; i = i->next)
diff --git a/src/gnome-cmd-dir.h b/src/gnome-cmd-dir.h
index 3f379f3..9faef74 100644
--- a/src/gnome-cmd-dir.h
+++ b/src/gnome-cmd-dir.h
@@ -110,10 +110,11 @@ inline GnomeCmdFile *gnome_cmd_dir_new_parent_dir_file (GnomeCmdDir *dir)
     return gnome_cmd_file_new (info, dir);
 }
 
-inline void gnome_cmd_dir_ref (GnomeCmdDir *dir)
+inline GnomeCmdDir *gnome_cmd_dir_ref (GnomeCmdDir *dir)
 {
-    g_return_if_fail (GNOME_CMD_IS_DIR (dir));
+    g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), NULL);
     GNOME_CMD_FILE (dir)->ref();
+    return dir;
 }
 
 inline void gnome_cmd_dir_unref (GnomeCmdDir *dir)
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 4a266b8..ae5003f 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -2862,11 +2862,9 @@ static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint
 
     g_return_if_fail (GNOME_CMD_IS_DIR (to));
 
-    gnome_cmd_dir_ref (to);
-
     // Start the xfer
     gnome_cmd_xfer_uris_start (uri_list,
-                               to,
+                               gnome_cmd_dir_ref (to),
                                NULL,
                                NULL,
                                to_fn,
diff --git a/src/gnome-cmd-make-copy-dialog.cc b/src/gnome-cmd-make-copy-dialog.cc
index 6916d4f..0571366 100644
--- a/src/gnome-cmd-make-copy-dialog.cc
+++ b/src/gnome-cmd-make-copy-dialog.cc
@@ -131,10 +131,8 @@ GtkWidget *gnome_cmd_make_copy_dialog_new (GnomeCmdFile *f, GnomeCmdDir *dir)
 
     GnomeCmdMakeCopyDialog *dialog = (GnomeCmdMakeCopyDialog *) g_object_new (GNOME_CMD_TYPE_MAKE_COPY_DIALOG, NULL);
 
-    dialog->priv->f = f;
-    dialog->priv->dir = dir;
-    f->ref();
-    gnome_cmd_dir_ref (dir);
+    dialog->priv->f = f->ref();
+    dialog->priv->dir = gnome_cmd_dir_ref (dir);
 
     gchar *msg = g_strdup_printf (_("Copy \"%s\" to"), f->get_name());
     GtkWidget *msg_label = create_label (GTK_WIDGET (dialog), msg);
diff --git a/src/gnome-cmd-search-dialog.cc b/src/gnome-cmd-search-dialog.cc
index 7a7cdc1..ff56cb4 100755
--- a/src/gnome-cmd-search-dialog.cc
+++ b/src/gnome-cmd-search-dialog.cc
@@ -326,10 +326,7 @@ static void search_dir_r (GnomeCmdDir *dir, SearchData *data)
 
                 // also ref each directory that has a matching file
                 if (g_list_index (data->match_dirs, dir) == -1)
-                {
-                    gnome_cmd_dir_ref (dir);
-                    data->match_dirs = g_list_append (data->match_dirs, dir);
-                }
+                    data->match_dirs = g_list_append (data->match_dirs, gnome_cmd_dir_ref (dir));
             }
     }
 }



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