gnome-commander r2156 - in branches/gcmd-1-3: . src



Author: epiotr
Date: Fri Oct  3 22:52:56 2008
New Revision: 2156
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2156&view=rev

Log:
GnomeCmdFileSelector: more C++ rework

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-file-list.cc
   branches/gcmd-1-3/src/gnome-cmd-file-list.h
   branches/gcmd-1-3/src/gnome-cmd-file-selector.cc
   branches/gcmd-1-3/src/gnome-cmd-file-selector.h

Modified: branches/gcmd-1-3/src/gnome-cmd-file-list.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-list.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-list.cc	Fri Oct  3 22:52:56 2008
@@ -1564,7 +1564,7 @@
 
 GList *GnomeCmdFileList::get_marked_files()
 {
-    return priv->selected_files ? g_list_copy (priv->selected_files) : NULL;
+    return priv->selected_files;
 }
 
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file-list.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-list.h	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-list.h	Fri Oct  3 22:52:56 2008
@@ -125,7 +125,7 @@
 
     GList *get_visible_files();                 // Returns a list with all files shown in the file list. The list is the same as that in the file list it self so make a copy and ref the files if needed
     GList *get_selected_files();                // Returns a list with all selected files. The list returned is a copy and should be freed when no longer needed. The files in the list is however not refed before returning
-    GList *get_marked_files();                  // Returns a list with all marked files. The list returned is a copy and should be freed when no longer needed. The files in the list is however not refed before returning
+    GList *get_marked_files();                  // Returns a list with all marked files. The list is the same as that in the file list it self so make a copy and ref the files if needed
                                                 // A marked file is a file that has been selected with ins etc. The file that is currently focused is not marked
 
     GnomeCmdFile *get_focused_file();           // Returns the currently focused file if any. The returned file is not reffed. The ".." file is returned if focused

Modified: branches/gcmd-1-3/src/gnome-cmd-file-selector.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-selector.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-selector.cc	Fri Oct  3 22:52:56 2008
@@ -141,11 +141,9 @@
 }
 
 
-inline void update_selected_files_label (GnomeCmdFileSelector *fs)
+inline void GnomeCmdFileSelector::update_selected_files_label()
 {
-    g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
-
-    GList *all_files = fs->file_list()->get_visible_files();
+    GList *all_files = file_list()->get_visible_files();
 
     if (!all_files)
         return;
@@ -161,9 +159,9 @@
     if (size_mode==GNOME_CMD_SIZE_DISP_MODE_POWERED)
         size_mode = GNOME_CMD_SIZE_DISP_MODE_GROUPED;
 
-    for (GList *tmp = all_files; tmp; tmp = tmp->next)
+    for (GList *i = all_files; i; i = i->next)
     {
-        GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
+        GnomeCmdFile *f = (GnomeCmdFile *) i->data;
 
         switch (f->info->type)
         {
@@ -186,10 +184,9 @@
         }
     }
 
-    GList *sel_files = fs->file_list()->get_marked_files();
-    for (GList *tmp = sel_files; tmp; tmp = tmp->next)
+    for (GList *i = file_list()->get_marked_files(); i; i = i->next)
     {
-        GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
+        GnomeCmdFile *f = (GnomeCmdFile *) i->data;
 
         switch (f->info->type)
         {
@@ -221,10 +218,7 @@
                                                 num_dirs),
                                        file_str, num_sel_dirs, num_dirs);
 
-    gtk_label_set_text (GTK_LABEL (fs->info_label), info_str);
-
-    if (sel_files)
-        g_list_free (sel_files);
+    gtk_label_set_text (GTK_LABEL (info_label), info_str);
 
     g_free (sel_str);
     g_free (total_str);
@@ -242,7 +236,7 @@
     for (GList *files = fs->file_list()->get_visible_files(); files; files = files->next)
         fs->file_list()->show_dir_tree_size((GnomeCmdFile *) files->data);
 
-    update_selected_files_label (fs);
+    fs->update_selected_files_label();
 }
 
 
@@ -280,32 +274,28 @@
 }
 
 
-inline void update_files (GnomeCmdFileSelector *fs)
+inline void GnomeCmdFileSelector::update_files()
 {
-    g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
-
-    GnomeCmdDir *dir = fs->get_directory();
+    GnomeCmdDir *dir = get_directory();
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
 
-    fs->file_list()->show_files(dir);
-    gnome_cmd_clist_set_voffset (GNOME_CMD_CLIST (fs->file_list()), fs->file_list()->cwd->voffset);
+    file_list()->show_files(dir);
+    gnome_cmd_clist_set_voffset (GNOME_CMD_CLIST (file_list()), file_list()->cwd->voffset);
 
-    if (fs->priv->realized)
-        update_selected_files_label (fs);
-    if (fs->priv->active)
-        fs->file_list()->select_row(0);
+    if (priv->realized)
+        update_selected_files_label();
+    if (priv->active)
+        file_list()->select_row(0);
 }
 
 
-inline void update_direntry (GnomeCmdFileSelector *fs)
+inline void GnomeCmdFileSelector::update_direntry()
 {
-    g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
-
-    gchar *tmp = gnome_cmd_dir_get_display_path (fs->file_list()->cwd);
+    gchar *tmp = gnome_cmd_dir_get_display_path (file_list()->cwd);
 
     g_return_if_fail (tmp != NULL);
 
-    gnome_cmd_dir_indicator_set_dir (GNOME_CMD_DIR_INDICATOR (fs->dir_indicator), tmp);
+    gnome_cmd_dir_indicator_set_dir (GNOME_CMD_DIR_INDICATOR (dir_indicator), tmp);
 
     g_free (tmp);
 }
@@ -774,7 +764,7 @@
     g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
 
     if (fs->file_list()->insert_file(f))
-        update_selected_files_label (fs);
+        fs->update_selected_files_label();
 }
 
 
@@ -786,7 +776,7 @@
 
     if (fs->file_list()->cwd == dir)
         if (fs->file_list()->remove_file(f))
-            update_selected_files_label (fs);
+            fs->update_selected_files_label();
 }
 
 
@@ -800,7 +790,7 @@
     {
         gnome_cmd_file_invalidate_metadata (f);                 // FIXME: should be handled in GnomeCmdDir, not here
         fs->file_list()->update_file(f);
-        update_selected_files_label (fs);
+        fs->update_selected_files_label();
     }
 }
 
@@ -967,7 +957,7 @@
 
 static void on_list_selection_changed (GnomeCmdFileList *fl, GnomeCmdFileSelector *fs)
 {
-    update_selected_files_label (fs);
+    fs->update_selected_files_label();
 }
 
 
@@ -1021,13 +1011,13 @@
 
     gtk_signal_emit (GTK_OBJECT (fs), file_selector_signals[CHANGED_DIR], dir);
 
-    update_direntry (fs);
+    fs->update_direntry();
     update_vol_label (fs);
 
     if (fs->file_list()->cwd != dir) return;
 
     fs->priv->sel_first_file = FALSE;
-    update_files (fs);
+    fs->update_files();
     fs->priv->sel_first_file = TRUE;
 
     if (!fs->priv->active)
@@ -1039,7 +1029,7 @@
     if (fs->priv->sel_first_file && fs->priv->active)
         gtk_clist_select_row (GTK_CLIST (fs->file_list()), 0, 0);
 
-    update_selected_files_label (fs);
+    fs->update_selected_files_label();
 
     DEBUG('l', "returning from on_dir_list_ok\n");
 }
@@ -1676,7 +1666,7 @@
     file_list()->update_style();
 
     if (priv->realized)
-        update_files (this);
+        update_files();
 
     create_con_buttons (this);
     update_connections();
@@ -1872,7 +1862,7 @@
                 f = file_list()->get_selected_file();
                 file_list()->show_dir_tree_size(f);
                 stop_kp (GTK_OBJECT (file_list()));
-                update_selected_files_label (this);
+                update_selected_files_label();
                 set_cursor_default ();
                 return TRUE;
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file-selector.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-selector.h	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-selector.h	Fri Oct  3 22:52:56 2008
@@ -92,6 +92,9 @@
     gboolean is_local()                     {  return gnome_cmd_con_is_local (get_connection ());  }
 
     void show_filter();
+    void update_files();
+    void update_direntry();
+    void update_selected_files_label();
     void update_style();
     void update_connections();
     void update_conbuttons_visibility();



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