gnome-commander r2141 - in branches/gcmd-1-3: . src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2141 - in branches/gcmd-1-3: . src
- Date: Tue, 30 Sep 2008 16:46:46 +0000 (UTC)
Author: epiotr
Date: Tue Sep 30 16:46:46 2008
New Revision: 2141
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2141&view=rev
Log:
GnomeCmdFileList::insert_file() and GnomeCmdFileList::remove_file() return success/failure now
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
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 Tue Sep 30 16:46:46 2008
@@ -1418,8 +1418,11 @@
}
-void GnomeCmdFileList::insert_file (GnomeCmdFile *f)
+gboolean GnomeCmdFileList::insert_file(GnomeCmdFile *f)
{
+ if (!file_is_wanted(f))
+ return FALSE;
+
gint num_files = size();
for (gint i=0; i<num_files; i++)
@@ -1433,12 +1436,14 @@
if (i<=priv->cur_file)
priv->cur_file++;
- return;
+ return TRUE;
}
}
// Insert the file at the end of the list
append_file(f);
+
+ return TRUE;
}
@@ -1510,32 +1515,31 @@
}
-void GnomeCmdFileList::remove_file (GnomeCmdFile *f)
+gboolean GnomeCmdFileList::remove_file(GnomeCmdFile *f)
{
- g_return_if_fail (f != NULL);
+ g_return_val_if_fail (f != NULL, FALSE);
gint row = get_row_from_file(f);
- if (row >= 0)
- {
- gtk_clist_remove (GTK_CLIST (this), row);
+ if (row<0) // f not found in the shown file list...
+ return FALSE;
- priv->selected_files = g_list_remove (priv->selected_files, f);
- priv->visible_files.remove(f);
+ gtk_clist_remove (GTK_CLIST (this), row);
- focus_file_at_row (this, MIN (row, GTK_CLIST (this)->focus_row));
- }
+ priv->selected_files = g_list_remove (priv->selected_files, f);
+ priv->visible_files.remove(f);
+
+ focus_file_at_row (this, MIN (row, GTK_CLIST (this)->focus_row));
+
+ return TRUE;
}
-void GnomeCmdFileList::remove_file (const gchar *uri_str)
+gboolean GnomeCmdFileList::remove_file(const gchar *uri_str)
{
- g_return_if_fail (uri_str != NULL);
-
- GnomeCmdFile *f = priv->visible_files.find(uri_str);
- g_return_if_fail (GNOME_CMD_IS_FILE (f));
+ g_return_val_if_fail (uri_str != NULL, FALSE);
- remove_file (f);
+ return remove_file (priv->visible_files.find(uri_str));
}
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 Tue Sep 30 16:46:46 2008
@@ -80,9 +80,9 @@
void clear();
void append_file(GnomeCmdFile *f);
- void insert_file(GnomeCmdFile *f);
- void remove_file(GnomeCmdFile *f);
- void remove_file(const gchar *uri_str);
+ gboolean insert_file(GnomeCmdFile *f); // Returns TRUE if file added to shown file list, FALSE otherwise
+ gboolean remove_file(GnomeCmdFile *f);
+ gboolean remove_file(const gchar *uri_str);
void remove_files(GList *files);
void remove_all_files() { clear(); }
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 Tue Sep 30 16:46:46 2008
@@ -288,7 +288,7 @@
}
-static void update_files (GnomeCmdFileSelector *fs)
+inline void update_files (GnomeCmdFileSelector *fs)
{
g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
@@ -781,11 +781,8 @@
g_return_if_fail (GNOME_CMD_IS_FILE (f));
g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
- if (!fs->file_list()->file_is_wanted(f))
- return;
-
- fs->file_list()->insert_file(f);
- update_selected_files_label (fs);
+ if (fs->file_list()->insert_file(f))
+ update_selected_files_label (fs);
}
@@ -795,11 +792,9 @@
g_return_if_fail (GNOME_CMD_IS_FILE (f));
g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
- if (fs->priv->cwd == dir && fs->file_list()->has_file(f))
- {
- fs->file_list()->remove_file(f);
- update_selected_files_label (fs);
- }
+ if (fs->priv->cwd == dir)
+ if (fs->file_list()->remove_file(f))
+ update_selected_files_label (fs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]