[monet] [widget] add the colour properties
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [monet] [widget] add the colour properties
- Date: Sat, 29 Aug 2009 09:41:39 +0000 (UTC)
commit 2592d6a8f97287cbf0c9d068a53e05ca019eb4fb
Author: Thomas Wood <thos gnome org>
Date: Sat Aug 29 10:41:13 2009 +0100
[widget] add the colour properties
Add background, foreground, border and highlight colour properties to the
MnWidget object.
monet/mn-widget.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++--
monet/mn-widget.h | 10 +++
2 files changed, 189 insertions(+), 5 deletions(-)
---
diff --git a/monet/mn-widget.c b/monet/mn-widget.c
index 1d04d3b..b7e61a6 100644
--- a/monet/mn-widget.c
+++ b/monet/mn-widget.c
@@ -9,26 +9,79 @@ G_DEFINE_TYPE (MnWidget, mn_widget, G_TYPE_OBJECT)
struct _MnWidgetPrivate
{
- gpointer dummy;
+ MnColor bg_color;
+ MnColor fg_color;
+ MnColor border_color;
+ MnColor highlight_color;
+};
+
+enum
+{
+ PROP_0,
+
+ PROP_BG_COLOR,
+ PROP_FG_COLOR,
+ PROP_BORDER_COLOR,
+ PROP_HIGHLIGHT_COLOR,
+ PROP_PADDING,
+
+ PROP_PARENT,
+ PROP_TYPE,
+ PROP_ID,
+ PROP_CLASS
};
static void
-mn_widget_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
+mn_widget_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ MnWidgetPrivate *priv = MN_WIDGET (object)->priv;
+
switch (property_id)
{
+ case PROP_BG_COLOR:
+ mn_value_set_color (value, &priv->bg_color);
+ break;
+ case PROP_FG_COLOR:
+ mn_value_set_color (value, &priv->fg_color);
+ break;
+ case PROP_BORDER_COLOR:
+ mn_value_set_color (value, &priv->border_color);
+ break;
+ case PROP_HIGHLIGHT_COLOR:
+ mn_value_set_color (value, &priv->highlight_color);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
-mn_widget_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
+mn_widget_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
+ MnWidget *widget = MN_WIDGET (object);
+
switch (property_id)
{
+ case PROP_BG_COLOR:
+ mn_widget_set_background_color (widget, mn_value_get_color (value));
+ break;
+ case PROP_FG_COLOR:
+ mn_widget_set_foreground_color (widget, mn_value_get_color (value));
+ break;
+ case PROP_BORDER_COLOR:
+ mn_widget_set_border_color (widget, mn_value_get_color (value));
+ break;
+ case PROP_HIGHLIGHT_COLOR:
+ mn_widget_set_highlight_color (widget, mn_value_get_color (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -46,9 +99,12 @@ mn_widget_finalize (GObject *object)
G_OBJECT_CLASS (mn_widget_parent_class)->finalize (object);
}
+#define MN_PARAM_READONLY G_PARAM_READABLE | G_PARAM_STATIC_STRINGS
+#define MN_PARAM_READWRITE G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
static void
mn_widget_class_init (MnWidgetClass *klass)
{
+ GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (MnWidgetPrivate));
@@ -57,6 +113,35 @@ mn_widget_class_init (MnWidgetClass *klass)
object_class->set_property = mn_widget_set_property;
object_class->dispose = mn_widget_dispose;
object_class->finalize = mn_widget_finalize;
+
+ pspec = g_param_spec_boxed ("background-color",
+ "background colour",
+ "Background colour of the widget",
+ MN_TYPE_COLOR,
+ MN_PARAM_READONLY);
+ g_object_class_install_property (object_class, PROP_BG_COLOR, pspec);
+
+ pspec = g_param_spec_boxed ("foreground-color",
+ "foreground colour",
+ "Foreground colour of the widget",
+ MN_TYPE_COLOR,
+ MN_PARAM_READONLY);
+ g_object_class_install_property (object_class, PROP_FG_COLOR, pspec);
+
+ pspec = g_param_spec_boxed ("border-color",
+ "border colour",
+ "Border colour of the widget",
+ MN_TYPE_COLOR,
+ MN_PARAM_READONLY);
+ g_object_class_install_property (object_class, PROP_BORDER_COLOR, pspec);
+
+ pspec = g_param_spec_boxed ("highlight-color",
+ "highlight colour",
+ "Highlight colour of the widget",
+ MN_TYPE_COLOR,
+ MN_PARAM_READONLY);
+ g_object_class_install_property (object_class, PROP_HIGHLIGHT_COLOR, pspec);
+
}
static void
@@ -70,3 +155,92 @@ mn_widget_new (void)
{
return g_object_new (MN_TYPE_WIDGET, NULL);
}
+
+MnColor *
+mn_widget_get_background_color (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return mn_color_copy (&widget->priv->bg_color);
+}
+
+void
+mn_widget_set_background_color (MnWidget *widget,
+ const MnColor *color)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (!mn_color_equal (&widget->priv->bg_color, color))
+ {
+ widget->priv->bg_color = *color;
+
+ g_object_notify (G_OBJECT (widget), "background-color");
+ }
+}
+
+MnColor *
+mn_widget_get_foreground_color (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return mn_color_copy (&widget->priv->fg_color);
+}
+
+void
+mn_widget_set_foreground_color (MnWidget *widget,
+ const MnColor *color)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (!mn_color_equal (&widget->priv->fg_color, color))
+ {
+ widget->priv->fg_color = *color;
+
+ g_object_notify (G_OBJECT (widget), "foreground-color");
+ }
+}
+
+MnColor *
+mn_widget_get_border_color (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return mn_color_copy (&widget->priv->border_color);
+}
+
+void
+mn_widget_set_border_color (MnWidget *widget,
+ const MnColor *color)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (!mn_color_equal (&widget->priv->border_color, color))
+ {
+ widget->priv->border_color = *color;
+
+ g_object_notify (G_OBJECT (widget), "border-color");
+ }
+}
+
+MnColor *
+mn_widget_get_highlight_color (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return mn_color_copy (&widget->priv->highlight_color);
+}
+
+void
+mn_widget_set_highlight_color (MnWidget *widget,
+ const MnColor *color)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (!mn_color_equal (&widget->priv->highlight_color, color))
+ {
+ widget->priv->highlight_color = *color;
+
+ g_object_notify (G_OBJECT (widget), "highlight-color");
+ }
+}
+
diff --git a/monet/mn-widget.h b/monet/mn-widget.h
index 9c19d25..fb4f40b 100644
--- a/monet/mn-widget.h
+++ b/monet/mn-widget.h
@@ -4,6 +4,7 @@
#define _MN_WIDGET_H
#include <glib-object.h>
+#include "mn-color.h"
G_BEGIN_DECLS
@@ -49,6 +50,15 @@ GType mn_widget_get_type (void);
MnWidget *mn_widget_new (void);
+MnColor * mn_widget_get_background_color (MnWidget *widget);
+void mn_widget_set_background_color (MnWidget *widget, const MnColor *color);
+MnColor * mn_widget_get_foreground_color (MnWidget *widget);
+void mn_widget_set_foreground_color (MnWidget *widget, const MnColor *color);
+MnColor * mn_widget_get_border_color (MnWidget *widget);
+void mn_widget_set_border_color (MnWidget *widget, const MnColor *color);
+MnColor * mn_widget_get_highlight_color (MnWidget *widget);
+void mn_widget_set_highlight_color (MnWidget *widget, const MnColor *color);
+
G_END_DECLS
#endif /* _MN_WIDGET_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]