aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Garcia <agarcia@igalia.com>2009-05-20 12:27:46 +0200
committerAlberto Garcia <agarcia@igalia.com>2009-05-20 12:27:46 +0200
commita18fb010205eb0c8bfbcf2ef9f2cf6a9065e47dc (patch)
tree387b435c832628c39ae1f4b90ecfb2e9ef28fc07
parent45e1f8a0e10057e4af56d49c9c6e68b224ee7c23 (diff)
Add a 'size' property to HildonCheckButton and HildonEntry
* hildon/hildon-entry.c (hildon_entry_class_init, +set_property, hildon_entry_new) * hildon/hildon-check-button.c (hildon_check_button_class_init) (+set_property, hildon_check_button_new): Make the theme size a property. Fixes: NB#117928 (Widgets such as Entry and CheckButton (and others) do too much in the _new function)
-rw-r--r--ChangeLog12
-rw-r--r--hildon/hildon-check-button.c37
-rw-r--r--hildon/hildon-entry.c39
3 files changed, 80 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 77a1faf..d8abdd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-05-20 Alberto Garcia <agarcia@igalia.com>
+
+ * hildon/hildon-entry.c
+ (hildon_entry_class_init, +set_property, hildon_entry_new)
+ * hildon/hildon-check-button.c
+ (hildon_check_button_class_init)
+ (+set_property, hildon_check_button_new):
+ Make the theme size a property.
+
+ Fixes: NB#117928 (Widgets such as Entry and CheckButton (and
+ others) do too much in the _new function)
+
2009-05-18 Claudio Saavedra <csaavedra@igalia.com>
* configure.ac: post release version bump
diff --git a/hildon/hildon-check-button.c b/hildon/hildon-check-button.c
index 1bc26ca..7283b89 100644
--- a/hildon/hildon-check-button.c
+++ b/hildon/hildon-check-button.c
@@ -72,6 +72,10 @@ enum {
LAST_SIGNAL
};
+enum {
+ PROP_SIZE = 1
+};
+
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (HildonCheckButton, hildon_check_button, GTK_TYPE_BUTTON);
@@ -160,9 +164,7 @@ hildon_check_button_get_active (HildonCheckButton *button)
GtkWidget *
hildon_check_button_new (HildonSizeType size)
{
- GtkWidget *button = g_object_new (HILDON_TYPE_CHECK_BUTTON, "xalign", 0.0, NULL);
- hildon_gtk_widget_set_theme_size (button, size);
- return button;
+ return g_object_new (HILDON_TYPE_CHECK_BUTTON, "xalign", 0.0, "size", size, NULL);
}
static void
@@ -198,12 +200,30 @@ hildon_check_button_style_set (GtkWidget *widget,
}
static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ case PROP_SIZE:
+ hildon_gtk_widget_set_theme_size (GTK_WIDGET (object), g_value_get_flags (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
hildon_check_button_class_init (HildonCheckButtonClass *klass)
{
GObjectClass *gobject_class = (GObjectClass*) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
GtkButtonClass *button_class = (GtkButtonClass*) klass;
+ gobject_class->set_property = set_property;
widget_class->style_set = hildon_check_button_style_set;
button_class->clicked = hildon_check_button_clicked;
@@ -234,6 +254,17 @@ hildon_check_button_class_init (HildonCheckButtonClass *klass)
0, G_MAXUINT, 26,
G_PARAM_READABLE));
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SIZE,
+ g_param_spec_flags (
+ "size",
+ "Size",
+ "Size request for the button",
+ HILDON_TYPE_SIZE_TYPE,
+ HILDON_SIZE_AUTO,
+ G_PARAM_WRITABLE));
+
g_type_class_add_private (klass, sizeof (HildonCheckButtonPrivate));
}
diff --git a/hildon/hildon-entry.c b/hildon/hildon-entry.c
index fad2382..6e065bc 100644
--- a/hildon/hildon-entry.c
+++ b/hildon/hildon-entry.c
@@ -55,6 +55,10 @@
G_DEFINE_TYPE (HildonEntry, hildon_entry, GTK_TYPE_ENTRY);
+enum {
+ PROP_SIZE = 1
+};
+
#define HILDON_ENTRY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
HILDON_TYPE_ENTRY, HildonEntryPrivate));
@@ -66,6 +70,23 @@ struct _HildonEntryPrivate
};
static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ case PROP_SIZE:
+ hildon_gtk_widget_set_theme_size (GTK_WIDGET (object), g_value_get_flags (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
hildon_entry_show_placeholder (HildonEntry *entry)
{
HildonEntryPrivate *priv = HILDON_ENTRY (entry)->priv;
@@ -180,11 +201,7 @@ hildon_entry_set_placeholder (HildonEntry *entry,
GtkWidget *
hildon_entry_new (HildonSizeType size)
{
- GtkWidget *entry = g_object_new (HILDON_TYPE_ENTRY, NULL);
-
- hildon_gtk_widget_set_theme_size (entry, size);
-
- return entry;
+ return g_object_new (HILDON_TYPE_ENTRY, "size", size, NULL);
}
static gboolean
@@ -234,10 +251,22 @@ hildon_entry_class_init (HildonEntryClass *klass)
GObjectClass *gobject_class = (GObjectClass *)klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
+ gobject_class->set_property = set_property;
gobject_class->finalize = hildon_entry_finalize;
widget_class->focus_in_event = hildon_entry_focus_in_event;
widget_class->focus_out_event = hildon_entry_focus_out_event;
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SIZE,
+ g_param_spec_flags (
+ "size",
+ "Size",
+ "Size request for the entry",
+ HILDON_TYPE_SIZE_TYPE,
+ HILDON_SIZE_AUTO,
+ G_PARAM_WRITABLE));
+
g_type_class_add_private (klass, sizeof (HildonEntryPrivate));
}