theme-parser.c File Reference

Go to the source code of this file.

Data Structures

struct  ParseInfo
struct  LocateAttr

Defines

#define ELEMENT_IS(name)   (strcmp (element_name, (name)) == 0)
#define MAX_ATTRS   24
#define MAX_REASONABLE   4096
#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)
#define THEME_SUBDIR   "metacity-1"
#define THEME_VERSION   2
#define METACITY_THEME_FILENAME_FORMAT   "metacity-theme-%d.xml"

Enumerations

enum  ParseState {
  STATE_START, STATE_THEME, STATE_INFO, STATE_NAME,
  STATE_AUTHOR, STATE_COPYRIGHT, STATE_DATE, STATE_DESCRIPTION,
  STATE_CONSTANT, STATE_FRAME_GEOMETRY, STATE_DISTANCE, STATE_BORDER,
  STATE_ASPECT_RATIO, STATE_DRAW_OPS, STATE_LINE, STATE_RECTANGLE,
  STATE_ARC, STATE_CLIP, STATE_TINT, STATE_GRADIENT,
  STATE_IMAGE, STATE_GTK_ARROW, STATE_GTK_BOX, STATE_GTK_VLINE,
  STATE_ICON, STATE_TITLE, STATE_INCLUDE, STATE_TILE,
  STATE_COLOR, STATE_FRAME_STYLE, STATE_PIECE, STATE_BUTTON,
  STATE_FRAME_STYLE_SET, STATE_FRAME, STATE_WINDOW, STATE_MENU_ICON,
  STATE_FALLBACK
}

Functions

static void set_error (GError **err, GMarkupParseContext *context, int error_domain, int error_code, const char *format,...) G_GNUC_PRINTF(5
static void static void add_context_to_error (GError **err, GMarkupParseContext *context)
static void parse_info_init (ParseInfo *info)
static void parse_info_free (ParseInfo *info)
static void push_state (ParseInfo *info, ParseState state)
static void pop_state (ParseInfo *info)
static ParseState peek_state (ParseInfo *info)
static void parse_toplevel_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_info_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_geometry_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_draw_op_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_gradient_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_style_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_style_set_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_piece_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_button_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_menu_icon_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void start_element_handler (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error)
static void end_element_handler (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error)
static void text_handler (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error)
static gboolean locate_attributes (GMarkupParseContext *context, const char *element_name, const char **attribute_names, const char **attribute_values, GError **error, const char *first_attribute_name, const char **first_attribute_retloc,...)
static gboolean check_no_attributes (GMarkupParseContext *context, const char *element_name, const char **attribute_names, const char **attribute_values, GError **error)
static gboolean parse_positive_integer (const char *str, int *val, GMarkupParseContext *context, MetaTheme *theme, GError **error)
static gboolean parse_double (const char *str, double *val, GMarkupParseContext *context, GError **error)
static gboolean parse_boolean (const char *str, gboolean *val, GMarkupParseContext *context, GError **error)
static gboolean parse_rounding (const char *str, guint *val, GMarkupParseContext *context, MetaTheme *theme, GError **error)
static gboolean parse_angle (const char *str, double *val, GMarkupParseContext *context, GError **error)
static gboolean parse_alpha (const char *str, MetaAlphaGradientSpec **spec_ret, GMarkupParseContext *context, GError **error)
static MetaColorSpecparse_color (MetaTheme *theme, const char *str, GError **err)
static gboolean parse_title_scale (const char *str, double *val, GMarkupParseContext *context, GError **error)
static void parse_distance (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_aspect_ratio (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static void parse_border (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error)
static gboolean all_whitespace (const char *text, int text_len)
MetaThememeta_theme_load (const char *theme_name, GError **err)

Variables

static GMarkupParser metacity_theme_parser


Define Documentation

#define ELEMENT_IS ( name   )     (strcmp (element_name, (name)) == 0)

#define MAX_ATTRS   24

Referenced by locate_attributes().

#define MAX_REASONABLE   4096

Definition at line 447 of file theme-parser.c.

Referenced by parse_positive_integer().

#define METACITY_THEME_FILENAME_FORMAT   "metacity-theme-%d.xml"

Definition at line 4477 of file theme-parser.c.

Referenced by meta_theme_load().

#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)

Definition at line 4270 of file theme-parser.c.

Referenced by text_handler().

#define THEME_SUBDIR   "metacity-1"

Definition at line 4470 of file theme-parser.c.

Referenced by meta_theme_load().

#define THEME_VERSION   2

Definition at line 4475 of file theme-parser.c.

Referenced by meta_theme_load().


Enumeration Type Documentation

enum ParseState

Enumerator:
STATE_START 
STATE_THEME 
STATE_INFO 
STATE_NAME 
STATE_AUTHOR 
STATE_COPYRIGHT 
STATE_DATE 
STATE_DESCRIPTION 
STATE_CONSTANT 
STATE_FRAME_GEOMETRY 
STATE_DISTANCE 
STATE_BORDER 
STATE_ASPECT_RATIO 
STATE_DRAW_OPS 
STATE_LINE 
STATE_RECTANGLE 
STATE_ARC 
STATE_CLIP 
STATE_TINT 
STATE_GRADIENT 
STATE_IMAGE 
STATE_GTK_ARROW 
STATE_GTK_BOX 
STATE_GTK_VLINE 
STATE_ICON 
STATE_TITLE 
STATE_INCLUDE 
STATE_TILE 
STATE_COLOR 
STATE_FRAME_STYLE 
STATE_PIECE 
STATE_BUTTON 
STATE_FRAME_STYLE_SET 
STATE_FRAME 
STATE_WINDOW 
STATE_MENU_ICON 
STATE_FALLBACK 

Definition at line 30 of file theme-parser.c.


Function Documentation

static void add_context_to_error ( GError **  err,
GMarkupParseContext *  context 
) [static]

Definition at line 234 of file theme-parser.c.

References _, and NULL.

Referenced by end_element_handler(), parse_draw_op_element(), parse_gradient_element(), and parse_toplevel_element().

static gboolean all_whitespace ( const char *  text,
int  text_len 
) [static]

Definition at line 4273 of file theme-parser.c.

References FALSE, and TRUE.

Referenced by text_handler().

static gboolean check_no_attributes ( GMarkupParseContext *  context,
const char *  element_name,
const char **  attribute_names,
const char **  attribute_values,
GError **  error 
) [static]

static void end_element_handler ( GMarkupParseContext *  context,
const gchar *  element_name,
gpointer  user_data,
GError **  error 
) [static]

static gboolean locate_attributes ( GMarkupParseContext *  context,
const char *  element_name,
const char **  attribute_names,
const char **  attribute_values,
GError **  error,
const char *  first_attribute_name,
const char **  first_attribute_retloc,
  ... 
) [static]

MetaTheme* meta_theme_load ( const char *  theme_name,
GError **  err 
)

static gboolean parse_alpha ( const char *  str,
MetaAlphaGradientSpec **  spec_ret,
GMarkupParseContext *  context,
GError **  error 
) [static]

static gboolean parse_angle ( const char *  str,
double *  val,
GMarkupParseContext *  context,
GError **  error 
) [static]

Definition at line 611 of file theme-parser.c.

References _, FALSE, parse_double(), set_error(), and TRUE.

Referenced by parse_draw_op_element().

static void parse_aspect_ratio ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static gboolean parse_boolean ( const char *  str,
gboolean *  val,
GMarkupParseContext *  context,
GError **  error 
) [static]

Definition at line 554 of file theme-parser.c.

References _, FALSE, set_error(), and TRUE.

Referenced by parse_draw_op_element(), and parse_toplevel_element().

static void parse_border ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_button_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static MetaColorSpec* parse_color ( MetaTheme theme,
const char *  str,
GError **  err 
) [static]

static void parse_distance ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static gboolean parse_double ( const char *  str,
double *  val,
GMarkupParseContext *  context,
GError **  error 
) [static]

Definition at line 519 of file theme-parser.c.

References _, FALSE, NULL, set_error(), and TRUE.

Referenced by parse_alpha(), parse_angle(), parse_aspect_ratio(), and parse_toplevel_element().

static void parse_draw_op_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

Definition at line 1697 of file theme-parser.c.

References _, add_context_to_error(), _MetaDrawOp::arc, _MetaDrawOp::clip, _MetaDrawOp::data, ELEMENT_IS, FALSE, _MetaDrawOp::gradient, _MetaDrawOp::gtk_arrow, _MetaDrawOp::gtk_box, _MetaDrawOp::gtk_vline, _MetaDrawOp::icon, _MetaDrawOp::image, _MetaDrawOp::line, locate_attributes(), meta_alpha_gradient_spec_free(), META_DRAW_ARC, META_DRAW_CLIP, META_DRAW_GRADIENT, META_DRAW_GTK_ARROW, META_DRAW_GTK_BOX, META_DRAW_GTK_VLINE, META_DRAW_ICON, META_DRAW_IMAGE, META_DRAW_LINE, META_DRAW_OP_LIST, meta_draw_op_list_append(), meta_draw_op_list_contains(), meta_draw_op_list_ref(), meta_draw_op_new(), META_DRAW_RECTANGLE, meta_draw_spec_new(), META_DRAW_TILE, META_DRAW_TINT, META_DRAW_TITLE, META_GRADIENT_LAST, meta_gradient_spec_new(), meta_gradient_type_from_string(), meta_gtk_arrow_from_string(), meta_gtk_shadow_from_string(), meta_gtk_state_from_string(), META_IMAGE_FILL_SCALE, meta_image_fill_type_from_string(), META_THEME_ALLOWS, META_THEME_DEGREES_IN_ARCS, meta_theme_load_image(), meta_theme_lookup_draw_op_list(), NULL, ParseInfo::op, _MetaDrawOp::op_list, ParseInfo::op_list, parse_alpha(), parse_angle(), parse_boolean(), parse_color(), parse_positive_integer(), peek_state(), push_state(), _MetaDrawOp::rectangle, set_error(), STATE_ARC, STATE_CLIP, STATE_DRAW_OPS, STATE_GRADIENT, STATE_GTK_ARROW, STATE_GTK_BOX, STATE_GTK_VLINE, STATE_ICON, STATE_IMAGE, STATE_INCLUDE, STATE_LINE, STATE_RECTANGLE, STATE_TILE, STATE_TINT, STATE_TITLE, ParseInfo::theme, _MetaDrawOp::tile, _MetaDrawOp::tint, _MetaDrawOp::title, and TRUE.

Referenced by start_element_handler().

static void parse_geometry_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_gradient_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_info_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_info_free ( ParseInfo info  )  [static]

static void parse_info_init ( ParseInfo info  )  [static]

static void parse_menu_icon_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_piece_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static gboolean parse_positive_integer ( const char *  str,
int *  val,
GMarkupParseContext *  context,
MetaTheme theme,
GError **  error 
) [static]

static gboolean parse_rounding ( const char *  str,
guint *  val,
GMarkupParseContext *  context,
MetaTheme theme,
GError **  error 
) [static]

static void parse_style_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static void parse_style_set_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

static gboolean parse_title_scale ( const char *  str,
double *  val,
GMarkupParseContext *  context,
GError **  error 
) [static]

Definition at line 726 of file theme-parser.c.

References _, FALSE, set_error(), and TRUE.

Referenced by parse_toplevel_element().

static void parse_toplevel_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
ParseInfo info,
GError **  error 
) [static]

Definition at line 761 of file theme-parser.c.

References _, add_context_to_error(), _MetaAlphaGradientSpec::alphas, _MetaFrameLayout::bottom_left_corner_rounded_radius, _MetaFrameLayout::bottom_right_corner_rounded_radius, check_no_attributes(), ELEMENT_IS, _MetaTheme::fallback_icon, _MetaTheme::fallback_mini_icon, FALSE, _MetaFrameLayout::has_title, _MetaFrameLayout::hide_buttons, _MetaFrameStyle::layout, ParseInfo::layout, locate_attributes(), meta_alpha_gradient_spec_free(), meta_color_spec_new_from_string(), meta_draw_op_list_new(), meta_frame_layout_copy(), meta_frame_layout_new(), meta_frame_layout_ref(), meta_frame_style_new(), meta_frame_style_set_new(), meta_frame_style_set_ref(), meta_frame_type_from_string(), META_FRAME_TYPE_LAST, META_THEME_ALLOWS, meta_theme_define_color_constant(), meta_theme_define_float_constant(), meta_theme_define_int_constant(), META_THEME_FRAME_BACKGROUNDS, META_THEME_HIDDEN_BUTTONS, meta_theme_insert_draw_op_list(), meta_theme_insert_layout(), meta_theme_insert_style(), meta_theme_insert_style_set(), meta_theme_load_image(), meta_theme_lookup_draw_op_list(), meta_theme_lookup_layout(), meta_theme_lookup_style(), meta_theme_lookup_style_set(), NULL, ParseInfo::op_list, parse_alpha(), parse_boolean(), parse_double(), parse_positive_integer(), parse_rounding(), parse_title_scale(), peek_state(), push_state(), set_error(), STATE_CONSTANT, STATE_DRAW_OPS, STATE_FALLBACK, STATE_FRAME_GEOMETRY, STATE_FRAME_STYLE, STATE_FRAME_STYLE_SET, STATE_INFO, STATE_MENU_ICON, STATE_THEME, STATE_WINDOW, ParseInfo::style, ParseInfo::style_set, _MetaTheme::style_sets_by_type, ParseInfo::theme, _MetaFrameLayout::title_scale, _MetaFrameLayout::top_left_corner_rounded_radius, _MetaFrameLayout::top_right_corner_rounded_radius, TRUE, _MetaFrameStyle::window_background_alpha, and _MetaFrameStyle::window_background_color.

Referenced by start_element_handler().

static ParseState peek_state ( ParseInfo info  )  [static]

static void pop_state ( ParseInfo info  )  [static]

Definition at line 303 of file theme-parser.c.

References NULL, and ParseInfo::states.

Referenced by end_element_handler().

static void push_state ( ParseInfo info,
ParseState  state 
) [static]

static void set_error ( GError **  err,
GMarkupParseContext *  context,
int  error_domain,
int  error_code,
const char *  format,
  ... 
) [static]

static void start_element_handler ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
gpointer  user_data,
GError **  error 
) [static]

static void text_handler ( GMarkupParseContext *  context,
const gchar *  text,
gsize  text_len,
gpointer  user_data,
GError **  error 
) [static]


Variable Documentation

GMarkupParser metacity_theme_parser [static]

Initial value:

Definition at line 200 of file theme-parser.c.

Referenced by meta_theme_load().


Generated on Sat Aug 23 22:04:23 2008 for metacity by  doxygen 1.5.5