gimp r24832 - in trunk: . app/dialogs app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24832 - in trunk: . app/dialogs app/widgets
- Date: Fri, 8 Feb 2008 12:28:37 +0000 (GMT)
Author: neo
Date: Fri Feb 8 12:28:36 2008
New Revision: 24832
URL: http://svn.gnome.org/viewvc/gimp?rev=24832&view=rev
Log:
2008-02-08 Sven Neumann <sven gimp org>
* app/widgets/gimplanguagestore-parser.c: implemented the parser.
* app/dialogs/tips-parser.c: minor cleanup.
Modified:
trunk/ChangeLog
trunk/app/dialogs/tips-parser.c
trunk/app/widgets/gimplanguagestore-parser.c
Modified: trunk/app/dialogs/tips-parser.c
==============================================================================
--- trunk/app/dialogs/tips-parser.c (original)
+++ trunk/app/dialogs/tips-parser.c Fri Feb 8 12:28:36 2008
@@ -296,7 +296,7 @@
switch (parser->state)
{
case TIPS_START:
- g_warning ("tips_parser: This shouldn't happen.\n");
+ g_warning ("%s: shouldn't get here", G_STRLOC);
break;
case TIPS_IN_TIPS:
Modified: trunk/app/widgets/gimplanguagestore-parser.c
==============================================================================
--- trunk/app/widgets/gimplanguagestore-parser.c (original)
+++ trunk/app/widgets/gimplanguagestore-parser.c Fri Feb 8 12:28:36 2008
@@ -48,6 +48,8 @@
gint unknown_depth;
GString *value;
GimpLanguageStore *store;
+ gchar *language;
+ gchar *code;
} IsoCodesParser;
@@ -61,11 +63,6 @@
const gchar *element_name,
gpointer user_data,
GError **error);
-static void iso_codes_parser_characters (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
static void iso_codes_parser_start_unknown (IsoCodesParser *parser);
static void iso_codes_parser_end_unknown (IsoCodesParser *parser);
@@ -75,7 +72,7 @@
{
iso_codes_parser_start_element,
iso_codes_parser_end_element,
- iso_codes_parser_characters,
+ NULL, /* characters */
NULL, /* passthrough */
NULL /* error */
};
@@ -88,6 +85,7 @@
#ifdef HAVE_ISO_CODES
GimpXmlParser *xml_parser;
gchar *filename;
+ gboolean success;
IsoCodesParser parser = { 0, };
g_return_val_if_fail (GIMP_IS_LANGUAGE_STORE (store), FALSE);
@@ -99,17 +97,43 @@
filename = g_build_filename (ISO_CODES_LOCATION, "iso_639.xml", NULL);
- gimp_xml_parser_parse_file (xml_parser, filename, error);
+ success = gimp_xml_parser_parse_file (xml_parser, filename, error);
gimp_xml_parser_free (xml_parser);
g_free (filename);
g_string_free (parser.value, TRUE);
+
+ return success;
#endif
return TRUE;
}
static void
+iso_codes_parser_entry (IsoCodesParser *parser,
+ const gchar **names,
+ const gchar **values)
+{
+ const gchar *lang = NULL;
+ const gchar *code = NULL;
+
+ while (*names && *values)
+ {
+ if (strcmp (*names, "name") == 0)
+ {
+ lang = *values;
+ }
+ else if (strcmp (*names, "iso_639_1_code") == 0)
+ {
+ code = *values;
+ }
+
+ names++;
+ values++;
+ }
+}
+
+static void
iso_codes_parser_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -121,7 +145,23 @@
switch (parser->state)
{
- default:
+ case ISO_CODES_START:
+ if (strcmp (element_name, "iso_639_entries") == 0)
+ {
+ parser->state = ISO_CODES_IN_ENTRIES;
+ break;
+ }
+
+ case ISO_CODES_IN_ENTRIES:
+ if (strcmp (element_name, "iso_639_entry") == 0)
+ {
+ parser->state = ISO_CODES_IN_ENTRY;
+ iso_codes_parser_entry (parser, attribute_names, attribute_values);
+ break;
+ }
+
+ case ISO_CODES_IN_ENTRY:
+ case ISO_CODES_IN_UNKNOWN:
iso_codes_parser_start_unknown (parser);
break;
}
@@ -137,24 +177,20 @@
switch (parser->state)
{
- default:
- iso_codes_parser_end_unknown (parser);
+ case ISO_CODES_START:
+ g_warning ("%s: shouldn't get here", G_STRLOC);
break;
- }
-}
-static void
-iso_codes_parser_characters (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- IsoCodesParser *parser = user_data;
+ case ISO_CODES_IN_ENTRIES:
+ parser->state = ISO_CODES_START;
+ break;
- switch (parser->state)
- {
- default:
+ case ISO_CODES_IN_ENTRY:
+ parser->state = ISO_CODES_IN_ENTRIES;
+ break;
+
+ case ISO_CODES_IN_UNKNOWN:
+ iso_codes_parser_end_unknown (parser);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]