[gnome-commander] tabs: move GnomeCmdFileSelector::goto_directory() to GnomeCmdFileList::goto_directory()
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] tabs: move GnomeCmdFileSelector::goto_directory() to GnomeCmdFileList::goto_directory()
- Date: Sat, 5 Jun 2010 21:01:10 +0000 (UTC)
commit c5ff2c6da533245947cd29b4d62c967d446cb551
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sat Jun 5 12:43:38 2010 +0200
tabs: move GnomeCmdFileSelector::goto_directory() to GnomeCmdFileList::goto_directory()
src/gnome-cmd-file-list.cc | 51 +++++++++++++++++++++++++++++++++++++
src/gnome-cmd-file-list.h | 2 +
src/gnome-cmd-file-selector.cc | 55 ----------------------------------------
src/gnome-cmd-file-selector.h | 2 +-
src/gnome-cmd-search-dialog.cc | 6 ++--
src/gnome-cmd-user-actions.cc | 6 ++--
6 files changed, 60 insertions(+), 62 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index ca790eb..e2506d4 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -2461,6 +2461,57 @@ gboolean GnomeCmdFileList::file_is_wanted(GnomeCmdFile *f)
}
+void GnomeCmdFileList::goto_directory(const gchar *in_dir)
+{
+ g_return_if_fail (in_dir != NULL);
+
+ GnomeCmdDir *new_dir = NULL;
+ const gchar *focus_dir = NULL;
+ gchar *dir;
+
+ if (g_str_has_prefix (in_dir, "~"))
+ dir = gnome_vfs_expand_initial_tilde (in_dir);
+ else
+ dir = unquote_if_needed (in_dir);
+
+ if (strcmp (dir, "..") == 0)
+ {
+ // lets get the parent directory
+ new_dir = gnome_cmd_dir_get_parent (cwd);
+ if (!new_dir)
+ {
+ g_free (dir);
+ return;
+ }
+ focus_dir = gnome_cmd_file_get_name (GNOME_CMD_FILE (cwd));
+ }
+ else
+ {
+ // check if it's an absolute address or not
+ if (dir[0] == '/')
+ new_dir = gnome_cmd_dir_new (con, gnome_cmd_con_create_path (con, dir));
+ else
+ if (g_str_has_prefix (dir, "\\\\"))
+ {
+ GnomeCmdPath *path = gnome_cmd_con_create_path (get_smb_con (), dir);
+ if (path)
+ new_dir = gnome_cmd_dir_new (get_smb_con (), path);
+ }
+ else
+ new_dir = gnome_cmd_dir_get_child (cwd, dir);
+ }
+
+ if (new_dir)
+ set_directory(new_dir);
+
+ // focus the current dir when going back to the parent dir
+ if (focus_dir)
+ focus_file(focus_dir, FALSE);
+
+ g_free (dir);
+}
+
+
void GnomeCmdFileList::invalidate_tree_size()
{
for (GList *tmp = get_visible_files(); tmp; tmp = tmp->next)
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index 8d5829c..5f9548c 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -162,6 +162,8 @@ struct GnomeCmdFileList
void update_style();
+ void goto_directory(const gchar *dir);
+
gboolean key_pressed(GdkEventKey *event);
};
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 05773be..b3d7e85 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -558,61 +558,6 @@ static void update_vol_label (GnomeCmdFileSelector *fs)
}
-void GnomeCmdFileSelector::goto_directory(const gchar *in_dir)
-{
- g_return_if_fail (in_dir != NULL);
-
- GnomeCmdDir *cur_dir = get_directory();
-
- g_return_if_fail (GNOME_CMD_IS_DIR (cur_dir));
-
- GnomeCmdDir *new_dir = NULL;
- const gchar *focus_dir = NULL;
- gchar *dir;
-
- if (g_str_has_prefix (in_dir, "~"))
- dir = gnome_vfs_expand_initial_tilde (in_dir);
- else
- dir = unquote_if_needed (in_dir);
-
- if (strcmp (dir, "..") == 0)
- {
- // lets get the parent directory
- new_dir = gnome_cmd_dir_get_parent (cur_dir);
- if (!new_dir)
- {
- g_free (dir);
- return;
- }
- focus_dir = gnome_cmd_file_get_name (GNOME_CMD_FILE (cur_dir));
- }
- else
- {
- // check if it's an absolute address or not
- if (dir[0] == '/')
- new_dir = gnome_cmd_dir_new (get_connection(), gnome_cmd_con_create_path (get_connection(), dir));
- else
- if (g_str_has_prefix (dir, "\\\\"))
- {
- GnomeCmdPath *path = gnome_cmd_con_create_path (get_smb_con (), dir);
- if (path)
- new_dir = gnome_cmd_dir_new (get_smb_con (), path);
- }
- else
- new_dir = gnome_cmd_dir_get_child (cur_dir, dir);
- }
-
- if (new_dir)
- file_list()->set_directory(new_dir);
-
- // focus the current dir when going back to the parent dir
- if (focus_dir)
- file_list()->focus_file(focus_dir, FALSE);
-
- g_free (dir);
-}
-
-
static void do_file_specific_action (GnomeCmdFileSelector *fs, GnomeCmdFile *f)
{
g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
diff --git a/src/gnome-cmd-file-selector.h b/src/gnome-cmd-file-selector.h
index 2bfe1d3..409a147 100644
--- a/src/gnome-cmd-file-selector.h
+++ b/src/gnome-cmd-file-selector.h
@@ -74,7 +74,7 @@ struct GnomeCmdFileSelector
GnomeCmdFileList *&file_list() { return list; }
GnomeCmdDir *get_directory() { return file_list()->cwd; }
- void goto_directory(const gchar *dir);
+ void goto_directory(const gchar *dir) { return file_list()->goto_directory(dir); }
void first();
void back();
diff --git a/src/gnome-cmd-search-dialog.cc b/src/gnome-cmd-search-dialog.cc
index acfcf57..f4afd42 100644
--- a/src/gnome-cmd-search-dialog.cc
+++ b/src/gnome-cmd-search-dialog.cc
@@ -633,9 +633,9 @@ static void on_goto (GtkButton *button, GnomeCmdSearchDialog *dialog)
gchar *fpath = gnome_cmd_file_get_path (f);
gchar *dpath = g_path_get_dirname (fpath);
- GnomeCmdFileSelector *fs = main_win->fs(ACTIVE);
- fs->goto_directory(dpath);
- fs->file_list()->focus_file(gnome_cmd_file_get_name (f), TRUE);
+ GnomeCmdFileList *fl = main_win->fs(ACTIVE)->file_list();
+ fl->goto_directory(dpath);
+ fl->focus_file(gnome_cmd_file_get_name (f), TRUE);
g_free (fpath);
g_free (dpath);
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 2fd6e21..0a6a5ce 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1346,7 +1346,7 @@ void view_backup_files (GtkMenuItem *menuitem, gpointer not_used)
void view_up (GtkMenuItem *menuitem, gpointer not_used)
{
- get_fs (ACTIVE)->goto_directory("..");
+ get_fl (ACTIVE)->goto_directory("..");
}
@@ -1413,13 +1413,13 @@ void view_in_inactive_pane (GtkMenuItem *menuitem, gpointer not_used)
void view_home (GtkMenuItem *menuitem, gpointer not_used)
{
get_fs (ACTIVE)->set_connection(get_home_con ());
- get_fs (ACTIVE)->goto_directory("~");
+ get_fl (ACTIVE)->goto_directory("~");
}
void view_root (GtkMenuItem *menuitem, gpointer not_used)
{
- get_fs (ACTIVE)->goto_directory("/");
+ get_fl (ACTIVE)->goto_directory("/");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]