[gnome-commander] GnomeCmdFileList: minor speedups in file selection



commit 74c8dd341039c8b19624b322e6dea3943c1b7ba0
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Fri Dec 4 00:16:48 2009 +0100

    GnomeCmdFileList: minor speedups in file selection

 src/gnome-cmd-file-list.cc |   40 ++++++++++++++++------------------------
 src/gnome-cmd-file-list.h  |    4 ++--
 2 files changed, 18 insertions(+), 26 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 5a64997..7df8e1f 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -367,7 +367,7 @@ static void on_quicksearch_popup_hide (GtkWidget *quicksearch_popup, GnomeCmdFil
 }
 
 
-void GnomeCmdFileList::select_file(GnomeCmdFile *f)
+void GnomeCmdFileList::select_file(GnomeCmdFile *f, gint row)
 {
     g_return_if_fail (f != NULL);
     g_return_if_fail (f->info != NULL);
@@ -375,7 +375,8 @@ void GnomeCmdFileList::select_file(GnomeCmdFile *f)
     if (strcmp (f->info->name, "..") == 0)
         return;
 
-    gint row = get_row_from_file(f);
+    if (row == -1)
+        gint row = get_row_from_file(f);
     if (row == -1)
         return;
 
@@ -402,11 +403,12 @@ void GnomeCmdFileList::select_file(GnomeCmdFile *f)
 }
 
 
-void GnomeCmdFileList::unselect_file(GnomeCmdFile *f)
+void GnomeCmdFileList::unselect_file(GnomeCmdFile *f, gint row)
 {
     g_return_if_fail (f != NULL);
 
-    gint row = get_row_from_file(f);
+    if (row == -1)
+        gint row = get_row_from_file(f);
     if (row == -1)
         return;
 
@@ -442,22 +444,9 @@ void GnomeCmdFileList::toggle_file(GnomeCmdFile *f)
 
     if (row < priv->visible_files.size())
         if (g_list_index (priv->selected_files, f) == -1)
-            select_file(f);
+            select_file(f, row);
         else
-            unselect_file(f);
-}
-
-
-inline void select_file_at_row (GnomeCmdFileList *fl, gint row)
-{
-    g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
-
-    fl->priv->cur_file = row;
-
-    GnomeCmdFile *f = fl->get_file_at_row(row);
-
-    if (f)
-            fl->select_file(f);
+            unselect_file(f, row);
 }
 
 
@@ -473,7 +462,9 @@ inline void select_file_range (GnomeCmdFileList *fl, gint start_row, gint end_ro
     }
 
     for (gint i=start_row; i<=end_row; i++)
-        select_file_at_row (fl, i);
+        fl->select_file(fl->get_file_at_row(i), i);
+
+    fl->priv->cur_file = end_row;
 }
 
 
@@ -1170,8 +1161,9 @@ static void on_file_clicked (GnomeCmdFileList *fl, GnomeCmdFile *f, GdkEventButt
                         else
                         {
                             if (prev_row!=row)
-                                fl->select_file(fl->get_file_at_row(prev_row));
-                            select_file_at_row (fl, row);
+                                fl->select_file(fl->get_file_at_row(prev_row), prev_row);
+                            fl->select_file(fl->get_file_at_row(row), row);
+                            fl->priv->cur_file = row;
                         }
                     }
             }
@@ -1235,9 +1227,9 @@ static void on_motion_notify (GtkCList *clist, GdkEventMotion *event, GnomeCmdFi
             {
                 fl->select_row(row+1);
                 if (fl->priv->right_mb_sel_state)
-                    fl->select_file(f);
+                    fl->select_file(f, row);
                 else
-                    fl->unselect_file(f);
+                    fl->unselect_file(f, row);
             }
         }
     }
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index 75fc8bc..450d90f 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -111,8 +111,8 @@ struct GnomeCmdFileList
 
     gboolean has_file(const GnomeCmdFile *f);
 
-    void select_file(GnomeCmdFile *f);
-    void unselect_file(GnomeCmdFile *f);
+    void select_file(GnomeCmdFile *f, gint row=-1);
+    void unselect_file(GnomeCmdFile *f, gint row=-1);
     void select_all();
     void unselect_all();
 



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