[gnome-commander] XML config: added support for selections handling
- From: Piotr Eljasiak <epiotr src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-commander] XML config: added support for selections handling
- Date: Sun, 5 Jul 2009 09:01:15 +0000 (UTC)
commit d0e02254252b9f3f6706021c22cf984c0cce8361
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sun Jul 5 10:44:36 2009 +0200
XML config: added support for selections handling
src/gnome-cmd-data.h | 2 ++
src/gnome-cmd-xml-config.cc | 41 ++++++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 70c45eb..da347ef 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -179,6 +179,8 @@ struct GnomeCmdData
Filter::Type filter_type;
FilterSettings filter_settings;
+ std::vector<Selection> selections;
+
SearchConfig search_defaults;
AdvrenameConfig advrename_defaults;
IntViewerConfig intviewer_defaults;
diff --git a/src/gnome-cmd-xml-config.cc b/src/gnome-cmd-xml-config.cc
index aa9dc4b..c51238a 100644
--- a/src/gnome-cmd-xml-config.cc
+++ b/src/gnome-cmd-xml-config.cc
@@ -348,7 +348,12 @@ enum {XML_ELEM_NOT_FOUND,
XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY,
XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_PATTERN,
XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_PATH,
- XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT};
+ XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT,
+ XML_GNOMECOMMANDER_SELECTIONS,
+ XML_GNOMECOMMANDER_SELECTIONS_PROFILE,
+ XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN,
+ XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATH,
+ XML_GNOMECOMMANDER_SELECTIONS_PROFILE_TEXT};
static DICT<guint> xml_elem_names(XML_ELEM_NOT_FOUND);
@@ -462,6 +467,7 @@ static void xml_start(GMarkupParseContext *context,
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE:
if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
G_MARKUP_COLLECT_STRING, "name", ¶m1,
G_MARKUP_COLLECT_INVALID))
@@ -472,17 +478,19 @@ static void xml_start(GMarkupParseContext *context,
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE_PATTERN:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN:
if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
G_MARKUP_COLLECT_STRING, "syntax", ¶m1,
G_MARKUP_COLLECT_BOOLEAN, "match-case", ¶m4,
G_MARKUP_COLLECT_INVALID))
{
- xml_search_profile.syntax = param1=="regex" ? Filter::TYPE_REGEX : Filter::TYPE_FNMATCH;
+ xml_search_profile.syntax = strcmp(param1,"regex")==0 ? Filter::TYPE_REGEX : Filter::TYPE_FNMATCH;
// FIXME: xml_search_profile.? = param4;
}
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE_PATH:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATH:
if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
G_MARKUP_COLLECT_BOOLEAN, "recursive", ¶m4,
G_MARKUP_COLLECT_INVALID))
@@ -490,6 +498,7 @@ static void xml_start(GMarkupParseContext *context,
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE_TEXT:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE_TEXT:
if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
G_MARKUP_COLLECT_BOOLEAN, "match-case", ¶m4,
G_MARKUP_COLLECT_INVALID))
@@ -544,6 +553,11 @@ static void xml_end (GMarkupParseContext *context,
cfg->search_defaults.content_patterns.reverse();
break;
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE:
+ if (xml_search_profile.name!="Default")
+ cfg->selections.push_back(xml_search_profile);
+ break;
+
default:
break;
}
@@ -571,10 +585,12 @@ static void xml_end (GMarkupParseContext *context,
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE_PATTERN:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN:
xml_search_profile.filename_pattern = text;
break;
case XML_GNOMECOMMANDER_SEARCHTOOL_PROFILE_TEXT:
+ case XML_GNOMECOMMANDER_SELECTIONS_PROFILE_TEXT:
xml_search_profile.text_pattern = text;
break;
@@ -629,7 +645,12 @@ gboolean gnome_cmd_xml_config_parse (const gchar *xml, gsize xml_len, GnomeCmdDa
{XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY, "/GnomeCommander/SearchTool/History"},
{XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_PATTERN, "/GnomeCommander/SearchTool/History/Pattern"},
{XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_PATH, "/GnomeCommander/SearchTool/History/Path"},
- {XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT, "/GnomeCommander/SearchTool/History/Text"}
+ {XML_GNOMECOMMANDER_SEARCHTOOL_HISTORY_TEXT, "/GnomeCommander/SearchTool/History/Text"},
+ {XML_GNOMECOMMANDER_SEARCHTOOL, "/GnomeCommander/Selections"},
+ {XML_GNOMECOMMANDER_SELECTIONS_PROFILE, "/GnomeCommander/Selections/Profile"},
+ {XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATTERN, "/GnomeCommander/Selections/Profile/Pattern"},
+ {XML_GNOMECOMMANDER_SELECTIONS_PROFILE_PATH, "/GnomeCommander/Selections/Profile/Path"},
+ {XML_GNOMECOMMANDER_SELECTIONS_PROFILE_TEXT, "/GnomeCommander/Selections/Profile/Text"}
};
load_data (xml_elem_names, xml_elem_data, G_N_ELEMENTS(xml_elem_data));
@@ -769,6 +790,20 @@ void gnome_cmd_xml_config_save (const gchar *path, GnomeCmdData &cfg)
fputs("\t\t</History>\n", f);
fputs("\t</SearchTool>\n", f);
+
+ // SELECTIONS
+ fputs("\t<Selections>\n", f);
+ for (std::vector<GnomeCmdData::Selection>::const_iterator sel=cfg.selections.begin(); sel!=cfg.selections.end(); ++sel)
+ {
+ fprintf_escaped(f, "\t\t<Profile name=\"%s\">\n", sel->name.c_str());
+ fprintf_escaped (f, "\t\t\t<Pattern syntax=\"%s\" match-case=\"0\">%s</Pattern>\n", sel->syntax==Filter::TYPE_REGEX ? "regex" : "shell", sel->filename_pattern.c_str());
+ fprintf (f, "\t\t\t<Path recursive=\"%i\" />\n", sel->recursive);
+ if (!sel->text_pattern.empty())
+ fprintf_escaped (f, "\t\t\t<Text match-case=\"%i\">%s</Text>\n", sel->match_case, sel->text_pattern.c_str());
+ fputs("\t\t</Profile>\n", f);
+ }
+ fputs("\t</Selections>\n", f);
+
fputs("</GnomeCommander>\n", f);
fputs("", f);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]