[gnome-commander] tabs: move GnomeCmdFileSelector::set_connection() to GnomeCmdFileList::set_connection



commit 19615f6fba913d1ac7603591c45f47ddbdc52689
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Jun 5 12:44:44 2010 +0200

    tabs: move GnomeCmdFileSelector::set_connection() to GnomeCmdFileList::set_connection

 src/gnome-cmd-file-list.cc     |   52 +++++++++++++++++++++++++++++++++
 src/gnome-cmd-file-list.h      |    4 +-
 src/gnome-cmd-file-selector.cc |   63 ----------------------------------------
 src/gnome-cmd-file-selector.h  |    4 ++
 src/gnome-cmd-user-actions.cc  |    4 +-
 5 files changed, 60 insertions(+), 67 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index e2506d4..93488c5 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -2379,6 +2379,58 @@ GList *GnomeCmdFileList::sort_selection(GList *list)
 }
 
 
+void GnomeCmdFileList::set_connection (GnomeCmdCon *new_con, GnomeCmdDir *start_dir)
+{
+    g_return_if_fail (GNOME_CMD_IS_CON (new_con));
+
+    if (con==new_con)
+    {
+        if (!gnome_cmd_con_should_remember_dir (new_con))
+            set_directory (gnome_cmd_con_get_default_dir (new_con));
+        else
+            if (start_dir)
+                set_directory (start_dir);
+        return;
+    }
+
+    if (!gnome_cmd_con_is_open (new_con))
+    {
+        g_signal_connect (new_con, "open-done", G_CALLBACK (on_con_open_done), this);
+        g_signal_connect (new_con, "open-failed", G_CALLBACK (on_con_open_failed), this);
+        priv->con_opening = new_con;
+
+        create_con_open_progress_dialog (this);
+        g_timeout_add (gnome_cmd_data.gui_update_rate, (GSourceFunc) update_con_open_progress, this);
+
+        gnome_cmd_con_open (new_con);
+
+        return;
+    }
+
+    con = new_con;
+
+    if (lwd)
+    {
+        gnome_cmd_dir_cancel_monitoring (lwd);
+        gnome_cmd_dir_unref (lwd);
+        lwd = NULL;
+    }
+    if (cwd)
+    {
+        gnome_cmd_dir_cancel_monitoring (cwd);
+        gnome_cmd_dir_unref (cwd);
+        cwd = NULL;
+    }
+
+    if (!start_dir)
+        start_dir = gnome_cmd_con_get_default_dir (con);
+
+    g_signal_emit (this, signals[CON_CHANGED], 0, con);
+
+    set_directory(start_dir);
+}
+
+
 void GnomeCmdFileList::set_directory(GnomeCmdDir *dir)
 {
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index 5f9548c..729d8de 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -158,12 +158,12 @@ struct GnomeCmdFileList
 
     void invalidate_tree_size();
 
+    void set_connection(GnomeCmdCon *con, GnomeCmdDir *start_dir=NULL);
     void set_directory(GnomeCmdDir *dir);
+    void goto_directory(const gchar *dir);
 
     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 b3d7e85..1ad1429 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -223,39 +223,6 @@ inline void GnomeCmdFileSelector::update_selected_files_label()
 }
 
 
-inline void set_connection (GnomeCmdFileSelector *fs, GnomeCmdCon *con, GnomeCmdDir *dir=NULL)
-{
-    gboolean con_change_needed = fs->get_connection()!=con;
-
-    if (con_change_needed)
-    {
-        fs->file_list()->con = con;
-        fs->priv->dir_history = gnome_cmd_con_get_dir_history (con);
-
-        if (fs->file_list()->lwd)
-        {
-            gnome_cmd_dir_cancel_monitoring (fs->file_list()->lwd);
-            gnome_cmd_dir_unref (fs->file_list()->lwd);
-            fs->file_list()->lwd = NULL;
-        }
-        if (fs->file_list()->cwd)
-        {
-            gnome_cmd_dir_cancel_monitoring (fs->file_list()->cwd);
-            gnome_cmd_dir_unref (fs->file_list()->cwd);
-            fs->file_list()->cwd = NULL;
-        }
-    }
-
-    if (!dir)
-        dir = gnome_cmd_con_get_default_dir (con);
-
-    fs->file_list()->set_directory(dir);
-
-    if (con_change_needed)
-        fs->con_combo->select_data(con);
-}
-
-
 inline void GnomeCmdFileSelector::update_files()
 {
     GnomeCmdDir *dir = get_directory();
@@ -1337,36 +1304,6 @@ void GnomeCmdFileSelector::update_connections()
 }
 
 
-void GnomeCmdFileSelector::set_connection (GnomeCmdCon *con, GnomeCmdDir *start_dir)
-{
-    g_return_if_fail (GNOME_CMD_IS_CON (con));
-
-    if (get_connection() == con)
-    {
-        if (start_dir)
-            set_directory (start_dir);
-        else
-            if (!gnome_cmd_con_should_remember_dir (con))
-                file_list()->set_directory (gnome_cmd_con_get_default_dir (con));
-        return;
-    }
-
-    if (!gnome_cmd_con_is_open (con))
-    {
-        g_signal_connect (con, "open-done", G_CALLBACK (on_con_open_done), this);
-        g_signal_connect (con, "open-failed", G_CALLBACK (on_con_open_failed), this);
-        priv->con_opening = con;
-
-        create_con_open_progress_dialog (this);
-        g_timeout_add (gnome_cmd_data.gui_update_rate, (GSourceFunc) update_con_open_progress, this);
-
-        gnome_cmd_con_open (con);
-    }
-    else
-        ::set_connection (this, con, start_dir);
-}
-
-
 gboolean gnome_cmd_file_selector_is_local (FileSelectorID fsID)
 {
     return main_win->fs(fsID)->is_local();
diff --git a/src/gnome-cmd-file-selector.h b/src/gnome-cmd-file-selector.h
index 409a147..247ad14 100644
--- a/src/gnome-cmd-file-selector.h
+++ b/src/gnome-cmd-file-selector.h
@@ -104,6 +104,10 @@ struct GnomeCmdFileSelector
     gboolean key_pressed(GdkEventKey *event);
 };
 
+inline void GnomeCmdFileSelector::set_connection(GnomeCmdCon *con, GnomeCmdDir *start_dir)
+{
+    file_list()->set_connection(con, start_dir);
+}
 
 GtkType gnome_cmd_file_selector_get_type ();
 GtkWidget *gnome_cmd_file_selector_new ();
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 0a6a5ce..7017d1c 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1412,7 +1412,7 @@ 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_fl (ACTIVE)->set_connection(get_home_con ());
     get_fl (ACTIVE)->goto_directory("~");
 }
 
@@ -1472,7 +1472,7 @@ void connections_new (GtkMenuItem *menuitem, gpointer not_used)
 
 void connections_change (GtkMenuItem *menuitem, gpointer con)           // this function is NOT exposed to user as UserAction
 {
-    get_fs (ACTIVE)->set_connection((GnomeCmdCon *) con);
+    get_fl (ACTIVE)->set_connection((GnomeCmdCon *) con);
 }
 
 



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