gnome-commander r2317 - in trunk: . doc/C po src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2317 - in trunk: . doc/C po src
- Date: Thu, 27 Nov 2008 18:15:45 +0000 (UTC)
Author: epiotr
Date: Thu Nov 27 18:15:45 2008
New Revision: 2317
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2317&view=rev
Log:
Use XML cfg for storing advrename settings
Added:
trunk/src/gnome-cmd-xml-config.cc
trunk/src/gnome-cmd-xml-config.h
Modified:
trunk/ChangeLog
trunk/doc/C/gnome-commander.xml
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/gnome-cmd-advrename-dialog.cc
trunk/src/gnome-cmd-data.cc
trunk/src/gnome-cmd-data.h
Modified: trunk/doc/C/gnome-commander.xml
==============================================================================
--- trunk/doc/C/gnome-commander.xml (original)
+++ trunk/doc/C/gnome-commander.xml Thu Nov 27 18:15:45 2008
@@ -5463,13 +5463,6 @@
</row>
<row valign="top">
<entry><para></para></entry>
- <entry><para>rename-history-size</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
<entry><para>right_mouse_button_mode</para></entry>
<entry><para></para></entry>
<entry><para></para></entry>
@@ -5804,41 +5797,6 @@
<entry><para></para></entry>
</row>
<row valign="top">
- <entry><para>[advrename]</para></entry>
- <entry><para>height</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para><xref linkend="gnome-commander-advanced-rename"/></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>width</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>counter_start</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>counter_precision</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>counter_increment</para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
<entry><para>[local_bookmarks]</para></entry>
<entry><para>count</para></entry>
<entry><para></para></entry>
@@ -5881,55 +5839,6 @@
<entry><para></para></entry>
</row>
<row valign="top">
- <entry><para>[template-history]</para></entry>
- <entry><para>size</para></entry>
- <entry><para>integer</para></entry>
- <entry><para>Number of template<emphasis><subscript>n</subscript></emphasis> entries</para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>template<emphasis><subscript>n</subscript></emphasis></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para>[rename-history]</para></entry>
- <entry><para>size</para></entry>
- <entry><para>integer</para></entry>
- <entry><para>Number of from/to/csens<emphasis><subscript>n</subscript></emphasis> entries</para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>from<emphasis><subscript>n</subscript></emphasis></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>to<emphasis><subscript>n</subscript></emphasis></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para></para></entry>
- <entry><para>csens<emphasis><subscript>n</subscript></emphasis></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
- <entry><para>[cmdline-history]</para></entry>
- <entry><para>line<emphasis><subscript>n</subscript></emphasis></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- <entry><para></para></entry>
- </row>
- <row valign="top">
<entry><para>[key-bindings]</para></entry>
<entry><para>[<shift>][<control>][<alt>][<win>]<emphasis>key_name</emphasis></para></entry>
<entry><para>string</para></entry>
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Thu Nov 27 18:15:45 2008
@@ -51,8 +51,9 @@
src/gnome-cmd-smb-auth.cc
src/gnome-cmd-smb-path.cc
src/gnome-cmd-user-actions.cc
-src/gnome-cmd-xfer-progress-win.cc
src/gnome-cmd-xfer.cc
+src/gnome-cmd-xfer-progress-win.cc
+src/gnome-cmd-xml-config.cc
src/imageloader.cc
src/intviewer/cp437.cc
src/intviewer/datapresentation.cc
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu Nov 27 18:15:45 2008
@@ -77,8 +77,9 @@
gnome-cmd-treeview.h gnome-cmd-treeview.cc \
gnome-cmd-types.h \
gnome-cmd-user-actions.h gnome-cmd-user-actions.cc \
- gnome-cmd-xfer-progress-win.h gnome-cmd-xfer-progress-win.cc \
gnome-cmd-xfer.h gnome-cmd-xfer.cc \
+ gnome-cmd-xfer-progress-win.h gnome-cmd-xfer-progress-win.cc \
+ gnome-cmd-xml-config.h gnome-cmd-xml-config.cc \
handle.h \
history.h history.cc \
imageloader.cc imageloader.h \
Modified: trunk/src/gnome-cmd-advrename-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-advrename-dialog.cc (original)
+++ trunk/src/gnome-cmd-advrename-dialog.cc Thu Nov 27 18:15:45 2008
@@ -561,7 +561,7 @@
void GnomeCmdAdvrenameDialog::Private::on_counter_start_spin_value_changed (GtkWidget *spin, GnomeCmdAdvrenameDialog *dialog)
{
- dialog->defaults.counter_start = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
+ dialog->defaults.default_profile.counter_start = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
if (dialog->priv->template_has_counters)
dialog->update_new_filenames();
}
@@ -569,7 +569,7 @@
void GnomeCmdAdvrenameDialog::Private::on_counter_step_spin_value_changed (GtkWidget *spin, GnomeCmdAdvrenameDialog *dialog)
{
- dialog->defaults.counter_increment = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
+ dialog->defaults.default_profile.counter_step = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
if (dialog->priv->template_has_counters)
dialog->update_new_filenames();
}
@@ -577,7 +577,7 @@
void GnomeCmdAdvrenameDialog::Private::on_counter_digits_spin_value_changed (GtkWidget *spin, GnomeCmdAdvrenameDialog *dialog)
{
- dialog->defaults.counter_precision = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
+ dialog->defaults.default_profile.counter_width = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
if (dialog->priv->template_has_counters)
dialog->update_new_filenames();
}
@@ -699,7 +699,9 @@
void GnomeCmdAdvrenameDialog::Private::on_case_combo_changed (GtkComboBox *combo, GnomeCmdAdvrenameDialog *dialog)
{
- switch (gtk_combo_box_get_active (combo))
+ gint item = gtk_combo_box_get_active (combo);
+
+ switch (item)
{
case 0: dialog->priv->convert_case = gcmd_convert_unchanged; break;
case 1: dialog->priv->convert_case = gcmd_convert_lowercase; break;
@@ -712,13 +714,16 @@
return;
}
+ dialog->defaults.default_profile.case_conversion = item;
dialog->update_new_filenames();
}
void GnomeCmdAdvrenameDialog::Private::on_trim_combo_changed (GtkComboBox *combo, GnomeCmdAdvrenameDialog *dialog)
{
- switch (gtk_combo_box_get_active (combo))
+ gint item = gtk_combo_box_get_active (combo);
+
+ switch (item)
{
case 0: dialog->priv->trim_blanks = gcmd_convert_unchanged; break;
case 1: dialog->priv->trim_blanks = gcmd_convert_ltrim; break;
@@ -729,6 +734,7 @@
return;
}
+ dialog->defaults.default_profile.trim_blanks = item;
dialog->update_new_filenames();
}
@@ -1348,7 +1354,9 @@
void GnomeCmdAdvrenameDialog::update_new_filenames()
{
- gnome_cmd_advrename_reset_counter (defaults.counter_start, defaults.counter_precision, defaults.counter_increment);
+ gnome_cmd_advrename_reset_counter (defaults.default_profile.counter_start,
+ defaults.default_profile.counter_width,
+ defaults.default_profile.counter_step);
char buff[256];
GtkTreeIter i;
@@ -1441,9 +1449,9 @@
g_signal_connect (priv->template_combo, "changed", G_CALLBACK (Private::on_template_entry_changed), this);
// Counter
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_start_spin), defaults.counter_start);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_step_spin), defaults.counter_increment);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_digits_spin), defaults.counter_precision);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_start_spin), defaults.default_profile.counter_start);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_step_spin), defaults.default_profile.counter_step);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->counter_digits_spin), defaults.default_profile.counter_width);
g_signal_connect (priv->counter_start_spin, "value-changed", G_CALLBACK (Private::on_counter_start_spin_value_changed), this);
g_signal_connect (priv->counter_step_spin, "value-changed", G_CALLBACK (Private::on_counter_step_spin_value_changed), this);
g_signal_connect (priv->counter_digits_spin, "value-changed", G_CALLBACK (Private::on_counter_digits_spin_value_changed), this);
@@ -1459,8 +1467,8 @@
g_signal_connect (priv->regex_remove_all_button, "clicked", G_CALLBACK (Private::on_regex_remove_all_btn_clicked), this);
// Case conversion & blank triming
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->case_combo), 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->trim_combo), 3);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->case_combo), defaults.default_profile.case_conversion);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->trim_combo), defaults.default_profile.trim_blanks);
g_signal_connect (priv->case_combo, "changed", G_CALLBACK (Private::on_case_combo_changed), this);
g_signal_connect (priv->trim_combo, "changed", G_CALLBACK (Private::on_trim_combo_changed), this);
Modified: trunk/src/gnome-cmd-data.cc
==============================================================================
--- trunk/src/gnome-cmd-data.cc (original)
+++ trunk/src/gnome-cmd-data.cc Thu Nov 27 18:15:45 2008
@@ -33,6 +33,7 @@
#include "gnome-cmd-main-win.h"
#include "gnome-cmd-advrename-dialog.h"
#include "gnome-cmd-bookmark-dialog.h"
+#include "gnome-cmd-xml-config.h"
#include "filter.h"
#include "utils.h"
@@ -88,6 +89,17 @@
DICT<guint> gdk_modifiers_names;
+void GnomeCmdData::AdvrenameConfig::Profile::reset()
+{
+ name.clear();
+ template_string.clear();
+ regexes.clear();
+ counter_start = counter_width = counter_step = 1;
+ case_conversion = 0;
+ trim_blanks = 3;
+}
+
+
inline gint get_int (const gchar *path, int def)
{
gboolean b = FALSE;
@@ -830,57 +842,6 @@
}
-inline void GnomeCmdData::save_rename_history()
-{
- GList *from = NULL;
- GList *to = NULL;
- GList *csens = NULL;
-
- GtkTreeIter i;
-
- for (gboolean valid_iter=gtk_tree_model_get_iter_first (advrename_defaults.regexes, &i); valid_iter; valid_iter=gtk_tree_model_iter_next (advrename_defaults.regexes, &i))
- {
- GnomeCmdAdvrenameDialog::Regex *rx;
-
- gtk_tree_model_get (advrename_defaults.regexes, &i,
- GnomeCmdAdvrenameDialog::COL_REGEX, &rx,
- -1);
- if (!rx)
- continue;
-
- from = g_list_append (from, const_cast <char *> (rx->from.c_str()));
- to = g_list_append (to, const_cast <char *> (rx->to.c_str()));
- csens = g_list_append (csens, (gpointer) (rx->case_sensitive ? "T" : "F"));
- }
-
- gnome_cmd_data_set_int ("/advrename/width", advrename_defaults.width);
- gnome_cmd_data_set_int ("/advrename/height", advrename_defaults.height);
-
- gnome_cmd_data_set_int ("/template-history/size", advrename_defaults.templates.size());
- gnome_cmd_data_set_string_history ("/template-history/template%d", advrename_defaults.templates.ents);
-
- gnome_cmd_data_set_int ("/advrename/counter_start", advrename_defaults.counter_start);
- gnome_cmd_data_set_int ("/advrename/counter_precision", advrename_defaults.counter_precision);
- gnome_cmd_data_set_int ("/advrename/counter_increment", advrename_defaults.counter_increment);
-
- gnome_cmd_data_set_int ("/rename-history/size", g_list_length (from));
- gnome_cmd_data_set_string_history ("/rename-history/from%d", from);
- gnome_cmd_data_set_string_history ("/rename-history/to%d", to);
- gnome_cmd_data_set_string_history ("/rename-history/csens%d", csens);
-
- // removing config data used by gcmd < 1.2.5
-
- gnome_config_clean_key (G_DIR_SEPARATOR_S PACKAGE "/options/template-auto-update");
- gnome_config_clean_key (G_DIR_SEPARATOR_S PACKAGE "/options/counter_start");
- gnome_config_clean_key (G_DIR_SEPARATOR_S PACKAGE "/options/counter_precision");
- gnome_config_clean_key (G_DIR_SEPARATOR_S PACKAGE "/options/counter_increment");
- gnome_config_clean_key (G_DIR_SEPARATOR_S PACKAGE "/options/rename-history-size");
- gnome_config_clean_section (G_DIR_SEPARATOR_S PACKAGE "/rename-history-from");
- gnome_config_clean_section (G_DIR_SEPARATOR_S PACKAGE "/rename-history-to");
- gnome_config_clean_section (G_DIR_SEPARATOR_S PACKAGE "/rename-history-csens");
-}
-
-
inline void GnomeCmdData::save_local_bookmarks()
{
GnomeCmdCon *con = gnome_cmd_con_list_get_home (priv->con_list);
@@ -1014,9 +975,9 @@
advrename_defaults.templates.ents = templates;
advrename_defaults.templates.pos = templates;
- advrename_defaults.counter_start = gnome_cmd_data_get_int ("/advrename/counter_start", 1);
- advrename_defaults.counter_precision = gnome_cmd_data_get_int ("/advrename/counter_precision", 1);
- advrename_defaults.counter_increment = gnome_cmd_data_get_int ("/advrename/counter_increment", 1);
+ advrename_defaults.default_profile.counter_start = gnome_cmd_data_get_int ("/advrename/counter_start", 1);
+ advrename_defaults.default_profile.counter_width = gnome_cmd_data_get_int ("/advrename/counter_precision", 1);
+ advrename_defaults.default_profile.counter_step = gnome_cmd_data_get_int ("/advrename/counter_increment", 1);
size = gnome_cmd_data_get_int ("/rename-history/size", 0);
@@ -1024,13 +985,6 @@
GList *tmp_to = to = load_string_history ("/rename-history/to%d", size);
GList *tmp_csens = csens = load_string_history ("/rename-history/csens%d", size);
- advrename_defaults.regexes = GTK_TREE_MODEL (gtk_list_store_new (GnomeCmdAdvrenameDialog::NUM_REGEX_COLS,
- G_TYPE_POINTER,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING));
-
for (GtkTreeIter iter; tmp_from && size > 0; --size)
{
GnomeCmdAdvrenameDialog::Regex *rx = new GnomeCmdAdvrenameDialog::Regex((gchar *) tmp_from->data,
@@ -1194,6 +1148,8 @@
void GnomeCmdData::load()
{
+ gchar *xml_cfg_path = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), "." PACKAGE, PACKAGE ".xml", NULL);
+
gchar *document_icon_dir = g_strdup_printf ("%s/share/pixmaps/document-icons/", GNOME_PREFIX);
gchar *theme_icon_dir = g_strdup_printf ("%s/mime-icons", PIXMAPS_DIR);
@@ -1398,7 +1354,31 @@
load_cmdline_history();
//load_dir_history ();
load_search_defaults();
- load_rename_history();
+
+ // FIXME: the regex list definitely needs to be created in GnomeCmdData::AdvrenameConfig::AdvrenameConfig() constructor
+ // Unfortunately, this can't be done now, as gnome_cmd_data is global and is constructed before main() - causing gcmd crash
+ // To be moved, when gnome_cmd_data is part of GnomeCmdMainWindow
+ advrename_defaults.regexes = GTK_TREE_MODEL (gtk_list_store_new (GnomeCmdAdvrenameDialog::NUM_REGEX_COLS,
+ G_TYPE_POINTER,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING));
+ if (!gnome_cmd_xml_config_load (xml_cfg_path, *this))
+ {
+ load_rename_history();
+
+ // add a few default templates here - for new users
+ AdvrenameConfig::Profile p;
+
+ p.name = "CamelCase";
+ p.template_string = "$N";
+ p.regexes.push_back(AdvrenameConfig::Profile::Regex("\\s*\\b(\\w)(\\w*)\\b", "\\u\\1\\L\\2\\E", FALSE));
+ p.regexes.push_back(AdvrenameConfig::Profile::Regex("\\.(.+)$", "\\L\\1", FALSE));
+
+ advrename_defaults.profiles.push_back(p);
+ }
+
load_intviewer_defaults();
load_auto_load_plugins();
@@ -1603,6 +1583,8 @@
};
load_data (gdk_modifiers_names, gdk_mod_names_data, G_N_ELEMENTS(gdk_mod_names_data));
+
+ g_free (xml_cfg_path);
}
@@ -1622,6 +1604,8 @@
void GnomeCmdData::save()
{
+ gchar *xml_cfg_path = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), "." PACKAGE, PACKAGE ".xml", NULL);
+
for (gint i=0; i<BOOKMARK_DIALOG_NUM_COLUMNS; i++)
{
gchar *tmp = g_strdup_printf ("/gnome-commander-size/column-widths/bookmark_dialog_col_width%d", i);
@@ -1752,13 +1736,15 @@
save_devices ("devices");
save_fav_apps ("fav-apps");
save_search_defaults();
- save_rename_history();
save_intviewer_defaults();
+ gnome_cmd_xml_config_save (xml_cfg_path, *this);
save_local_bookmarks();
save_smb_bookmarks();
save_auto_load_plugins();
gnome_config_sync ();
+
+ g_free (xml_cfg_path);
}
Modified: trunk/src/gnome-cmd-data.h
==============================================================================
--- trunk/src/gnome-cmd-data.h (original)
+++ trunk/src/gnome-cmd-data.h Thu Nov 27 18:15:45 2008
@@ -21,6 +21,9 @@
#ifndef __GNOME_CMD_DATA_H__
#define __GNOME_CMD_DATA_H__
+#include <vector>
+#include <string>
+
#include "gnome-cmd-app.h"
#include "gnome-cmd-types.h"
#include "gnome-cmd-file-list.h"
@@ -58,18 +61,48 @@
struct AdvrenameConfig
{
- History templates;
- GtkTreeModel *regexes;
+ struct Profile
+ {
+ struct Regex
+ {
+ std::string pattern;
+ std::string replace;
+ gboolean match_case;
+
+ Regex(): match_case(FALSE) {}
+ Regex(const gchar *from, const gchar *to, gboolean _match_case): pattern(from),
+ replace(to),
+ match_case(_match_case) {}
+ };
+
+ std::string name;
+ std::string template_string;
+ guint counter_start;
+ guint counter_width;
+ gint counter_step;
+
+ std::vector<Regex> regexes;
+
+ guint case_conversion;
+ guint trim_blanks;
+
+ void reset();
+
+ Profile(): counter_start(1), counter_width(1), counter_step(1),
+ case_conversion(0), trim_blanks(3) {}
+ };
- guint counter_start;
- gint counter_increment;
- guint counter_precision;
gint width, height;
- AdvrenameConfig(): templates(ADVRENAME_HISTORY_SIZE), regexes(NULL),
- counter_start(1), counter_increment(1), counter_precision(1), // defaults for
- width(600), height(400) {} // advrename settings
- ~AdvrenameConfig() { if (regexes) g_object_unref (regexes); }
+ Profile default_profile;
+ std::vector<Profile> profiles;
+
+ History templates;
+ GtkTreeModel *regexes;
+
+ AdvrenameConfig(): width(600), height(400),
+ templates(ADVRENAME_HISTORY_SIZE), regexes(NULL) {}
+ ~AdvrenameConfig() { if (regexes) g_object_unref (regexes); }
};
struct IntViewerConfig
@@ -112,7 +145,6 @@
void save_auto_load_plugins();
void save_cmdline_history();
void save_local_bookmarks();
- void save_rename_history();
void save_search_defaults();
void save_intviewer_defaults();
void save_smb_bookmarks();
Added: trunk/src/gnome-cmd-xml-config.cc
==============================================================================
--- (empty file)
+++ trunk/src/gnome-cmd-xml-config.cc Thu Nov 27 18:15:45 2008
@@ -0,0 +1,655 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2008 Piotr Eljasiak
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+/* gmarkup.c - Simple XML-like parser
+ *
+ * Copyright 2000, 2003 Red Hat, Inc.
+ * Copyright 2007, 2008 Ryan Lortie <desrt desrt ca>
+ *
+ * GLib is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * GLib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GLib; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <stack>
+#include <string>
+#include <algorithm>
+
+#include "gnome-cmd-includes.h"
+#include "gnome-cmd-xml-config.h"
+#include "gnome-cmd-advrename-dialog.h"
+#include "dict.h"
+#include "utils.h"
+
+using namespace std;
+
+
+#if !GLIB_CHECK_VERSION (2, 16, 0)
+typedef enum
+{
+ G_MARKUP_COLLECT_INVALID,
+ G_MARKUP_COLLECT_STRING,
+ G_MARKUP_COLLECT_STRDUP,
+ G_MARKUP_COLLECT_BOOLEAN,
+ G_MARKUP_COLLECT_TRISTATE,
+
+ G_MARKUP_COLLECT_OPTIONAL = (1 << 16)
+} GMarkupCollectType;
+
+
+static gboolean
+g_markup_parse_boolean (const char *string,
+ gboolean *value)
+{
+ char const * const falses[] = { "false", "f", "no", "n", "0" };
+ char const * const trues[] = { "true", "t", "yes", "y", "1" };
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (falses); i++)
+ {
+ if (g_ascii_strcasecmp (string, falses[i]) == 0)
+ {
+ if (value != NULL)
+ *value = FALSE;
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (trues); i++)
+ {
+ if (g_ascii_strcasecmp (string, trues[i]) == 0)
+ {
+ if (value != NULL)
+ *value = TRUE;
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+static
+gboolean
+g_markup_collect_attributes (const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ GError **error,
+ GMarkupCollectType first_type,
+ const gchar *first_attr,
+ ...)
+{
+ GMarkupCollectType type;
+ const gchar *attr;
+ guint64 collected;
+ int written;
+ va_list ap;
+ int i;
+
+ type = first_type;
+ attr = first_attr;
+ collected = 0;
+ written = 0;
+
+ va_start (ap, first_attr);
+ while (type != G_MARKUP_COLLECT_INVALID)
+ {
+ gboolean mandatory;
+ const gchar *value;
+
+ mandatory = !(type & G_MARKUP_COLLECT_OPTIONAL);
+ type &= (G_MARKUP_COLLECT_OPTIONAL - 1);
+
+ /* tristate records a value != TRUE and != FALSE
+ * for the case where the attribute is missing
+ */
+ if (type == G_MARKUP_COLLECT_TRISTATE)
+ mandatory = FALSE;
+
+ for (i = 0; attribute_names[i]; i++)
+ if (i >= 40 || !(collected & (G_GUINT64_CONSTANT(1) << i)))
+ if (!strcmp (attribute_names[i], attr))
+ break;
+
+ /* ISO C99 only promises that the user can pass up to 127 arguments.
+ * Subtracting the first 4 arguments plus the final NULL and dividing
+ * by 3 arguments per collected attribute, we are left with a maximum
+ * number of supported attributes of (127 - 5) / 3 = 40.
+ *
+ * In reality, nobody is ever going to call us with anywhere close to
+ * 40 attributes to collect, so it is safe to assume that if i > 40
+ * then the user has given some invalid or repeated arguments. These
+ * problems will be caught and reported at the end of the function.
+ *
+ * We know at this point that we have an error, but we don't know
+ * what error it is, so just continue...
+ */
+ if (i < 40)
+ collected |= (G_GUINT64_CONSTANT(1) << i);
+
+ value = attribute_values[i];
+
+ if (value == NULL && mandatory)
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "element '%s' requires attribute '%s'",
+ element_name, attr);
+
+ va_end (ap);
+ goto failure;
+ }
+
+ switch (type)
+ {
+ case G_MARKUP_COLLECT_STRING:
+ {
+ const char **str_ptr;
+
+ str_ptr = va_arg (ap, const char **);
+
+ if (str_ptr != NULL)
+ *str_ptr = value;
+ }
+ break;
+
+ case G_MARKUP_COLLECT_STRDUP:
+ {
+ char **str_ptr;
+
+ str_ptr = va_arg (ap, char **);
+
+ if (str_ptr != NULL)
+ *str_ptr = g_strdup (value);
+ }
+ break;
+
+ case G_MARKUP_COLLECT_BOOLEAN:
+ case G_MARKUP_COLLECT_TRISTATE:
+ if (value == NULL)
+ {
+ gboolean *bool_ptr;
+
+ bool_ptr = va_arg (ap, gboolean *);
+
+ if (bool_ptr != NULL)
+ {
+ if (type == G_MARKUP_COLLECT_TRISTATE)
+ /* constructivists rejoice!
+ * neither false nor true...
+ */
+ *bool_ptr = -1;
+
+ else /* G_MARKUP_COLLECT_BOOLEAN */
+ *bool_ptr = FALSE;
+ }
+ }
+ else
+ {
+ if (!g_markup_parse_boolean (value, va_arg (ap, gboolean *)))
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "element '%s', attribute '%s', value '%s' "
+ "cannot be parsed as a boolean value",
+ element_name, attr, value);
+
+ va_end (ap);
+ goto failure;
+ }
+ }
+
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ type = va_arg (ap, GMarkupCollectType);
+ attr = va_arg (ap, const char *);
+ written++;
+ }
+ va_end (ap);
+
+ /* ensure we collected all the arguments */
+ for (i = 0; attribute_names[i]; i++)
+ if ((collected & (G_GUINT64_CONSTANT(1) << i)) == 0)
+ {
+ /* attribute not collected: could be caused by two things.
+ *
+ * 1) it doesn't exist in our list of attributes
+ * 2) it existed but was matched by a duplicate attribute earlier
+ *
+ * find out.
+ */
+ int j;
+
+ for (j = 0; j < i; j++)
+ if (strcmp (attribute_names[i], attribute_names[j]) == 0)
+ /* duplicate! */
+ break;
+
+ /* j is now the first occurance of attribute_names[i] */
+ if (i == j)
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+ "attribute '%s' invalid for element '%s'",
+ attribute_names[i], element_name);
+ else
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "attribute '%s' given multiple times for element '%s'",
+ attribute_names[i], element_name);
+
+ goto failure;
+ }
+
+ return TRUE;
+
+failure:
+ /* replay the above to free allocations */
+ type = first_type;
+ attr = first_attr;
+
+ va_start (ap, first_attr);
+ while (type != G_MARKUP_COLLECT_INVALID)
+ {
+ gpointer ptr;
+
+ ptr = va_arg (ap, gpointer);
+
+ if (ptr == NULL)
+ continue;
+
+ switch (type & (G_MARKUP_COLLECT_OPTIONAL - 1))
+ {
+ case G_MARKUP_COLLECT_STRDUP:
+ if (written)
+ g_free (*(char **) ptr);
+
+ case G_MARKUP_COLLECT_STRING:
+ *(char **) ptr = NULL;
+ break;
+
+ case G_MARKUP_COLLECT_BOOLEAN:
+ *(gboolean *) ptr = FALSE;
+ break;
+
+ case G_MARKUP_COLLECT_TRISTATE:
+ *(gboolean *) ptr = -1;
+ break;
+ }
+
+ type = va_arg (ap, GMarkupCollectType);
+ attr = va_arg (ap, const char *);
+
+ if (written)
+ written--;
+ }
+ va_end (ap);
+
+ return FALSE;
+}
+#endif
+
+
+enum {XML_ELEM_NOT_FOUND,
+ XML_GNOMECOMMANDER,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_WINDOWSIZE,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TEMPLATE,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_COUNTER,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES_REGEX,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_CASECONVERSION,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TRIMBLANKS,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY,
+ XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY_TEMPLATE};
+
+
+static DICT<guint> xml_elem_names(XML_ELEM_NOT_FOUND);
+static stack<string> xml_paths;
+
+static GnomeCmdData::AdvrenameConfig::Profile xml_profile;
+
+
+static bool is_default(GnomeCmdData::AdvrenameConfig::Profile &profile)
+{
+ return strcmp(profile.name.c_str(),"Default")==0;
+}
+
+
+static void xml_start(GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
+ string element_path;
+
+ if (!xml_paths.empty())
+ element_path = xml_paths.top();
+
+ element_path += G_DIR_SEPARATOR;
+ element_path += element_name;
+
+ xml_paths.push(element_path);
+
+ GnomeCmdData *cfg = (GnomeCmdData *) user_data;
+ gchar *param1, *param2, *param3;
+ gboolean param4;
+
+ switch (xml_elem_names[xml_paths.top()])
+ {
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_WINDOWSIZE:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "width", ¶m1,
+ G_MARKUP_COLLECT_STRING, "height", ¶m2,
+ G_MARKUP_COLLECT_INVALID))
+ {
+ cfg->advrename_defaults.width = atoi(param1);
+ cfg->advrename_defaults.height = atoi(param2);
+ }
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "name", ¶m1,
+ G_MARKUP_COLLECT_INVALID))
+ {
+ xml_profile.reset();
+ xml_profile.name = param1; // FIXME: unescape text
+ }
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_COUNTER:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "start", ¶m1,
+ G_MARKUP_COLLECT_STRING, "step", ¶m2,
+ G_MARKUP_COLLECT_STRING, "width", ¶m3,
+ G_MARKUP_COLLECT_INVALID))
+ {
+ xml_profile.counter_start = atoi(param1);
+ xml_profile.counter_step = atoi(param2);
+ xml_profile.counter_width = atoi(param3);
+ }
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES:
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES_REGEX:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "pattern", ¶m1,
+ G_MARKUP_COLLECT_STRING, "replace", ¶m2,
+ G_MARKUP_COLLECT_BOOLEAN, "match-case", ¶m4,
+ G_MARKUP_COLLECT_INVALID))
+ {
+ // FIXME: unescape param1
+ // FIXME: unescape param2
+
+ xml_profile.regexes.push_back(GnomeCmdData::AdvrenameConfig::Profile::Regex(param1, param2, param4));
+ }
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_CASECONVERSION:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "use", ¶m1,
+ G_MARKUP_COLLECT_INVALID))
+ xml_profile.case_conversion = atoi(param1);
+ else
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TRIMBLANKS:
+ if (g_markup_collect_attributes (element_name, attribute_names, attribute_values, error,
+ G_MARKUP_COLLECT_STRING, "use", ¶m1,
+ G_MARKUP_COLLECT_INVALID))
+ xml_profile.trim_blanks = atoi(param1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+static void xml_end (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
+{
+ GnomeCmdData *cfg = (GnomeCmdData *) user_data;
+
+ switch (xml_elem_names[xml_paths.top()])
+ {
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE:
+ cfg->advrename_defaults.profiles.push_back(xml_profile);
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL:
+ {
+ vector<GnomeCmdData::AdvrenameConfig::Profile>::iterator p;
+
+ p = find_if (cfg->advrename_defaults.profiles.begin(), cfg->advrename_defaults.profiles.end(), is_default);
+
+ if (p!=cfg->advrename_defaults.profiles.end())
+ {
+ GtkTreeIter iter;
+
+ cfg->advrename_defaults.default_profile = *p;
+
+ for (std::vector<GnomeCmdData::AdvrenameConfig::Profile::Regex>::const_iterator r=p->regexes.begin(); r!=p->regexes.end(); ++r)
+ {
+ GnomeCmdAdvrenameDialog::Regex *rx = new GnomeCmdAdvrenameDialog::Regex(r->pattern.c_str(),r->replace.c_str(), r->match_case);
+
+ gtk_list_store_append (GTK_LIST_STORE (cfg->advrename_defaults.regexes), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (cfg->advrename_defaults.regexes), &iter,
+ GnomeCmdAdvrenameDialog::COL_REGEX, rx,
+ GnomeCmdAdvrenameDialog::COL_MALFORMED_REGEX, !*rx,
+ GnomeCmdAdvrenameDialog::COL_PATTERN, r->pattern.c_str(),
+ GnomeCmdAdvrenameDialog::COL_REPLACE, r->replace.c_str(),
+ GnomeCmdAdvrenameDialog::COL_MATCH_CASE, r->match_case ? _("Yes") : _("No"),
+ -1);
+ }
+
+ cfg->advrename_defaults.profiles.erase(p);
+ }
+ }
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY:
+ cfg->advrename_defaults.templates.reverse();
+ break;
+
+ default:
+ break;
+ }
+
+ xml_paths.pop();
+}
+
+
+ static void xml_element (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ GnomeCmdData *cfg = (GnomeCmdData *) user_data;
+
+ switch (xml_elem_names[xml_paths.top()])
+ {
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TEMPLATE:
+ // FIXME: unescape text
+ xml_profile.template_string = text;
+ break;
+
+ case XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY_TEMPLATE:
+ // FIXME: unescape text
+ cfg->advrename_defaults.templates.add(text);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+gboolean gnome_cmd_xml_config_load (const gchar *path, GnomeCmdData &cfg)
+{
+ static GMarkupParser parser = {xml_start, xml_end, xml_element};
+
+ char *xml = NULL;
+ gsize xml_len = 0;
+ GError *error = NULL;
+
+ if (!g_file_get_contents (path, &xml, &xml_len, &error))
+ {
+ g_warning (error->message);
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ static struct
+ {
+ guint id;
+ const gchar *path;
+ }
+ xml_elem_data[] = {
+ {XML_GNOMECOMMANDER, "/GnomeCommander"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL, "/GnomeCommander/AdvancedRenameTool"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_WINDOWSIZE, "/GnomeCommander/AdvancedRenameTool/WindowSize"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE, "/GnomeCommander/AdvancedRenameTool/Profile"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TEMPLATE, "/GnomeCommander/AdvancedRenameTool/Profile/Template"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_COUNTER, "/GnomeCommander/AdvancedRenameTool/Profile/Counter"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES, "/GnomeCommander/AdvancedRenameTool/Profile/Regexes"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_REGEXES_REGEX, "/GnomeCommander/AdvancedRenameTool/Profile/Regexes/Regex"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_CASECONVERSION, "/GnomeCommander/AdvancedRenameTool/Profile/CaseConversion"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_PROFILE_TRIMBLANKS, "/GnomeCommander/AdvancedRenameTool/Profile/TrimBlanks"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY, "/GnomeCommander/AdvancedRenameTool/TemplateHistory"},
+ {XML_GNOMECOMMANDER_ADVANCEDRENAMETOOL_TEMPLATEHISTORY_TEMPLATE, "/GnomeCommander/AdvancedRenameTool/TemplateHistory/Template"}
+ };
+
+ load_data (xml_elem_names, xml_elem_data, G_N_ELEMENTS(xml_elem_data));
+
+ if (xml_len==-1)
+ xml_len = strlen (xml);
+
+ GMarkupParseContext *context = g_markup_parse_context_new (&parser, GMarkupParseFlags(0), &cfg, NULL);
+
+ if (!g_markup_parse_context_parse (context, xml, xml_len, &error) ||
+ !g_markup_parse_context_end_parse (context, &error))
+ {
+ g_warning (error->message);
+ g_error_free (error);
+ }
+
+ g_markup_parse_context_free (context);
+ g_free (xml);
+
+ // FIXME: "Default" template
+
+ return error==NULL;
+}
+
+
+void gnome_cmd_xml_config_save (const gchar *path, GnomeCmdData &cfg)
+{
+ FILE *f = fopen(path,"w");
+
+ if (!f)
+ return;
+
+ GtkTreeIter i;
+
+ fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", f);
+ fputs("<GnomeCommander version=\"" VERSION "\">\n", f);
+ fputs("\t<AdvancedRenameTool>\n", f);
+ fprintf (f, "\t\t<WindowSize width=\"%i\" height=\"%i\" />\n", cfg.advrename_defaults.width, cfg.advrename_defaults.height);
+
+ fprintf(f, "\t\t<Profile name=\"%s\">\n", "Default");
+ fprintf(f, "\t\t\t<Template>%s</Template>\n", cfg.advrename_defaults.templates.empty() ? "$N" : cfg.advrename_defaults.templates.front());
+ fprintf(f, "\t\t\t<Counter start=\"%u\" step=\"%i\" width=\"%u\" />\n", cfg.advrename_defaults.default_profile.counter_start,
+ cfg.advrename_defaults.default_profile.counter_step,
+ cfg.advrename_defaults.default_profile.counter_width);
+ fputs("\t\t\t<Regexes>\n", f);
+
+ for (gboolean valid_iter=gtk_tree_model_get_iter_first (cfg.advrename_defaults.regexes, &i); valid_iter; valid_iter=gtk_tree_model_iter_next (cfg.advrename_defaults.regexes, &i))
+ {
+ GnomeCmdAdvrenameDialog::Regex *rx;
+
+ gtk_tree_model_get (cfg.advrename_defaults.regexes, &i,
+ GnomeCmdAdvrenameDialog::COL_REGEX, &rx,
+ -1);
+ if (!rx)
+ continue;
+
+ fprintf(f, "\t\t\t\t<Regex pattern=\"%s\" replace=\"%s\" match-case=\"%u\" />\n", rx->from.c_str(), rx->to.c_str(), rx->case_sensitive);
+ }
+
+ fputs("\t\t\t</Regexes>\n", f);
+ fprintf(f, "\t\t\t<CaseConversion use=\"%u\" />\n", cfg.advrename_defaults.default_profile.case_conversion);
+ fprintf(f, "\t\t\t<TrimBlanks use=\"%u\" />\n", cfg.advrename_defaults.default_profile.trim_blanks);
+ fputs("\t\t</Profile>\n", f);
+
+ for (std::vector<GnomeCmdData::AdvrenameConfig::Profile>::const_iterator p=cfg.advrename_defaults.profiles.begin(); p!=cfg.advrename_defaults.profiles.end(); ++p)
+ {
+ fprintf(f, "\t\t<Profile name=\"%s\">\n", p->name.c_str());
+ fprintf(f, "\t\t\t<Template>%s</Template>\n", p->template_string.empty() ? "$N" : p->template_string.c_str());
+ fprintf(f, "\t\t\t<Counter start=\"%u\" step=\"%i\" width=\"%u\" />\n", p->counter_start, p->counter_step, p->counter_width);
+ fputs("\t\t\t<Regexes>\n", f);
+ for (std::vector<GnomeCmdData::AdvrenameConfig::Profile::Regex>::const_iterator r=p->regexes.begin(); r!=p->regexes.end(); ++r)
+ fprintf(f, "\t\t\t\t<Regex pattern=\"%s\" replace=\"%s\" match-case=\"%u\" />\n", r->pattern.c_str(), r->replace.c_str(), r->match_case);
+ fputs("\t\t\t</Regexes>\n", f);
+ fprintf(f, "\t\t\t<CaseConversion use=\"%u\" />\n", p->case_conversion);
+ fprintf(f, "\t\t\t<TrimBlanks use=\"%u\" />\n", p->trim_blanks);
+ fputs("\t\t</Profile>\n", f);
+ }
+
+ fputs("\t\t<TemplateHistory>\n", f);
+
+ for (GList *i=cfg.advrename_defaults.templates.ents; i; i=i->next)
+ fprintf (f, "\t\t\t<Template>%s</Template>\n", (const gchar *) i->data);
+
+ fputs("\t\t</TemplateHistory>\n", f);
+ fputs("\t</AdvancedRenameTool>\n", f);
+ fputs("</GnomeCommander>\n", f);
+ fputs("", f);
+
+ fclose(f);
+}
Added: trunk/src/gnome-cmd-xml-config.h
==============================================================================
--- (empty file)
+++ trunk/src/gnome-cmd-xml-config.h Thu Nov 27 18:15:45 2008
@@ -0,0 +1,29 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2008 Piotr Eljasiak
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __GNOME_CMD_XML_CONFIG_H__
+#define __GNOME_CMD_XML_CONFIG_H__
+
+#include "gnome-cmd-data.h"
+
+gboolean gnome_cmd_xml_config_load (const gchar *path, GnomeCmdData &cfg);
+void gnome_cmd_xml_config_save (const gchar *path, GnomeCmdData &cfg);
+
+#endif // __GNOME_CMD_XML_CONFIG_H__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]