* doc/hildon-docs.sgml * doc/hildon.types * examples/Makefile.am * examples/hildon...
authorAlberto Garcia <agarcia@igalia.com>
Wed, 2 Jul 2008 18:06:06 +0000 (18:06 +0000)
committerAlberto Garcia <agarcia@igalia.com>
Wed, 2 Jul 2008 18:06:06 +0000 (18:06 +0000)
ChangeLog
doc/hildon-docs.sgml
doc/hildon.types
examples/Makefile.am
examples/hildon-button-example.c [new file with mode: 0644]
src/Makefile.am
src/hildon-button.c [new file with mode: 0644]
src/hildon-button.h [new file with mode: 0644]
src/hildon.h

index 9947fba..3c11f03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-07-02  Alberto Garcia  <agarcia@igalia.com>
+
+       * doc/hildon-docs.sgml
+       * doc/hildon.types
+       * examples/Makefile.am
+       * examples/hildon-button-example.c
+       * src/Makefile.am
+       * src/hildon-button.c
+       * src/hildon-button.h
+       * src/hildon.h: Initial version of the new HildonButton widget,
+       with examples.
+
 2008-07-02  Claudio Saavedra  <csaavedra@igalia.com>
 
        * src/hildon-pannable-area.c:
index f413a72..3308467 100644 (file)
@@ -28,6 +28,7 @@
 
   <chapter>
     <title>Selectors</title>
+    <xi:include href="xml/hildon-button.xml"/>
     <xi:include href="xml/hildon-color-button.xml"/>
     <xi:include href="xml/hildon-color-chooser-dialog.xml"/>
     <xi:include href="xml/hildon-color-chooser.xml"/>
index 256058f..96b9923 100644 (file)
@@ -37,6 +37,7 @@
 #include                                        <src/hildon-pannable-area.h>
 #include                                        <src/hildon-stackable-window.h>
 #include                                        <src/hildon-app-menu.h>
+#include                                        <src/hildon-button.h>
 
 hildon_banner_get_type
 hildon_calendar_popup_get_type
@@ -73,3 +74,4 @@ hildon_dialog_get_type
 hildon_pannable_area_get_type
 hildon_stackable_window_get_type
 hildon_app_menu_get_type
+hildon_button_get_type
index 4c850f6..22e1022 100644 (file)
@@ -47,6 +47,7 @@ noinst_PROGRAMS                               = hildon-window-example                         \
                                          hildon-logical-color-example                  \
                                          hildon-app-menu-example                       \
                                          hildon-stackable-window-example               \
+                                         hildon-button-example                         \
                                          hildon-dialog-example
 # Hildon window
 hildon_window_example_LDADD            = $(HILDON_OBJ_LIBS)
@@ -278,6 +279,11 @@ hildon_app_menu_example_LDADD              = $(HILDON_OBJ_LIBS)
 hildon_app_menu_example_CFLAGS         = $(HILDON_OBJ_CFLAGS)
 hildon_app_menu_example_SOURCES                = hildon-app-menu-example.c
 
+# Hildon button
+hildon_button_example_LDADD            = $(HILDON_OBJ_LIBS)
+hildon_button_example_CFLAGS           = $(HILDON_OBJ_CFLAGS)
+hildon_button_example_SOURCES          = hildon-button-example.c
+
 # Hildon dialog
 hildon_dialog_example_LDADD            = $(HILDON_OBJ_LIBS)
 hildon_dialog_example_CFLAGS           = $(HILDON_OBJ_CFLAGS)
diff --git a/examples/hildon-button-example.c b/examples/hildon-button-example.c
new file mode 100644 (file)
index 0000000..04b6d40
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Karl Lattimer <karl.lattimer@nokia.com>
+ *
+ * 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-button.h>
+
+static void
+button_clicked_cb                               (HildonButton *button,
+                                                 gpointer      data)
+{
+    g_debug ("Pressed button: %s", hildon_button_get_title (button));
+}
+
+static void
+vertical_buttons_window                         (void)
+{
+    GtkWidget *win;
+    GtkWidget *button;
+    GtkBox *hbox;
+    GtkBox *vbox1;
+    GtkBox *vbox2;
+    GtkBox *vbox3;
+    int i;
+
+    /* Create window */
+    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    gtk_container_set_border_width (GTK_CONTAINER (win), 20);
+
+    /* Create and pack boxes */
+    hbox = GTK_BOX (gtk_hbox_new (FALSE, 10));
+    vbox1 = GTK_BOX (gtk_vbox_new (FALSE, 10));
+    vbox2 = GTK_BOX (gtk_vbox_new (FALSE, 10));
+    vbox3 = GTK_BOX (gtk_vbox_new (FALSE, 10));
+
+    gtk_box_pack_start (hbox, GTK_WIDGET (vbox1), TRUE, TRUE, 0);
+    gtk_box_pack_start (hbox, GTK_WIDGET (vbox2), TRUE, TRUE, 0);
+    gtk_box_pack_start (hbox, GTK_WIDGET (vbox3), TRUE, TRUE, 0);
+
+    /* Finger buttons */
+    for (i = 0; i < 4; i++) {
+        char *title = g_strdup_printf ("Finger %d", i);
+        button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE |
+                                    HILDON_BUTTON_FINGER_HEIGHT, title, "Some value");
+        g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+        gtk_box_pack_start (vbox1, button, FALSE, FALSE, 0);
+        g_free (title);
+    }
+
+    /* Thumb buttons */
+    for (i = 0; i < 3; i++) {
+        char *title = g_strdup_printf ("Thumb %d", i);
+        button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE |
+                                    HILDON_BUTTON_THUMB_HEIGHT, title, "Some value");
+        g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+        gtk_box_pack_start (vbox2, button, FALSE, FALSE, 0);
+        g_free (title);
+    }
+
+    /* Auto buttons */
+    for (i = 0; i < 4; i++) {
+        char *title = g_strdup_printf ("Auto %d", i);
+        button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE, title, "Some value");
+        g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+        gtk_box_pack_start (vbox3, button, FALSE, FALSE, 0);
+        g_free (title);
+    }
+
+    gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (hbox));
+
+    g_signal_connect (win, "delete_event", G_CALLBACK (gtk_widget_destroy), NULL);
+
+    gtk_widget_show_all (win);
+}
+
+static void
+horizontal_buttons_window                       (void)
+{
+    GtkWidget *win;
+    GtkWidget *button;
+    GtkBox *vbox;
+    GtkBox *hbox1;
+    GtkBox *hbox2;
+    GtkBox *hbox3;
+
+    /* Create window */
+    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    gtk_container_set_border_width (GTK_CONTAINER (win), 20);
+
+    /* Create and pack boxes */
+    vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
+    hbox1 = GTK_BOX (gtk_hbox_new (FALSE, 10));
+    hbox2 = GTK_BOX (gtk_hbox_new (FALSE, 10));
+    hbox3 = GTK_BOX (gtk_hbox_new (FALSE, 10));
+
+    gtk_box_pack_start (vbox, GTK_WIDGET (hbox1), TRUE, TRUE, 0);
+    gtk_box_pack_start (vbox, GTK_WIDGET (hbox2), TRUE, TRUE, 0);
+    gtk_box_pack_start (vbox, GTK_WIDGET (hbox3), TRUE, TRUE, 0);
+
+    /* Full screen width button */
+    button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE |
+                                HILDON_BUTTON_FULLSCREEN_WIDTH, "Full width", "Some value");
+    gtk_box_pack_start (hbox1, button, TRUE, TRUE, 0);
+    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+
+    /* Half screen width buttons */
+    button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE |
+                                HILDON_BUTTON_HALFSCREEN_WIDTH, "Half width 1", "Some value");
+    gtk_box_pack_start (hbox2, button, TRUE, TRUE, 0);
+    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+
+    button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE |
+                                HILDON_BUTTON_HALFSCREEN_WIDTH, "Half width 2 with longer text", "Some value");
+    gtk_box_pack_start (hbox2, button, TRUE, TRUE, 0);
+    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+
+    /* Auto width button */
+    button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE, "Auto 1", "Some value");
+    gtk_box_pack_start (hbox3, button, TRUE, TRUE, 0);
+    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+
+    button = hildon_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE, "Auto 2 with longer text", "Some value");
+    gtk_box_pack_start (hbox3, button, TRUE, TRUE, 0);
+    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+
+    gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox));
+
+    g_signal_connect (win, "delete_event", G_CALLBACK (gtk_widget_destroy), NULL);
+
+    gtk_widget_show_all (win);
+}
+
+int
+main                                            (int    argc,
+                                                 char **argv)
+{
+    GtkWidget *win;
+    GtkWidget *but1;
+    GtkWidget *but2;
+    GtkWidget *label;
+    GtkBox *vbox;
+
+    gtk_init (&argc, &argv);
+
+    vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
+
+    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+    label = gtk_label_new ("HildonButton example");
+    but1 = gtk_button_new_with_label ("Buttons with different heights");
+    but2 = gtk_button_new_with_label ("Buttons with differend widths");
+
+    gtk_box_pack_start (vbox, label, TRUE, TRUE, 0);
+    gtk_box_pack_start (vbox, but1, TRUE, TRUE, 0);
+    gtk_box_pack_start (vbox, but2, TRUE, TRUE, 0);
+
+    gtk_container_set_border_width (GTK_CONTAINER (win), 20);
+    gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox));
+
+    g_signal_connect (but1, "clicked", G_CALLBACK (vertical_buttons_window), NULL);
+    g_signal_connect (but2, "clicked", G_CALLBACK (horizontal_buttons_window), NULL);
+    g_signal_connect (win, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+
+    gtk_widget_show_all (win);
+
+    gtk_main ();
+
+    return 0;
+}
index 73d4e4e..c3f84f4 100644 (file)
@@ -65,6 +65,7 @@ libhildon_@API_VERSION_MAJOR@_la_SOURCES              = hildon-private.c                              \
                                                          hildon-bread-crumb.c                          \
                                                          hildon-bread-crumb-widget.c                   \
                                                          hildon-app-menu.c                             \
+                                                         hildon-button.c                               \
                                                          hildon-dialog.c
 
 libhildon_@API_VERSION_MAJOR@_built_public_headers  = \
@@ -113,6 +114,7 @@ libhildon_@API_VERSION_MAJOR@_public_headers                = hildon-banner.h                               \
                                                          hildon-bread-crumb.h                          \
                                                          hildon-app-menu.h                             \
                                                          hildon-dialog.h                               \
+                                                         hildon-button.h                               \
                                                          hildon-version.h
 
 libhildon_@API_VERSION_MAJOR@_include_HEADERS          = $(libhildon_@API_VERSION_MAJOR@_public_headers)                       \
diff --git a/src/hildon-button.c b/src/hildon-button.c
new file mode 100644 (file)
index 0000000..4807004
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * 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-button
+ * @short_description: Widget representing a button in the Hildon framework.
+ *
+ * The HildonButton is a GTK widget which represent a clickable
+ * button. It is derived from the GtkButton widget and provides
+ * additional commodities specific to the Hildon framework.
+ */
+
+#include                                        "hildon-button.h"
+
+#define FINGER_BUTTON_HEIGHT                    70
+#define THUMB_BUTTON_HEIGHT                     105
+#define HALFSCREEN_BUTTON_WIDTH                 400
+#define FULLSCREEN_BUTTON_WIDTH                 800
+
+G_DEFINE_TYPE                                   (HildonButton, hildon_button, GTK_TYPE_BUTTON);
+
+#define                                         HILDON_BUTTON_GET_PRIVATE(obj) \
+                                                (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+                                                HILDON_TYPE_BUTTON, HildonButtonPrivate));
+
+typedef struct                                  _HildonButtonPrivate HildonButtonPrivate;
+
+struct                                          _HildonButtonPrivate
+{
+    GtkLabel *title;
+    GtkLabel *value;
+};
+
+enum {
+  PROP_TITLE = 1,
+  PROP_VALUE
+};
+
+static void
+hildon_button_set_property                      (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+    HildonButton *button = HILDON_BUTTON (object);
+
+    switch (prop_id)
+    {
+    case PROP_TITLE:
+        hildon_button_set_title (button, g_value_get_string (value));
+        break;
+    case PROP_VALUE:
+        hildon_button_set_value (button, g_value_get_string (value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+hildon_button_get_property                      (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+    HildonButton *button = HILDON_BUTTON (object);
+    HildonButtonPrivate *priv = HILDON_BUTTON_GET_PRIVATE (button);
+
+    switch (prop_id)
+    {
+    case PROP_TITLE:
+        g_value_set_string (value, gtk_label_get_text (priv->title));
+        break;
+    case PROP_VALUE:
+        g_value_set_string (value, gtk_label_get_text (priv->value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+hildon_button_class_init                        (HildonButtonClass *klass)
+{
+    GObjectClass *gobject_class = (GObjectClass *)klass;
+    GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
+
+    gobject_class->set_property = hildon_button_set_property;
+    gobject_class->get_property = hildon_button_get_property;
+
+    g_object_class_install_property (
+        gobject_class,
+        PROP_TITLE,
+        g_param_spec_string (
+            "title",
+            "Title",
+            "Text of the title label inside the button",
+            NULL,
+            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+    g_object_class_install_property (
+        gobject_class,
+        PROP_VALUE,
+        g_param_spec_string (
+            "value",
+            "Value",
+            "Text of the value label inside the button",
+            NULL,
+            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+    gtk_widget_class_install_style_property (
+        widget_class,
+        g_param_spec_uint (
+            "horizontal-spacing",
+            "Horizontal spacing between labels",
+            "Horizontal spacing between the title and value labels, when in horizontal mode",
+            0, G_MAXUINT, 25,
+            G_PARAM_READABLE));
+
+    gtk_widget_class_install_style_property (
+        widget_class,
+        g_param_spec_uint (
+            "vertical-spacing",
+            "Vertical spacing between labels",
+            "Vertical spacing between the title and value labels, when in vertical mode",
+            0, G_MAXUINT, 5,
+            G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (HildonButtonPrivate));
+}
+
+static void
+hildon_button_init                              (HildonButton *self)
+{
+    HildonButtonPrivate *priv = HILDON_BUTTON_GET_PRIVATE (self);
+
+    priv->title = GTK_LABEL (gtk_label_new (NULL));
+    priv->value = GTK_LABEL (gtk_label_new (NULL));
+
+    gtk_widget_set_name (GTK_WIDGET (priv->title), "hildon-button-title");
+    gtk_widget_set_name (GTK_WIDGET (priv->value), "hildon-button-value");
+
+    gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0.5);
+    gtk_misc_set_alignment (GTK_MISC (priv->value), 0, 0.5);
+}
+
+void
+hildon_button_set_size_groups                   (HildonButton *button,
+                                                 GtkSizeGroup *title_size_group,
+                                                 GtkSizeGroup *value_size_group)
+{
+    HildonButtonPrivate *priv;
+
+    g_return_if_fail (HILDON_IS_BUTTON (button));
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+
+    if (title_size_group)
+        gtk_size_group_add_widget (title_size_group, GTK_WIDGET (priv->title));
+
+    if (value_size_group)
+        gtk_size_group_add_widget (value_size_group, GTK_WIDGET (priv->value));
+}
+
+GtkWidget *
+hildon_button_new                               (HildonButtonFlags  flags,
+                                                 const char        *title,
+                                                 const char        *value)
+{
+    return hildon_button_new_full (flags, title, value, NULL, NULL);
+}
+
+GtkWidget *
+hildon_button_new_full                          (HildonButtonFlags  flags,
+                                                 const char        *title,
+                                                 const char        *value,
+                                                 GtkSizeGroup      *title_size_group,
+                                                 GtkSizeGroup      *value_size_group)
+{
+    GtkWidget *button;
+    GtkWidget *box;
+    GtkWidget *alignment;
+    HildonButtonPrivate *priv;
+    guint horizontal_spacing;
+    guint vertical_spacing;
+    gint width = -1;
+    gint height = -1;
+    const char *widget_name = "hildon-button";
+
+    /* Requested height */
+    if (flags & HILDON_BUTTON_FINGER_HEIGHT) {
+        height = FINGER_BUTTON_HEIGHT;
+        widget_name = "hildon-finger-button";
+    } else if (flags & HILDON_BUTTON_THUMB_HEIGHT) {
+        height = THUMB_BUTTON_HEIGHT;
+        widget_name = "hildon-thumb-button";
+    }
+
+    /* Requested width */
+    if (flags & HILDON_BUTTON_HALFSCREEN_WIDTH) {
+        width = HALFSCREEN_BUTTON_WIDTH;
+    } else if (flags & HILDON_BUTTON_FULLSCREEN_WIDTH) {
+        width = FULLSCREEN_BUTTON_WIDTH;
+    }
+
+    /* Create widget */
+    button = g_object_new (HILDON_TYPE_BUTTON,
+                           "title", title,
+                           "value", value,
+                           "width-request", width,
+                           "height-request", height,
+                           "name", widget_name,
+                           NULL);
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+
+    /* Pack everything */
+    gtk_widget_style_get (button,
+                          "horizontal-spacing", &horizontal_spacing,
+                          "vertical-spacing", &vertical_spacing,
+                          NULL);
+
+    if (flags & HILDON_BUTTON_WITH_VERTICAL_VALUE) {
+        box = gtk_vbox_new (FALSE, vertical_spacing);
+    } else {
+        box = gtk_hbox_new (FALSE, horizontal_spacing);
+    }
+
+    alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
+
+    gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (priv->title), TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (priv->value), TRUE, TRUE, 0);
+
+    gtk_container_add (GTK_CONTAINER (alignment), box);
+    gtk_container_add (GTK_CONTAINER (button), alignment);
+
+    /* Set size groups */
+    if (title_size_group || value_size_group)
+        hildon_button_set_size_groups (HILDON_BUTTON (button), title_size_group, value_size_group);
+
+    gtk_widget_show_all (alignment);
+
+    return button;
+}
+
+void
+hildon_button_set_title                         (HildonButton *button,
+                                                 const char   *title)
+{
+    HildonButtonPrivate *priv;
+
+    g_return_if_fail (HILDON_IS_BUTTON (button));
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+    gtk_label_set_text (priv->title, title);
+
+    g_object_notify (G_OBJECT (button), "title");
+}
+
+void
+hildon_button_set_value                         (HildonButton *button,
+                                                 const char   *value)
+{
+    HildonButtonPrivate *priv;
+
+    g_return_if_fail (HILDON_IS_BUTTON (button));
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+    gtk_label_set_text (priv->value, value);
+
+    g_object_notify (G_OBJECT (button), "value");
+}
+
+const char *
+hildon_button_get_title                         (HildonButton *button)
+{
+    HildonButtonPrivate *priv;
+
+    g_return_val_if_fail (HILDON_IS_BUTTON (button), NULL);
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+
+    return gtk_label_get_text (priv->title);
+}
+
+const char *
+hildon_button_get_value                         (HildonButton *button)
+{
+    HildonButtonPrivate *priv;
+
+    g_return_val_if_fail (HILDON_IS_BUTTON (button), NULL);
+
+    priv = HILDON_BUTTON_GET_PRIVATE (button);
+
+    return gtk_label_get_text (priv->value);
+}
+
+void
+hildon_button_set_title_and_value               (HildonButton *button,
+                                                 const char   *title,
+                                                 const char   *value)
+{
+    hildon_button_set_title (button, title);
+    hildon_button_set_value (button, value);
+}
diff --git a/src/hildon-button.h b/src/hildon-button.h
new file mode 100644 (file)
index 0000000..ce3b581
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef                                         __HILDON_BUTTON_H__
+#define                                         __HILDON_BUTTON_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define                                         HILDON_TYPE_BUTTON \
+                                                (hildon_button_get_type())
+
+#define                                         HILDON_BUTTON(obj) \
+                                                (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                HILDON_TYPE_BUTTON, HildonButton))
+
+#define                                         HILDON_BUTTON_CLASS(klass) \
+                                                (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                                HILDON_TYPE_BUTTON, HildonButtonClass))
+
+#define                                         HILDON_IS_BUTTON(obj) \
+                                                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_BUTTON))
+
+#define                                         HILDON_IS_BUTTON_CLASS(klass) \
+                                                (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_BUTTON))
+
+#define                                         HILDON_BUTTON_GET_CLASS(obj) \
+                                                (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                                HILDON_TYPE_BUTTON, HildonButtonClass))
+
+typedef struct                                  _HildonButton HildonButton;
+
+typedef struct                                  _HildonButtonClass HildonButtonClass;
+
+struct                                          _HildonButtonClass
+{
+    GtkButtonClass parent_class;
+};
+
+struct                                          _HildonButton
+{
+    GtkButton parent;
+};
+
+typedef enum {
+   HILDON_BUTTON_WITH_HORIZONTAL_VALUE          = 1,      /* adds second Label horizontally */
+   HILDON_BUTTON_WITH_VERTICAL_VALUE            = 2,      /* adds second Label vertically */
+   HILDON_BUTTON_AUTO_WIDTH                     = 0 << 2, /* leave width unset */
+   HILDON_BUTTON_HALFSCREEN_WIDTH               = 1 << 2, /* set to 50% screen width */
+   HILDON_BUTTON_FULLSCREEN_WIDTH               = 2 << 2, /* set to 100% screen width */
+   HILDON_BUTTON_AUTO_HEIGHT                    = 0 << 4, /* leave height unset */
+   HILDON_BUTTON_FINGER_HEIGHT                  = 1 << 4, /* set to finger height */
+   HILDON_BUTTON_THUMB_HEIGHT                   = 2 << 4, /* set to thumb height */
+}                                               HildonButtonFlags;
+
+GType
+hildon_button_get_type                          (void) G_GNUC_CONST;
+
+GtkWidget *
+hildon_button_new                               (HildonButtonFlags flags,
+                                                 const char        *title,
+                                                 const char        *value);
+
+GtkWidget *
+hildon_button_new_full                          (HildonButtonFlags  flags,
+                                                 const char        *title,
+                                                 const char        *value,
+                                                 GtkSizeGroup      *title_size_group,
+                                                 GtkSizeGroup      *value_size_group);
+
+void
+hildon_button_set_title                         (HildonButton *button,
+                                                 const char *title);
+
+void
+hildon_button_set_value                         (HildonButton *button,
+                                                 const char *value);
+
+const char *
+hildon_button_get_title                         (HildonButton *button);
+
+const char *
+hildon_button_get_value                         (HildonButton *button);
+
+void
+hildon_button_set_title_and_value               (HildonButton *button,
+                                                 const char *title,
+                                                 const char *value);
+
+void
+hildon_button_set_size_groups                   (HildonButton *button,
+                                                 GtkSizeGroup *title_size_group,
+                                                 GtkSizeGroup *value_size_group);
+
+G_END_DECLS
+
+#endif /* __HILDON_BUTTON_H__ */
index cfa8001..73e3487 100644 (file)
@@ -65,6 +65,7 @@
 #include                                        "hildon-bread-crumb-trail.h"
 #include                                        "hildon-pannable-area.h"
 #include                                        "hildon-app-menu.h"
+#include                                        "hildon-button.h"
 #include                                        "hildon-dialog.h"
 
 #endif