gnome-commander r2330 - in branches/gcmd-1-3: . src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2330 - in branches/gcmd-1-3: . src
- Date: Mon, 1 Dec 2008 20:07:28 +0000 (UTC)
Author: epiotr
Date: Mon Dec 1 20:07:27 2008
New Revision: 2330
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2330&view=rev
Log:
Added gnome_cmd_xml_config_parse() function
Modified:
branches/gcmd-1-3/ChangeLog
branches/gcmd-1-3/src/gnome-cmd-xml-config.cc
branches/gcmd-1-3/src/gnome-cmd-xml-config.h
Modified: branches/gcmd-1-3/src/gnome-cmd-xml-config.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-xml-config.cc (original)
+++ branches/gcmd-1-3/src/gnome-cmd-xml-config.cc Mon Dec 1 20:07:27 2008
@@ -513,22 +513,10 @@
}
-gboolean gnome_cmd_xml_config_load (const gchar *path, GnomeCmdData &cfg)
+gboolean gnome_cmd_xml_config_parse (const gchar *xml, gsize xml_len, 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;
@@ -556,6 +544,8 @@
GMarkupParseContext *context = g_markup_parse_context_new (&parser, GMarkupParseFlags(0), &cfg, NULL);
+ GError *error = NULL;
+
if (!g_markup_parse_context_parse (context, xml, xml_len, &error) ||
!g_markup_parse_context_end_parse (context, &error))
{
@@ -564,7 +554,6 @@
}
g_markup_parse_context_free (context);
- g_free (xml);
// FIXME: "Default" template
@@ -572,6 +561,29 @@
}
+gboolean gnome_cmd_xml_config_load (const gchar *path, GnomeCmdData &cfg)
+{
+ gchar *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;
+ }
+
+ gboolean retval = gnome_cmd_xml_config_parse (xml, xml_len, cfg);
+
+ g_free (xml);
+
+ return retval;
+}
+
+
void gnome_cmd_xml_config_save (const gchar *path, GnomeCmdData &cfg)
{
FILE *f = fopen(path,"w");
Modified: branches/gcmd-1-3/src/gnome-cmd-xml-config.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-xml-config.h (original)
+++ branches/gcmd-1-3/src/gnome-cmd-xml-config.h Mon Dec 1 20:07:27 2008
@@ -23,6 +23,7 @@
#include "gnome-cmd-data.h"
+gboolean gnome_cmd_xml_config_parse (const gchar *xml, gsize xml_len, GnomeCmdData &cfg);
gboolean gnome_cmd_xml_config_load (const gchar *path, GnomeCmdData &cfg);
void gnome_cmd_xml_config_save (const gchar *path, GnomeCmdData &cfg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]