[monet] [widget] add parent, style-type, id and style-class properties
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [monet] [widget] add parent, style-type, id and style-class properties
- Date: Thu, 3 Sep 2009 21:49:40 +0000 (UTC)
commit bb28487e78b9bf638e0cb82fb01e88e5b459bf85
Author: Thomas Wood <thos gnome org>
Date: Thu Sep 3 22:49:31 2009 +0100
[widget] add parent, style-type, id and style-class properties
monet/mn-widget.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++
monet/mn-widget.h | 9 +++
2 files changed, 171 insertions(+), 0 deletions(-)
---
diff --git a/monet/mn-widget.c b/monet/mn-widget.c
index 8651972..6e3f25d 100644
--- a/monet/mn-widget.c
+++ b/monet/mn-widget.c
@@ -34,6 +34,11 @@ struct _MnWidgetPrivate
MnColor fg_color;
MnColor border_color;
MnColor highlight_color;
+
+ MnWidget *parent;
+ gchar *type;
+ gchar *id;
+ gchar *class;
};
enum
@@ -75,6 +80,19 @@ mn_widget_get_property (GObject *object,
mn_value_set_color (value, &priv->highlight_color);
break;
+ case PROP_PARENT:
+ g_value_set_object (value, priv->parent);
+ break;
+ case PROP_TYPE:
+ g_value_set_string (value, priv->type);
+ break;
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_CLASS:
+ g_value_set_string (value, priv->class);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -103,6 +121,19 @@ mn_widget_set_property (GObject *object,
mn_widget_set_highlight_color (widget, mn_value_get_color (value));
break;
+ case PROP_PARENT:
+ mn_widget_set_parent (widget, g_value_get_object (value));
+ break;
+ case PROP_TYPE:
+ mn_widget_set_style_type (widget, g_value_get_string (value));
+ break;
+ case PROP_ID:
+ mn_widget_set_id (widget, g_value_get_string (value));
+ break;
+ case PROP_CLASS:
+ mn_widget_set_style_class (widget, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -163,6 +194,33 @@ mn_widget_class_init (MnWidgetClass *klass)
MN_PARAM_READONLY);
g_object_class_install_property (object_class, PROP_HIGHLIGHT_COLOR, pspec);
+ pspec = g_param_spec_object ("parent",
+ "Parent Widget",
+ "Parent widget in the scene graph",
+ MN_TYPE_WIDGET,
+ MN_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_PARENT, pspec);
+
+ pspec = g_param_spec_string ("id",
+ "id",
+ "Unique identifier of the widget",
+ "",
+ MN_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_ID, pspec);
+
+ pspec = g_param_spec_string ("style-class",
+ "Style Class",
+ "Style class name of the widget",
+ "",
+ MN_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_ID, pspec);
+
+ pspec = g_param_spec_string ("style-type",
+ "Style Type",
+ "Type name of the widget",
+ "",
+ MN_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_ID, pspec);
}
static void
@@ -265,3 +323,107 @@ mn_widget_set_highlight_color (MnWidget *widget,
}
}
+MnWidget*
+mn_widget_get_parent (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return widget->priv->parent;
+}
+
+void
+mn_widget_set_parent (MnWidget *widget,
+ MnWidget *parent)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (widget->priv->parent != parent)
+ {
+ g_object_unref (widget->priv->parent);
+ widget->priv->parent = parent;
+
+ g_object_notify (G_OBJECT (widget), "parent");
+ }
+}
+
+gchar*
+mn_widget_get_id (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return widget->priv->id;
+}
+
+void
+mn_widget_set_id (MnWidget *widget,
+ const gchar *id)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (g_strcmp0 (id, widget->priv->id))
+ {
+ g_free (widget->priv->id);
+
+ if (id)
+ widget->priv->id = g_strdup (id);
+ else
+ widget->priv->id = NULL;
+
+ g_object_notify (G_OBJECT (widget), "id");
+ }
+}
+
+gchar*
+mn_widget_get_style_type (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return widget->priv->type;
+}
+
+void
+mn_widget_set_style_type (MnWidget *widget,
+ const gchar *type)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (g_strcmp0 (type, widget->priv->type))
+ {
+ g_free (widget->priv->type);
+
+ if (type)
+ widget->priv->type = g_strdup (type);
+ else
+ widget->priv->type = NULL;
+
+ g_object_notify (G_OBJECT (widget), "type");
+ }
+}
+
+gchar*
+mn_widget_get_style_class (MnWidget *widget)
+{
+ g_return_val_if_fail (MN_IS_WIDGET (widget), NULL);
+
+ return widget->priv->class;
+}
+
+void
+mn_widget_set_style_class (MnWidget *widget,
+ const gchar *class)
+{
+ g_return_if_fail (MN_IS_WIDGET (widget));
+
+ if (g_strcmp0 (class, widget->priv->class))
+ {
+ g_free (widget->priv->class);
+
+ if (class)
+ widget->priv->class = g_strdup (class);
+ else
+ widget->priv->class = NULL;
+
+ g_object_notify (G_OBJECT (widget), "class");
+ }
+}
+
diff --git a/monet/mn-widget.h b/monet/mn-widget.h
index 31206d4..bb3d4f6 100644
--- a/monet/mn-widget.h
+++ b/monet/mn-widget.h
@@ -80,6 +80,15 @@ 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);
+MnWidget* mn_widget_get_parent (MnWidget *widget);
+void mn_widget_set_parent (MnWidget *widget, MnWidget *parent);
+
+gchar* mn_widget_get_id (MnWidget *widget);
+void mn_widget_set_id (MnWidget *widget, const gchar *id);
+gchar* mn_widget_get_style_type (MnWidget *widget);
+void mn_widget_set_style_type (MnWidget *widget, const gchar *type);
+gchar* mn_widget_get_style_class (MnWidget *widget);
+void mn_widget_set_style_class (MnWidget *widget, const gchar *class);
G_END_DECLS
#endif /* _MN_WIDGET_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]