[monet/monet-xml] Use an array to hold the list of widget drawing ops
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monet/monet-xml] Use an array to hold the list of widget drawing ops
- Date: Sun, 25 Jul 2010 17:22:06 +0000 (UTC)
commit 2ef8466bdf56271577671d5058819bd3014812ee
Author: Thomas Wood <thos gnome org>
Date: Sun Jul 25 16:53:04 2010 +0100
Use an array to hold the list of widget drawing ops
monet/mn-config.c | 41 ++++++++++++++++-------------------------
monet/mn-config.h | 25 +++++++++++++++++--------
monet/mn-style.c | 16 ++++++++--------
3 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/monet/mn-config.c b/monet/mn-config.c
index a5acc7c..c58a174 100644
--- a/monet/mn-config.c
+++ b/monet/mn-config.c
@@ -72,23 +72,12 @@ static void
mn_config_finalize (GObject *object)
{
MnConfig *config = MN_CONFIG (object);
- /* MnConfigPrivate *priv = config->priv; */
-
- mn_config_free_ops (config->button_ops);
-
- mn_config_free_ops (config->entry_ops);
-
- mn_config_free_ops (config->check_ops);
-
- mn_config_free_ops (config->radio_ops);
-
- mn_config_free_ops (config->menu_ops);
-
- mn_config_free_ops (config->menu_item_ops);
-
- mn_config_free_ops (config->menu_bar_ops);
+ gint i;
- mn_config_free_ops (config->tool_bar_ops);
+ for (i = 0; i < MN_WIDGET_LAST;i++)
+ {
+ mn_config_free_ops (config->widget_ops[i]);
+ }
G_OBJECT_CLASS (mn_config_parent_class)->finalize (object);
}
@@ -360,7 +349,7 @@ monet_start_element (GMarkupParseContext *context,
{
GError *err = NULL;
const gchar **attr_n;
- gint i;
+ gint i, widget;
MnConfig *config = (MnConfig *) user_data;
if (!strcmp (element_name, "monet"))
@@ -395,21 +384,23 @@ monet_start_element (GMarkupParseContext *context,
}
if (!strcmp (type, "button"))
- ops = &config->button_ops[wstate];
+ widget = MN_BUTTON;
else if (!strcmp (type, "entry"))
- ops = &config->entry_ops[wstate];
+ widget = MN_ENTRY;
else if (!strcmp (type, "check"))
- ops = &config->check_ops[wstate];
+ widget = MN_CHECK;
else if (!strcmp (type, "radio"))
- ops = &config->radio_ops[wstate];
+ widget = MN_RADIO;
else if (!strcmp (type, "menu"))
- ops = &config->menu_ops[wstate];
+ widget = MN_MENU;
else if (!strcmp (type, "menu-item"))
- ops = &config->menu_item_ops[wstate];
+ widget = MN_MENU_ITEM;
else if (!strcmp (type, "menu-bar"))
- ops = &config->menu_bar_ops[wstate];
+ widget = MN_MENU_BAR;
else if (!strcmp (type, "tool-bar"))
- ops = &config->tool_bar_ops[wstate];
+ widget = MN_TOOL_BAR;
+
+ ops = &config->widget_ops[widget][wstate];
g_markup_parse_context_push (context, &widget_parser, ops);
}
diff --git a/monet/mn-config.h b/monet/mn-config.h
index e6b7147..69f4e8f 100644
--- a/monet/mn-config.h
+++ b/monet/mn-config.h
@@ -51,6 +51,22 @@ typedef struct _MnConfig MnConfig;
typedef struct _MnConfigClass MnConfigClass;
typedef struct _MnConfigPrivate MnConfigPrivate;
+typedef GSList *MnDrawingOps[4];
+
+enum
+{
+ MN_BUTTON,
+ MN_ENTRY,
+ MN_CHECK,
+ MN_RADIO,
+ MN_MENU,
+ MN_MENU_ITEM,
+ MN_MENU_BAR,
+ MN_TOOL_BAR,
+
+ MN_WIDGET_LAST
+};
+
struct _MnConfig
{
GObject parent;
@@ -58,14 +74,7 @@ struct _MnConfig
MnConfigPrivate *priv;
/*< private >*/
- GSList *button_ops[4];
- GSList *entry_ops[4];
- GSList *check_ops[4];
- GSList *radio_ops[4];
- GSList *menu_ops[4];
- GSList *menu_item_ops[4];
- GSList *menu_bar_ops[4];
- GSList *tool_bar_ops[4];
+ MnDrawingOps widget_ops[MN_WIDGET_LAST];
};
struct _MnConfigClass
diff --git a/monet/mn-style.c b/monet/mn-style.c
index 43a69ac..ee4b954 100644
--- a/monet/mn-style.c
+++ b/monet/mn-style.c
@@ -335,7 +335,7 @@ mn_style_paint_entry (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->entry_ops;
+ ops = style->priv->config->widget_ops[MN_ENTRY];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -353,7 +353,7 @@ mn_style_paint_button (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->button_ops;
+ ops = style->priv->config->widget_ops[MN_BUTTON];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -371,7 +371,7 @@ mn_style_paint_check_box (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->check_ops;
+ ops = style->priv->config->widget_ops[MN_CHECK];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -389,7 +389,7 @@ mn_style_paint_radio_button (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->radio_ops;
+ ops = style->priv->config->widget_ops[MN_MENU];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -408,7 +408,7 @@ mn_style_paint_menu (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->menu_ops;
+ ops = style->priv->config->widget_ops[MN_MENU];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -426,7 +426,7 @@ mn_style_paint_menu_item (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->menu_item_ops;
+ ops = style->priv->config->widget_ops[MN_MENU_ITEM];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -444,7 +444,7 @@ mn_style_paint_menu_bar (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->menu_bar_ops;
+ ops = style->priv->config->widget_ops[MN_MENU_BAR];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
@@ -462,7 +462,7 @@ mn_style_paint_tool_bar (MnStyle *style,
{
GSList **ops;
- ops = style->priv->config->tool_bar_ops;
+ ops = style->priv->config->widget_ops[MN_TOOL_BAR];
mn_style_draw_ops (style, ops, cr, x, y, width, height, colors, state, flags);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]