2008-09-05 Alberto Garcia <agarcia@igalia.com>
+ * doc/hildon-docs.sgml
+ * doc/hildon.types
+ * examples/Makefile.am
+ * examples/hildon-entry-example.c
+ * src/Makefile.am
+ * src/hildon-entry.c
+ * src/hildon-entry.h
+ * src/hildon.h:
+ New HildonEntry widget, with example.
+
+2008-09-05 Alberto Garcia <agarcia@igalia.com>
+
* src/hildon-button.c (hildon_button_construct_child): Pack the
image with expand == fill == FALSE. This is a workaround for a bug
in GtkBox.
<xi:include href="xml/hildon-range-editor.xml"/>
<xi:include href="xml/hildon-time-editor.xml"/>
<xi:include href="xml/hildon-date-editor.xml"/>
+ <xi:include href="xml/hildon-entry.xml"/>
</chapter>
<chapter>
#include <src/hildon-pannable-area.h>
#include <src/hildon-stackable-window.h>
#include <src/hildon-app-menu.h>
+#include <src/hildon-entry.h>
#include <src/hildon-button.h>
#include <src/hildon-touch-selector.h>
#include <src/hildon-touch-selector-entry.h>
hildon_pannable_area_get_type
hildon_stackable_window_get_type
hildon_app_menu_get_type
+hildon_entry_get_type
hildon_button_get_type
hildon_touch_selector_get_type
hildon_touch_selector_entry_get_type
hildon-logical-color-example \
hildon-app-menu-example \
hildon-stackable-window-example \
+ hildon-entry-example \
hildon-button-example \
hildon-dialog-example \
hildon-date-button-example \
hildon_app_menu_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
hildon_app_menu_example_SOURCES = hildon-app-menu-example.c
+# Hildon entry
+hildon_entry_example_LDADD = $(HILDON_OBJ_LIBS)
+hildon_entry_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
+hildon_entry_example_SOURCES = hildon-entry-example.c
+
# Hildon button
hildon_button_example_LDADD = $(HILDON_OBJ_LIBS)
hildon_button_example_CFLAGS = $(HILDON_OBJ_CFLAGS)
--- /dev/null
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <gtk/gtk.h>
+#include <hildon.h>
+
+static void
+reset_entry (HildonEntry *entry)
+{
+ hildon_entry_set_placeholder (entry, "Placeholder text");
+}
+
+static void
+text_changed (HildonEntry *entry,
+ GParamSpec *arg1,
+ GtkLabel *label)
+{
+ /* Do *NOT* use gtk_entry_get_text () */
+ const gchar *text = hildon_entry_get_text (entry);
+
+ if (text != NULL && *text != '\0') {
+ gtk_label_set_text (label, text);
+ } else {
+ gtk_label_set_text (label, "(empty)");
+ }
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ GtkWidget *win;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *button;
+ GtkWidget *label3;
+ GtkWidget *label2;
+ GtkBox *vbox;
+
+ gtk_init (&argc, &argv);
+
+ gtk_rc_parse_string ("style \"placeholder\" {\n"
+ "text[NORMAL] = \"#C03030\""
+ "}\n"
+ "widget \"*.hildon-entry-placeholder\" style \"placeholder\"\n");
+
+ win = hildon_stackable_window_new ();
+ vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
+
+ label = gtk_label_new ("HildonEntry example");
+ entry = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
+ button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
+ label2 = gtk_label_new ("Contents of the entry:");
+ label3 = gtk_label_new (NULL);
+
+ gtk_button_set_label (GTK_BUTTON (button), "Reset entry");
+ reset_entry (HILDON_ENTRY (entry));
+ text_changed (HILDON_ENTRY (entry), NULL, GTK_LABEL (label3));
+
+ gtk_box_pack_start (vbox, label, TRUE, TRUE, 0);
+ gtk_box_pack_start (vbox, button, FALSE, FALSE, 0);
+ gtk_box_pack_start (vbox, entry, FALSE, FALSE, 0);
+ gtk_box_pack_start (vbox, label2, TRUE, TRUE, 0);
+ gtk_box_pack_start (vbox, label3, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (win), 20);
+ gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox));
+
+ g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (entry, "notify::text", G_CALLBACK (text_changed), label3);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (reset_entry), entry);
+
+ gtk_widget_show_all (win);
+
+ gtk_main ();
+
+ return 0;
+}
hildon-marshalers.c \
hildon-calendar.c \
hildon-pannable-area.c \
+ hildon-entry.c \
hildon-bread-crumb-trail.c \
hildon-bread-crumb.c \
hildon-bread-crumb-widget.c \
hildon-wizard-dialog.h \
hildon-calendar.h \
hildon-pannable-area.h \
+ hildon-entry.h \
hildon-bread-crumb-trail.h \
hildon-bread-crumb.h \
hildon-app-menu.h \
--- /dev/null
+/*
+ * This file is a part of hildon
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Karl Lattimer <karl.lattimer@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ *
+ */
+
+/**
+ * SECTION:hildon-entry
+ * @short_description: Widget representing a 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.
+ */
+
+#include "hildon-entry.h"
+
+G_DEFINE_TYPE (HildonEntry, hildon_entry, GTK_TYPE_ENTRY);
+
+static const gchar *placeholder_widget_name = "hildon-entry-placeholder";
+
+void
+hildon_entry_set_text (HildonEntry *entry,
+ const gchar *text)
+{
+ g_return_if_fail (HILDON_IS_ENTRY (entry));
+
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
+
+ gtk_widget_set_name (GTK_WIDGET (entry), NULL);
+}
+
+const gchar *
+hildon_entry_get_text (HildonEntry *entry)
+{
+ g_return_val_if_fail (HILDON_IS_ENTRY (entry), NULL);
+
+ if (g_str_equal (gtk_widget_get_name (GTK_WIDGET (entry)), placeholder_widget_name)) {
+ return "";
+ }
+
+ return gtk_entry_get_text (GTK_ENTRY (entry));
+}
+
+void
+hildon_entry_set_placeholder (HildonEntry *entry,
+ const gchar *text)
+{
+ g_return_if_fail (HILDON_IS_ENTRY (entry));
+
+ gtk_widget_set_name (GTK_WIDGET (entry), placeholder_widget_name);
+
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
+}
+
+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;
+}
+
+static gboolean
+hildon_entry_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ if (g_str_equal (gtk_widget_get_name (widget), placeholder_widget_name)) {
+ hildon_entry_set_text (HILDON_ENTRY (widget), "");
+ }
+ if (GTK_WIDGET_CLASS (hildon_entry_parent_class)->focus_in_event) {
+ return GTK_WIDGET_CLASS (hildon_entry_parent_class)->focus_in_event (widget, event);
+ } else {
+ return FALSE;
+ }
+}
+
+static void
+hildon_entry_class_init (HildonEntryClass *klass)
+{
+ GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
+
+ widget_class->focus_in_event = hildon_entry_focus_in_event;
+}
+
+static void
+hildon_entry_init (HildonEntry *self)
+{
+}
--- /dev/null
+/*
+ * This file is a part of hildon
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ *
+ */
+
+#ifndef __HILDON_ENTRY_H__
+#define __HILDON_ENTRY_H__
+
+#include "hildon-gtk.h"
+
+G_BEGIN_DECLS
+
+#define HILDON_TYPE_ENTRY \
+ (hildon_entry_get_type())
+
+#define HILDON_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ HILDON_TYPE_ENTRY, HildonEntry))
+
+#define HILDON_ENTRY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ HILDON_TYPE_ENTRY, HildonEntryClass))
+
+#define HILDON_IS_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_ENTRY))
+
+#define HILDON_IS_ENTRY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_ENTRY))
+
+#define HILDON_ENTRY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ HILDON_TYPE_ENTRY, HildonEntryClass))
+
+typedef struct _HildonEntry HildonEntry;
+
+typedef struct _HildonEntryClass HildonEntryClass;
+
+struct _HildonEntryClass
+{
+ GtkEntryClass parent_class;
+};
+
+struct _HildonEntry
+{
+ GtkEntry parent;
+};
+
+
+GType
+hildon_entry_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+hildon_entry_new (HildonSizeType size);
+
+void
+hildon_entry_set_text (HildonEntry *entry,
+ const gchar *text);
+
+void
+hildon_entry_set_placeholder (HildonEntry *entry,
+ const gchar *text);
+
+const gchar *
+hildon_entry_get_text (HildonEntry *entry);
+
+G_END_DECLS
+
+#endif /* __HILDON_ENTRY_H__ */
#include "hildon-calendar.h"
#include "hildon-bread-crumb-trail.h"
#include "hildon-pannable-area.h"
+#include "hildon-entry.h"
#include "hildon-app-menu.h"
#include "hildon-button.h"
#include "hildon-check-button.h"