X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=hildon%2Fhildon-entry.c;h=07f338b4f488d59883849213572bf70b9cacab24;hb=2b11e29d5aa540c12d67e088687814fbc8149e63;hp=fad23820eba022e5fc24381bd26548ff8af2eb9e;hpb=69a11338fe0cc36a868e5812b590f5437622988a;p=hildon diff --git a/hildon/hildon-entry.c b/hildon/hildon-entry.c index fad2382..07f338b 100644 --- a/hildon/hildon-entry.c +++ b/hildon/hildon-entry.c @@ -16,11 +16,10 @@ /** * SECTION:hildon-entry - * @short_description: Widget representing a text entry in the Hildon framework. + * @short_description: Text entry in the Hildon framework. * - * The #HildonEntry is a GTK widget which represents a text entry. It - * is derived from the #GtkEntry widget and provides additional - * commodities specific to the Hildon framework. + * The #HildonEntry is text entry derived from the #GtkEntry widget providing + * additional commodities specific to the Hildon framework. * * Besides all the features inherited from #GtkEntry, a #HildonEntry * can also have a placeholder text. This text will be shown if the @@ -55,6 +54,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 +69,29 @@ struct _HildonEntryPrivate }; static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + HildonSizeType size; + + switch (prop_id) + { + case PROP_SIZE: + size = g_value_get_flags (value); + /* If this is auto height, default to finger height. */ + if (!(size & (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_THUMB_HEIGHT))) + size |= HILDON_SIZE_FINGER_HEIGHT; + hildon_gtk_widget_set_theme_size (GTK_WIDGET (object), size); + 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 +206,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 +256,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_WIDTH | HILDON_SIZE_FINGER_HEIGHT, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE)); + g_type_class_add_private (klass, sizeof (HildonEntryPrivate)); }