2 * This file is a part of hildon
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * Contact: Karl Lattimer <karl.lattimer@nokia.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser Public License as published by
10 * the Free Software Foundation; version 2 of the license.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser Public License for more details.
20 * SECTION:hildon-entry
21 * @short_description: Widget representing a text entry in the Hildon framework.
23 * The #HildonEntry is a GTK widget which represents a text entry. It
24 * is derived from the GtkEntry widget and provides additional
25 * commodities specific to the Hildon framework.
28 #include "hildon-entry.h"
30 G_DEFINE_TYPE (HildonEntry, hildon_entry, GTK_TYPE_ENTRY);
32 static const gchar *placeholder_widget_name = "hildon-entry-placeholder";
35 hildon_entry_set_text (HildonEntry *entry,
38 g_return_if_fail (HILDON_IS_ENTRY (entry));
40 gtk_entry_set_text (GTK_ENTRY (entry), text);
42 gtk_widget_set_name (GTK_WIDGET (entry), NULL);
46 hildon_entry_get_text (HildonEntry *entry)
48 g_return_val_if_fail (HILDON_IS_ENTRY (entry), NULL);
50 if (g_str_equal (gtk_widget_get_name (GTK_WIDGET (entry)), placeholder_widget_name)) {
54 return gtk_entry_get_text (GTK_ENTRY (entry));
58 hildon_entry_set_placeholder (HildonEntry *entry,
61 g_return_if_fail (HILDON_IS_ENTRY (entry));
63 gtk_widget_set_name (GTK_WIDGET (entry), placeholder_widget_name);
65 gtk_entry_set_text (GTK_ENTRY (entry), text);
69 hildon_entry_new (HildonSizeType size)
71 GtkWidget *entry = g_object_new (HILDON_TYPE_ENTRY, NULL);
73 hildon_gtk_widget_set_theme_size (entry, size);
79 hildon_entry_focus_in_event (GtkWidget *widget,
82 if (g_str_equal (gtk_widget_get_name (widget), placeholder_widget_name)) {
83 hildon_entry_set_text (HILDON_ENTRY (widget), "");
85 if (GTK_WIDGET_CLASS (hildon_entry_parent_class)->focus_in_event) {
86 return GTK_WIDGET_CLASS (hildon_entry_parent_class)->focus_in_event (widget, event);
93 hildon_entry_class_init (HildonEntryClass *klass)
95 GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
97 widget_class->focus_in_event = hildon_entry_focus_in_event;
101 hildon_entry_init (HildonEntry *self)