[gnome-commander] XML config: load bookmarks from XML cfg



commit 9a9ba9970142f9180790937bef38ac8299f95cef
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Mon Jan 4 23:49:16 2010 +0100

    XML config: load bookmarks from XML cfg

 src/gnome-cmd-data.cc       |   23 ++++++++++++------
 src/gnome-cmd-data.h        |    2 +
 src/gnome-cmd-xml-config.cc |   52 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 2c4ad90..2a6cfcc 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -994,6 +994,8 @@ GnomeCmdData::GnomeCmdData()
 {
     quick_connect = NULL;
 
+    XML_cfg_has_bookmarks = FALSE;
+
     confirm_delete = TRUE;
     confirm_copy_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
     confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
@@ -1332,6 +1334,13 @@ void GnomeCmdData::load()
         priv->ftp_anonymous_password = gnome_cmd_data_get_string ("/ftp/anonymous_password", "you provider com");
     }
 
+    priv->con_list = gnome_cmd_con_list_new ();
+
+    gnome_cmd_con_list_begin_update (priv->con_list);
+    load_devices ("devices");
+    load_connections ("connections") || load_connections ("ftp-servers");
+    gnome_cmd_con_list_end_update (priv->con_list);
+
     // "/quick-connect/uri" must be read AFTER retrieving anonymous password
 
     gchar * quick_connect_uri = gnome_cmd_data_get_string ("/quick-connect/uri", "ftp://anonymous ftp gnome org/pub/GNOME/");
@@ -1577,15 +1586,13 @@ void GnomeCmdData::load()
 
 void GnomeCmdData::load_more()
 {
-    priv->con_list = gnome_cmd_con_list_new ();
-    gnome_cmd_con_list_begin_update (priv->con_list);
-    load_devices ("devices");
-    load_connections ("connections") || load_connections ("ftp-servers");
-    gnome_cmd_con_list_end_update (priv->con_list);
-
     load_fav_apps ("fav-apps");
-    load_local_bookmarks();
-    load_smb_bookmarks();
+
+    if (!XML_cfg_has_bookmarks)
+    {
+        load_local_bookmarks();
+        load_smb_bookmarks();
+    }
 }
 
 
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index d08a911..f432e10 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -179,6 +179,8 @@ struct GnomeCmdData
 
   public:
 
+    gboolean                     XML_cfg_has_bookmarks;
+
     gboolean                     confirm_delete;
     GnomeCmdConfirmOverwriteMode confirm_copy_overwrite;
     GnomeCmdConfirmOverwriteMode confirm_move_overwrite;
diff --git a/src/gnome-cmd-xml-config.cc b/src/gnome-cmd-xml-config.cc
index 186c425..adcf9e6 100644
--- a/src/gnome-cmd-xml-config.cc
+++ b/src/gnome-cmd-xml-config.cc
@@ -47,6 +47,7 @@
 
 #include "gnome-cmd-includes.h"
 #include "gnome-cmd-xml-config.h"
+#include "gnome-cmd-con-list.h"
 #include "gnome-cmd-advrename-dialog.h"
 #include "gnome-cmd-regex.h"
 #include "gnome-cmd-user-actions.h"
@@ -355,6 +356,9 @@ enum {XML_ELEM_NOT_FOUND,
       XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT,
       XML_GNOMECOMMANDER_BOOKMARKSTOOL,
       XML_GNOMECOMMANDER_BOOKMARKSTOOL_WINDOWSIZE,
+      XML_GNOMECOMMANDER_BOOKMARKS,
+      XML_GNOMECOMMANDER_BOOKMARKS_GROUP,
+      XML_GNOMECOMMANDER_BOOKMARKS_GROUP_BOOKMARK,
       XML_GNOMECOMMANDER_SELECTIONS,
       XML_GNOMECOMMANDER_SELECTIONS_PROFILE,
       XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN,
@@ -370,6 +374,8 @@ static stack<string> xml_paths;
 static GnomeCmdData::AdvrenameConfig::Profile xml_adv_profile;
 static GnomeCmdData::Selection xml_search_profile;
 
+static GnomeCmdCon *xml_con = NULL;
+
 
 static bool is_default(GnomeCmdData::AdvrenameConfig::Profile &profile)
 {
@@ -485,6 +491,49 @@ static void xml_start(GMarkupParseContext *context,
             }
             break;
 
+        case XML_GNOMECOMMANDER_BOOKMARKS:
+            cfg->XML_cfg_has_bookmarks = TRUE;
+            break;
+
+        case XML_GNOMECOMMANDER_BOOKMARKS_GROUP:
+            if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+                                             G_MARKUP_COLLECT_STRING, "name", &param1,
+                                             G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "remote", &param4,
+                                             G_MARKUP_COLLECT_INVALID))
+            {
+                if (param4) //  if remote...
+                    xml_con = gnome_cmd_con_list_find_alias ((GnomeCmdConList *) gnome_cmd_data_get_con_list (), param1);
+                else
+                    if (strcmp(param1,"Home")==0)
+                        xml_con = gnome_cmd_con_list_get_home ((GnomeCmdConList *) gnome_cmd_data_get_con_list ());
+                    else
+                        if (strcmp(param1,"SMB")==0)
+                            xml_con = gnome_cmd_con_list_get_smb ((GnomeCmdConList *) gnome_cmd_data_get_con_list ());
+                        else
+                            xml_con = NULL;
+
+                if (!xml_con)
+                    g_warning ("<Bookmarks> unknown connection: '%s' - ignored", param1);
+            }
+            break;
+
+        case XML_GNOMECOMMANDER_BOOKMARKS_GROUP_BOOKMARK:
+            if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+                                             G_MARKUP_COLLECT_STRDUP, "name", &param1,
+                                             G_MARKUP_COLLECT_STRDUP, "path", &param2,
+                                             G_MARKUP_COLLECT_INVALID))
+            {
+                if (xml_con)
+                    gnome_cmd_con_add_bookmark (xml_con, param1, param2);
+                else
+                {
+                    // g_warning ("<Bookmarks> unknown connection: '%s' - ignored", param1);
+                    g_free (param1);
+                    g_free (param2);
+                }
+            }
+            break;
+
         case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE:
         case XML_GNOMECOMMANDER_SELECTIONS_PROFILE:
             if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
@@ -718,6 +767,9 @@ gboolean gnome_cmd_xml_config_parse (const gchar *xml, gsize xml_len, GnomeCmdDa
                         {XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT, "/GnomeCommander/SearchTool/History/Text"},
                         {XML_GNOMECOMMANDER_BOOKMARKSTOOL, "/GnomeCommander/BookmarksTool"},
                         {XML_GNOMECOMMANDER_BOOKMARKSTOOL_WINDOWSIZE, "/GnomeCommander/BookmarksTool/WindowSize"},
+                        {XML_GNOMECOMMANDER_BOOKMARKS, "/GnomeCommander/Bookmarks"},
+                        {XML_GNOMECOMMANDER_BOOKMARKS_GROUP, "/GnomeCommander/Bookmarks/Group"},
+                        {XML_GNOMECOMMANDER_BOOKMARKS_GROUP_BOOKMARK, "/GnomeCommander/Bookmarks/Group/Bookmark"},
                         {XML_GNOMECOMMANDER_SELECTIONS, "/GnomeCommander/Selections"},
                         {XML_GNOMECOMMANDER_SELECTIONS_PROFILE, "/GnomeCommander/Selections/Profile"},
                         {XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN, "/GnomeCommander/Selections/Profile/Pattern"},



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