[metacity] theme: cleanup text_handler function
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] theme: cleanup text_handler function
- Date: Sat, 23 Jan 2016 18:16:43 +0000 (UTC)
commit aedf0177a23987389f6a567922818a36d21acac3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Jan 23 18:26:25 2016 +0200
theme: cleanup text_handler function
src/ui/theme-parser.c | 104 +++++++------------------------------------------
1 files changed, 15 insertions(+), 89 deletions(-)
---
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 1d4869a..5eb5a30 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -3728,8 +3728,6 @@ end_element_handler (GMarkupParseContext *context,
pop_required_version (info);
}
-#define NO_TEXT(element_name) set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, _("No text is
allowed inside element <%s>"), element_name)
-
static gboolean
all_whitespace (const char *text,
int text_len)
@@ -3766,28 +3764,16 @@ text_handler (GMarkupParseContext *context,
if (all_whitespace (text, text_len))
return;
- /* FIXME http://bugzilla.gnome.org/show_bug.cgi?id=70448 would
- * allow a nice cleanup here.
- */
-
switch (peek_state (info))
{
case STATE_START:
g_assert_not_reached (); /* gmarkup shouldn't do this */
break;
- case STATE_THEME:
- NO_TEXT ("metacity_theme");
- break;
- case STATE_INFO:
- NO_TEXT ("info");
- break;
case STATE_NAME:
if (info->theme->readable_name != NULL)
{
- set_error (error, context, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- _("<%s> specified twice for this theme"),
- "name");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("<%s> specified twice for this theme"), "name");
return;
}
@@ -3796,10 +3782,8 @@ text_handler (GMarkupParseContext *context,
case STATE_AUTHOR:
if (info->theme->author != NULL)
{
- set_error (error, context, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- _("<%s> specified twice for this theme"),
- "author");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("<%s> specified twice for this theme"), "author");
return;
}
@@ -3808,10 +3792,8 @@ text_handler (GMarkupParseContext *context,
case STATE_COPYRIGHT:
if (info->theme->copyright != NULL)
{
- set_error (error, context, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- _("<%s> specified twice for this theme"),
- "copyright");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("<%s> specified twice for this theme"), "copyright");
return;
}
@@ -3820,10 +3802,8 @@ text_handler (GMarkupParseContext *context,
case STATE_DATE:
if (info->theme->date != NULL)
{
- set_error (error, context, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- _("<%s> specified twice for this theme"),
- "date");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("<%s> specified twice for this theme"), "date");
return;
}
@@ -3832,101 +3812,47 @@ text_handler (GMarkupParseContext *context,
case STATE_DESCRIPTION:
if (info->theme->description != NULL)
{
- set_error (error, context, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- _("<%s> specified twice for this theme"),
- "description");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("<%s> specified twice for this theme"), "description");
return;
}
info->theme->description = g_strndup (text, text_len);
break;
+ case STATE_THEME:
+ case STATE_INFO:
case STATE_CONSTANT:
- NO_TEXT ("constant");
- break;
case STATE_FRAME_GEOMETRY:
- NO_TEXT ("frame_geometry");
- break;
case STATE_DISTANCE:
- NO_TEXT ("distance");
- break;
case STATE_BORDER:
- NO_TEXT ("border");
- break;
case STATE_ASPECT_RATIO:
- NO_TEXT ("aspect_ratio");
- break;
case STATE_DRAW_OPS:
- NO_TEXT ("draw_ops");
- break;
case STATE_LINE:
- NO_TEXT ("line");
- break;
case STATE_RECTANGLE:
- NO_TEXT ("rectangle");
- break;
case STATE_ARC:
- NO_TEXT ("arc");
- break;
case STATE_CLIP:
- NO_TEXT ("clip");
- break;
case STATE_TINT:
- NO_TEXT ("tint");
- break;
case STATE_GRADIENT:
- NO_TEXT ("gradient");
- break;
case STATE_IMAGE:
- NO_TEXT ("image");
- break;
case STATE_GTK_ARROW:
- NO_TEXT ("gtk_arrow");
- break;
case STATE_GTK_BOX:
- NO_TEXT ("gtk_box");
- break;
case STATE_GTK_VLINE:
- NO_TEXT ("gtk_vline");
- break;
case STATE_ICON:
- NO_TEXT ("icon");
- break;
case STATE_TITLE:
- NO_TEXT ("title");
- break;
case STATE_INCLUDE:
- NO_TEXT ("include");
- break;
case STATE_TILE:
- NO_TEXT ("tile");
- break;
case STATE_COLOR:
- NO_TEXT ("color");
- break;
case STATE_FRAME_STYLE:
- NO_TEXT ("frame_style");
- break;
case STATE_PIECE:
- NO_TEXT ("piece");
- break;
case STATE_BUTTON:
- NO_TEXT ("button");
- break;
case STATE_MENU_ICON:
- NO_TEXT ("menu_icon");
- break;
case STATE_FRAME_STYLE_SET:
- NO_TEXT ("frame_style_set");
- break;
case STATE_FRAME:
- NO_TEXT ("frame");
- break;
case STATE_WINDOW:
- NO_TEXT ("window");
- break;
case STATE_FALLBACK:
- NO_TEXT ("fallback");
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("No text is allowed inside element <%s>"),
+ g_markup_parse_context_get_element (context));
break;
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]