[glade] * gladeui/glade-editor-property.c, gladeui/glade-property-class.c, gladeui/glade-widget-adaptor.c:
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] * gladeui/glade-editor-property.c, gladeui/glade-property-class.c, gladeui/glade-widget-adaptor.c:
- Date: Thu, 3 Feb 2011 14:14:48 +0000 (UTC)
commit 2cacedcccbe65ce3556d603207d984d3d5a5db40
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Feb 3 23:22:51 2011 +0900
* gladeui/glade-editor-property.c, gladeui/glade-property-class.c,
gladeui/glade-widget-adaptor.c: Added support for GdkRGBA properties
* gladeui/glade-property.c: When loading properties, set the enabled flag at load time before
syncing the property instead of after (so that backends can sync the property in the UI).
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Add notion of GdkRGBA properties to
GtkColorButton adaptor (so that the workspace driven dialog can also set rgba properties), and
make rgba properties optional and disabled by default.
ChangeLog | 10 +++++
gladeui/glade-editor-property.c | 71 ++++++++++++++++++++++++++++++---------
gladeui/glade-property-class.c | 15 ++++++++
gladeui/glade-property.c | 10 +++---
gladeui/glade-widget-adaptor.c | 3 +-
plugins/gtk+/glade-gtk.c | 38 +++++++++++++++++---
plugins/gtk+/gtk+.xml.in | 4 ++
7 files changed, 123 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e4b34f3..bbe9360 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,16 @@
has supported this ever since supporting <attributes>, only just adding a GtkFontSelectionDialog
to do this from Glade now.
+ * gladeui/glade-editor-property.c, gladeui/glade-property-class.c,
+ gladeui/glade-widget-adaptor.c: Added support for GdkRGBA properties
+
+ * gladeui/glade-property.c: When loading properties, set the enabled flag at load time before
+ syncing the property instead of after (so that backends can sync the property in the UI).
+
+ * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Add notion of GdkRGBA properties to
+ GtkColorButton adaptor (so that the workspace driven dialog can also set rgba properties), and
+ make rgba properties optional and disabled by default.
+
2011-02-02 Juan Pablo Ugarte <juanpablougarte gmail com>
* gladeui/glade-design-layout.c:
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 6126a01..7402c99 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -1226,7 +1226,7 @@ GLADE_MAKE_EPROP (GladeEPropColor, glade_eprop_color)
#define GLADE_IS_EPROP_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_COLOR))
#define GLADE_IS_EPROP_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_COLOR))
#define GLADE_EPROP_COLOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_COLOR, GladeEPropColorClass))
- static void glade_eprop_color_finalize (GObject * object)
+static void glade_eprop_color_finalize (GObject * object)
{
/* Chain up */
G_OBJECT_CLASS (editor_property_class)->finalize (object);
@@ -1236,12 +1236,16 @@ static void
glade_eprop_color_load (GladeEditorProperty * eprop, GladeProperty * property)
{
GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
+ GParamSpec *pspec;
GdkColor *color;
+ GdkRGBA *rgba;
gchar *text;
/* Chain up first */
editor_property_class->load (eprop, property);
+ pspec = glade_property_class_get_pspec (eprop->priv->klass);
+
if (property)
{
if ((text = glade_property_make_string (property)) != NULL)
@@ -1252,18 +1256,34 @@ glade_eprop_color_load (GladeEditorProperty * eprop, GladeProperty * property)
else
gtk_entry_set_text (GTK_ENTRY (eprop_color->entry), "");
- if ((color = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
- gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton), color);
- else
- {
- GdkColor black = { 0, };
-
- /* Manually fill it with black for an NULL value.
- */
- if (gdk_color_parse ("Black", &black))
- gtk_color_button_set_color
- (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
- }
+ if (pspec->value_type == GDK_TYPE_COLOR)
+ {
+ if ((color = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton), color);
+ else
+ {
+ GdkColor black = { 0, };
+
+ /* Manually fill it with black for an NULL value.
+ */
+ if (gdk_color_parse ("Black", &black))
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
+ }
+ }
+ else if (pspec->value_type == GDK_TYPE_RGBA)
+ {
+ if ((rgba = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (eprop_color->cbutton), rgba);
+ else
+ {
+ GdkRGBA black = { 0, };
+
+ /* Manually fill it with black for an NULL value.
+ */
+ if (gdk_rgba_parse (&black, "Black"))
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
+ }
+ }
}
}
@@ -1271,15 +1291,28 @@ static void
glade_eprop_color_changed (GtkWidget * button, GladeEditorProperty * eprop)
{
GdkColor color = { 0, };
+ GdkRGBA rgba = { 0, };
GValue value = { 0, };
+ GParamSpec *pspec;
if (eprop->priv->loading)
return;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
+ pspec = glade_property_class_get_pspec (eprop->priv->klass);
+ g_value_init (&value, pspec->value_type);
+
+ if (pspec->value_type == GDK_TYPE_COLOR)
+ {
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
- g_value_init (&value, GDK_TYPE_COLOR);
- g_value_set_boxed (&value, &color);
+ g_value_set_boxed (&value, &color);
+ }
+ else if (pspec->value_type == GDK_TYPE_RGBA)
+ {
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (button), &rgba);
+
+ g_value_set_boxed (&value, &rgba);
+ }
glade_editor_property_commit_no_callback (eprop, &value);
g_value_unset (&value);
@@ -1290,6 +1323,9 @@ glade_eprop_color_create_input (GladeEditorProperty * eprop)
{
GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
GtkWidget *hbox;
+ GParamSpec *pspec;
+
+ pspec = glade_property_class_get_pspec (eprop->priv->klass);
hbox = gtk_hbox_new (FALSE, 0);
@@ -1302,6 +1338,9 @@ glade_eprop_color_create_input (GladeEditorProperty * eprop)
gtk_widget_show (eprop_color->cbutton);
gtk_box_pack_start (GTK_BOX (hbox), eprop_color->cbutton, FALSE, FALSE, 0);
+ if (pspec->value_type == GDK_TYPE_RGBA)
+ gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (eprop_color->cbutton), TRUE);
+
g_signal_connect (G_OBJECT (eprop_color->cbutton), "color-set",
G_CALLBACK (glade_eprop_color_changed), eprop);
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index dd37b98..57a8664 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -460,6 +460,7 @@ glade_property_class_make_string_from_gvalue (GladePropertyClass *
gchar *string = NULL, **strv, str[G_ASCII_DTOSTR_BUF_SIZE];
GObject *object;
GdkColor *color;
+ GdkRGBA *rgba;
GList *objects;
if (G_IS_PARAM_SPEC_ENUM (property_class->pspec))
@@ -503,6 +504,12 @@ glade_property_class_make_string_from_gvalue (GladePropertyClass *
string = g_strdup_printf ("#%04x%04x%04x",
color->red, color->green, color->blue);
}
+ else if (property_class->pspec->value_type == GDK_TYPE_RGBA)
+ {
+ rgba = g_value_get_boxed (value);
+ if (rgba)
+ string = gdk_rgba_to_string (rgba);
+ }
else if (property_class->pspec->value_type == G_TYPE_STRV)
{
strv = g_value_get_boxed (value);
@@ -778,6 +785,7 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
GValue *value = g_new0 (GValue, 1);
gchar **strv;
GdkColor color = { 0, };
+ GdkRGBA rgba = { 0, };
g_value_init (value, property_class->pspec->value_type);
@@ -819,6 +827,13 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
else
g_warning ("could not parse colour name `%s'", string);
}
+ else if (property_class->pspec->value_type == GDK_TYPE_RGBA)
+ {
+ if (gdk_rgba_parse (&rgba, string))
+ g_value_set_boxed (value, &rgba);
+ else
+ g_warning ("could not parse rgba colour name `%s'", string);
+ }
else if (property_class->pspec->value_type == G_TYPE_STRV)
{
strv = g_strsplit (string, "\n", 0);
diff --git a/gladeui/glade-property.c b/gladeui/glade-property.c
index b4585ad..672fb0d 100644
--- a/gladeui/glade-property.c
+++ b/gladeui/glade-property.c
@@ -1114,6 +1114,11 @@ glade_property_read (GladeProperty * property,
}
else
{
+ /* If an optional property is specified in the
+ * glade file, its enabled
+ */
+ property->priv->enabled = TRUE;
+
gvalue =
glade_property_class_make_gvalue_from_string (property->priv->klass, value, project);
@@ -1121,11 +1126,6 @@ glade_property_read (GladeProperty * property,
g_value_unset (gvalue);
g_free (gvalue);
-
- /* If an optional property is specified in the
- * glade file, its enabled
- */
- property->priv->enabled = TRUE;
}
translatable =
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 5cdd210..f9a8aee 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1110,7 +1110,8 @@ glade_widget_adaptor_get_eprop_type (GParamSpec * pspec)
}
else if (G_IS_PARAM_SPEC_BOXED (pspec))
{
- if (pspec->value_type == GDK_TYPE_COLOR)
+ if (pspec->value_type == GDK_TYPE_COLOR ||
+ pspec->value_type == GDK_TYPE_RGBA)
type = GLADE_TYPE_EPROP_COLOR;
else if (pspec->value_type == G_TYPE_STRV)
type = GLADE_TYPE_EPROP_TEXT;
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 5fa7ae8..6531d58 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -5581,23 +5581,49 @@ glade_gtk_color_button_refresh_color (GtkColorButton * button,
GladeWidget * gbutton)
{
GladeProperty *property;
- GdkColor color = { 0, };
if ((property = glade_widget_get_property (gbutton, "color")) != NULL)
- glade_command_set_property (property, &color);
-}
+ {
+ if (glade_property_get_enabled (property))
+ {
+ GdkColor color = { 0, };
+ gtk_color_button_get_color (button, &color);
+ glade_command_set_property (property, &color);
+ }
+ }
+ if ((property = glade_widget_get_property (gbutton, "rgba")) != NULL)
+ {
+ if (glade_property_get_enabled (property))
+ {
+ GdkRGBA rgba = { 0, };
+ gtk_color_button_get_rgba (button, &rgba);
+ glade_command_set_property (property, &rgba);
+ }
+ }
+}
void
glade_gtk_color_button_set_property (GladeWidgetAdaptor * adaptor,
GObject * object,
const gchar * id, const GValue * value)
{
+ GladeProperty *property;
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+
if (!strcmp (id, "color"))
{
- if (g_value_get_boxed (value))
- gtk_color_button_set_color (GTK_COLOR_BUTTON (object),
- (GdkColor *) g_value_get_boxed (value));
+ if ((property = glade_widget_get_property (gwidget, "color")) != NULL &&
+ glade_property_get_enabled (property) && g_value_get_boxed (value))
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (object),
+ (GdkColor *) g_value_get_boxed (value));
+ }
+ else if (!strcmp (id, "rgba"))
+ {
+ if ((property = glade_widget_get_property (gwidget, "rgba")) != NULL &&
+ glade_property_get_enabled (property) && g_value_get_boxed (value))
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (object),
+ (GdkRGBA *) g_value_get_boxed (value));
}
else
GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor, object, id, value);
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index fa64e7e..4f8a5fc 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1170,6 +1170,8 @@ embedded in another object</_tooltip>
<properties>
<property id="title" translatable="True"/>
<property id="color" default="Black" optional="True" optional-default="False"/>
+ <property id="alpha" optional="True" optional-default="False"/>
+ <property id="rgba" default="Black" optional="True" optional-default="False" since="3.0"/>
<!-- These props dont apply to color buttons -->
<property id="glade-type" disabled="True"/>
@@ -1798,6 +1800,8 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkColorSelection" generic-name="colorselection" _title="Color Selection">
<properties>
<property id="current-color" default="Black" optional="True" optional-default="False"/>
+ <property id="current-alpha" optional="True" optional-default="False"/>
+ <property id="current-rgba" default="Black" optional="True" optional-default="False" since="3.0"/>
</properties>
</glade-widget-class>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]