2008-08-07 Alberto Garcia <agarcia@igalia.com>
authorAlberto Garcia <agarcia@igalia.com>
Thu, 7 Aug 2008 13:57:18 +0000 (13:57 +0000)
committerAlberto Garcia <agarcia@igalia.com>
Thu, 7 Aug 2008 13:57:18 +0000 (13:57 +0000)
HildonButtonFlags split into HildonButtonArrangement (to set the
button layout) and HildonSizeType (which can be used for any
widget).

* src/hildon-button.h
* src/hildon-button.c
(hildon_button_class_init)
(hildon_button_set_arrangement)
(hildon_button_set_property): New "size-flags"
property. "arrangement-flags" renamed to "arrangement".
(hildon_button_new, hildon_button_new_with_text)
(hildon_button_new_full): Constructors updated to reflect type changes.

* src/hildon-helper.h
* src/hildon-helper.c (hildon_helper_set_theme_size): New function
to set the size of a widget.

* src/Makefile.am
* src/hildon.h
* src/hildon-button-helpers.c
* src/hildon-button-helpers.h: New hildon-button-helpers module.

* src/hildon-date-button.c
* src/hildon-date-button.h
* src/hildon-picker-button.c
* src/hildon-picker-button.h
* src/hildon-time-button.c
* src/hildon-time-button.h: Updated widgets to reflect
HildonButton API changes.

* examples/hildon-button-example.c
* examples/hildon-date-button-example.c
* examples/hildon-picker-button-example.c
* examples/hildon-picker-button-multicolumn-example.c
* examples/hildon-time-button-example.c
* examples/hildon-touch-selector-entry-example.c
* examples/hildon-touch-selector-example.c: Updated examples to
reflect HildonButton API changes.

22 files changed:
ChangeLog
examples/hildon-button-example.c
examples/hildon-date-button-example.c
examples/hildon-picker-button-example.c
examples/hildon-picker-button-multicolumn-example.c
examples/hildon-time-button-example.c
examples/hildon-touch-selector-entry-example.c
examples/hildon-touch-selector-example.c
src/Makefile.am
src/hildon-button-helpers.c [new file with mode: 0644]
src/hildon-button-helpers.h [new file with mode: 0644]
src/hildon-button.c
src/hildon-button.h
src/hildon-date-button.c
src/hildon-date-button.h
src/hildon-helper.c
src/hildon-helper.h
src/hildon-picker-button.c
src/hildon-picker-button.h
src/hildon-time-button.c
src/hildon-time-button.h
src/hildon.h

index 7fa0e2e..9ccdb6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+2008-08-07  Alberto Garcia  <agarcia@igalia.com>
+
+       HildonButtonFlags split into HildonButtonArrangement (to set the
+       button layout) and HildonSizeType (which can be used for any
+       widget).
+
+       * src/hildon-button.h
+       * src/hildon-button.c
+       (hildon_button_class_init)
+       (hildon_button_set_arrangement)
+       (hildon_button_set_property): New "size-flags"
+       property. "arrangement-flags" renamed to "arrangement".
+       (hildon_button_new, hildon_button_new_with_text)
+       (hildon_button_new_full): Constructors updated to reflect type changes.
+
+       * src/hildon-helper.h
+       * src/hildon-helper.c (hildon_helper_set_theme_size): New function
+       to set the size of a widget.
+
+       * src/Makefile.am
+       * src/hildon.h
+       * src/hildon-button-helpers.c
+       * src/hildon-button-helpers.h: New hildon-button-helpers module.
+
+       * src/hildon-date-button.c
+       * src/hildon-date-button.h
+       * src/hildon-picker-button.c
+       * src/hildon-picker-button.h
+       * src/hildon-time-button.c
+       * src/hildon-time-button.h: Updated widgets to reflect
+       HildonButton API changes.
+
+       * examples/hildon-button-example.c
+       * examples/hildon-date-button-example.c
+       * examples/hildon-picker-button-example.c
+       * examples/hildon-picker-button-multicolumn-example.c
+       * examples/hildon-time-button-example.c
+       * examples/hildon-touch-selector-entry-example.c
+       * examples/hildon-touch-selector-example.c: Updated examples to
+       reflect HildonButton API changes.
+
 2008-08-06  Claudio Saavedra  <csaavedra@igalia.com>
 
        * doc/hildon-docs.sgml:
index 58871b4..46d25bb 100644 (file)
@@ -43,15 +43,15 @@ vertical_buttons_window                         (GtkButton *b,
     GtkBox *vbox2;
     GtkBox *vbox3;
     int i;
-    HildonButtonFlags layout;
+    HildonButtonArrangement arrangement;
 
     /* Create window */
     win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
     gtk_container_set_border_width (GTK_CONTAINER (win), 20);
 
-    layout = gtk_toggle_button_get_active (horizontal) ?
-            HILDON_BUTTON_WITH_HORIZONTAL_VALUE :
-            HILDON_BUTTON_WITH_VERTICAL_VALUE;
+    arrangement = gtk_toggle_button_get_active (horizontal) ?
+            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL :
+            HILDON_BUTTON_ARRANGEMENT_VERTICAL;
 
     /* Create and pack boxes */
     hbox = GTK_BOX (gtk_hbox_new (FALSE, 10));
@@ -66,9 +66,9 @@ vertical_buttons_window                         (GtkButton *b,
     /* Finger buttons */
     gtk_box_pack_start (vbox1, gtk_label_new ("Finger height"), FALSE, FALSE, 0);
     for (i = 0; i < 4; i++) {
-        char *title = g_strdup_printf ("Title %d", i);
-        button = hildon_button_new_with_text (layout |
-                                              HILDON_BUTTON_FINGER_HEIGHT, title,
+        gchar *title = g_strdup_printf ("Title %d", i);
+        button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT |
+                                              HILDON_SIZE_AUTO_WIDTH, arrangement, title,
                                               i % 2 ? "Value" : NULL);
         g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
         gtk_box_pack_start (vbox1, button, FALSE, FALSE, 0);
@@ -78,9 +78,9 @@ vertical_buttons_window                         (GtkButton *b,
     /* Thumb buttons */
     gtk_box_pack_start (vbox2, gtk_label_new ("Thumb height"), FALSE, FALSE, 0);
     for (i = 0; i < 3; i++) {
-        char *title = g_strdup_printf ("Title %d", i);
-        button = hildon_button_new_with_text (layout |
-                                              HILDON_BUTTON_THUMB_HEIGHT, title,
+        gchar *title = g_strdup_printf ("Title %d", i);
+        button = hildon_button_new_with_text (HILDON_SIZE_THUMB_HEIGHT |
+                                              HILDON_SIZE_AUTO_WIDTH, arrangement, title,
                                               i % 2 ? "Value" : NULL);
         g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
         gtk_box_pack_start (vbox2, button, FALSE, FALSE, 0);
@@ -90,8 +90,8 @@ vertical_buttons_window                         (GtkButton *b,
     /* Auto buttons */
     gtk_box_pack_start (vbox3, gtk_label_new ("Auto height"), FALSE, FALSE, 0);
     for (i = 0; i < 6; i++) {
-        char *title = g_strdup_printf ("Title %d", i);
-        button = hildon_button_new_with_text (layout, title,
+        gchar *title = g_strdup_printf ("Title %d", i);
+        button = hildon_button_new_with_text (HILDON_SIZE_AUTO, arrangement, title,
                                               i % 2 ? "Value" : NULL);
         g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
         gtk_box_pack_start (vbox3, button, FALSE, FALSE, 0);
@@ -116,15 +116,15 @@ horizontal_buttons_window                       (GtkButton *b,
     GtkBox *hbox2;
     GtkBox *hbox3;
     GtkBox *hbox4;
-    HildonButtonFlags layout;
+    HildonButtonArrangement arrangement;
 
     /* Create window */
     win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
     gtk_container_set_border_width (GTK_CONTAINER (win), 20);
 
-    layout = gtk_toggle_button_get_active (horizontal) ?
-            HILDON_BUTTON_WITH_HORIZONTAL_VALUE :
-            HILDON_BUTTON_WITH_VERTICAL_VALUE;
+    arrangement = gtk_toggle_button_get_active (horizontal) ?
+            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL :
+            HILDON_BUTTON_ARRANGEMENT_VERTICAL;
 
     /* Create and pack boxes */
     vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
@@ -140,53 +140,46 @@ horizontal_buttons_window                       (GtkButton *b,
     gtk_box_pack_start (vbox, GTK_WIDGET (hbox4), FALSE, FALSE, 0);
 
     /* Full screen width button */
-    button = hildon_button_new_with_text (layout |
-                                          HILDON_BUTTON_FULLSCREEN_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT, "Full width", "Value");
+    button = hildon_button_new_with_text (HILDON_SIZE_FULLSCREEN_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement, "Full width", "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_with_text (layout |
-                                          HILDON_BUTTON_HALFSCREEN_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT, "Half width 1", "Value");
+    button = hildon_button_new_with_text (HILDON_SIZE_HALFSCREEN_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement, "Half width 1", "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_with_text (layout |
-                                          HILDON_BUTTON_HALFSCREEN_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT,
+    button = hildon_button_new_with_text (HILDON_SIZE_HALFSCREEN_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement,
                                           "Half width 2 with long title",
                                           "Value");
     gtk_box_pack_start (hbox2, button, TRUE, TRUE, 0);
     g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
 
     /* Half screen width buttons */
-    button = hildon_button_new_with_text (layout |
-                                          HILDON_BUTTON_HALFSCREEN_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT, "Half width 3", NULL);
+    button = hildon_button_new_with_text (HILDON_SIZE_HALFSCREEN_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement, "Half width 3", NULL);
     gtk_box_pack_start (hbox3, button, TRUE, TRUE, 0);
     g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
 
-    button = hildon_button_new_with_text (layout |
-                                          HILDON_BUTTON_HALFSCREEN_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT,
+    button = hildon_button_new_with_text (HILDON_SIZE_HALFSCREEN_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement,
                                           "Half width 4 with very long title (REALLY long)",
                                           "Value (title is truncated)");
     gtk_box_pack_start (hbox3, button, TRUE, TRUE, 0);
     g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
 
     /* Auto width button */
-    button = hildon_button_new_with_text (layout |
-                                          HILDON_BUTTON_AUTO_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT,
+    button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement,
                                           "Auto width 1", "Value");
     gtk_box_pack_start (hbox4, button, TRUE, TRUE, 0);
     g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
 
-    button = hildon_button_new_with_text (layout |
-                                          HILDON_BUTTON_AUTO_WIDTH |
-                                          HILDON_BUTTON_FINGER_HEIGHT,
+    button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH |
+                                          HILDON_SIZE_FINGER_HEIGHT, arrangement,
                                           "Auto width 2 with longer text", NULL);
     gtk_box_pack_start (hbox4, button, TRUE, TRUE, 0);
     g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL);
index 3b69c94..32815ed 100644 (file)
@@ -30,7 +30,7 @@ main (int argc, char **args)
   gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
   hildon_program_add_window (program, HILDON_WINDOW (window));
 
-  button = hildon_date_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_date_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   g_signal_connect (G_OBJECT (button), "value-changed",
                     G_CALLBACK (on_picker_value_changed), NULL);
 
index 6b6c92f..bec2ea2 100644 (file)
@@ -47,7 +47,7 @@ main (int argc, char **args)
   gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
   hildon_program_add_window (program, HILDON_WINDOW (window));
 
-  button = hildon_picker_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   selector = hildon_touch_selector_new_text ();
   hildon_button_set_title (HILDON_BUTTON (button), "Continent");
 
index 1d8c752..a8fe959 100644 (file)
@@ -89,7 +89,7 @@ main (int argc, char **args)
   hildon_program_add_window (program, HILDON_WINDOW (window));
   selector = create_touch_selector ();
 
-  button = hildon_picker_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   hildon_button_set_title (HILDON_BUTTON (button), "Protocol");
   hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                      HILDON_TOUCH_SELECTOR (selector));
index ce73f7a..d5a4cb7 100644 (file)
@@ -30,7 +30,7 @@ main (int argc, char **args)
   gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
   hildon_program_add_window (program, HILDON_WINDOW (window));
 
-  button = hildon_time_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_time_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   g_signal_connect (G_OBJECT (button), "value-changed",
                     G_CALLBACK (on_picker_value_changed), NULL);
 
index 71d6f3d..22c2535 100644 (file)
@@ -89,7 +89,7 @@ main (int argc, char **args)
                        "class \"HildonTouchSelector\" style \"default\"\n");
 
 
-  button = hildon_picker_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   hildon_button_set_title (HILDON_BUTTON (button), "Pick a band!");
   selector = hildon_touch_selector_entry_new_text ();
   for (i = 0; artists [i] != NULL; i++) {
index 29e558a..3094e91 100644 (file)
@@ -104,7 +104,7 @@ get_visible_content (GtkWidget * window)
 
   label = gtk_label_new ("Here we are going to put the selection");
 
-  button = hildon_picker_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
   hildon_button_set_title (HILDON_BUTTON (button), "Click me..");
   selector = create_selector ();
   hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
index 88d2b39..8b0f779 100644 (file)
@@ -77,6 +77,7 @@ libhildon_@API_VERSION_MAJOR@_la_SOURCES = \
                hildon-bread-crumb-widget.c             \
                hildon-app-menu.c                       \
                hildon-button.c                         \
+               hildon-button-helpers.c                 \
                hildon-dialog.c
 
 libhildon_@API_VERSION_MAJOR@_built_public_headers  = \
@@ -136,6 +137,7 @@ libhildon_@API_VERSION_MAJOR@_public_headers = \
                hildon-app-menu.h                       \
                hildon-dialog.h                         \
                hildon-button.h                         \
+               hildon-button-helpers.h                 \
                hildon-version.h
 
 libhildon_@API_VERSION_MAJOR@_include_HEADERS = \
diff --git a/src/hildon-button-helpers.c b/src/hildon-button-helpers.c
new file mode 100644 (file)
index 0000000..4bac7b4
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ *
+ */
+
+#include "hildon-button-helpers.h"
+
+GtkWidget *
+hildon_gtk_button_new                           (HildonSizeType size)
+{
+    GtkWidget *button = gtk_button_new ();
+    hildon_helper_set_theme_size (button, size);
+    return button;
+}
diff --git a/src/hildon-button-helpers.h b/src/hildon-button-helpers.h
new file mode 100644 (file)
index 0000000..e9344bf
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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_BUTTON_HELPERS_H__
+#define                                         __HILDON_BUTTON_HELPERS_H__
+
+#include                                        <gtk/gtk.h>
+#include                                        "hildon-helper.h"
+
+G_BEGIN_DECLS
+
+GtkWidget *
+hildon_gtk_button_new                           (HildonSizeType size);
+
+G_END_DECLS
+
+#endif /* __HILDON_BUTTON_HELPERS_H__ */
index 0135ccf..e9e2bfa 100644 (file)
@@ -61,12 +61,13 @@ struct                                          _HildonButtonPrivate
 enum {
   PROP_TITLE = 1,
   PROP_VALUE,
-  PROP_ARRANGEMENT_FLAGS
+  PROP_SIZE_FLAGS,
+  PROP_ARRANGEMENT
 };
 
 static void
-hildon_button_set_arrangement                   (HildonButton      *button,
-                                                 HildonButtonFlags  flags);
+hildon_button_set_arrangement                   (HildonButton            *button,
+                                                 HildonButtonArrangement  arrangement);
 
 static void
 hildon_button_construct_child                   (HildonButton *button);
@@ -87,8 +88,11 @@ hildon_button_set_property                      (GObject      *object,
     case PROP_VALUE:
         hildon_button_set_value (button, g_value_get_string (value));
         break;
-    case PROP_ARRANGEMENT_FLAGS:
-        hildon_button_set_arrangement (button, g_value_get_flags (value));
+    case PROP_SIZE_FLAGS:
+        hildon_helper_set_theme_size (GTK_WIDGET (button), g_value_get_flags (value));
+        break;
+    case PROP_ARRANGEMENT:
+        hildon_button_set_arrangement (button, g_value_get_enum (value));
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -150,13 +154,24 @@ hildon_button_class_init                        (HildonButtonClass *klass)
 
     g_object_class_install_property (
         gobject_class,
-        PROP_ARRANGEMENT_FLAGS,
+        PROP_SIZE_FLAGS,
         g_param_spec_flags (
-            "arrangement-flags",
-            "Arrangement flags",
+            "size-flags",
+            "Size flags",
+            "Size request for the button",
+            HILDON_TYPE_SIZE_TYPE,
+            HILDON_SIZE_AUTO,
+            G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+    g_object_class_install_property (
+        gobject_class,
+        PROP_ARRANGEMENT,
+        g_param_spec_enum (
+            "arrangement",
+            "Arrangement",
             "How the button contents must be arranged",
-            HILDON_TYPE_BUTTON_FLAGS,
-            HILDON_BUTTON_WITH_HORIZONTAL_VALUE,
+            HILDON_TYPE_BUTTON_ARRANGEMENT,
+            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
             G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
     gtk_widget_class_install_style_property (
@@ -230,42 +245,47 @@ hildon_button_set_size_groups                   (HildonButton *button,
 
 /**
  * hildon_button_new:
- * @flags: flags to set the size and layout of the button
+ * @size: Flags to set the size of the button.
+ * @arrangement: How the labels must be arranged.
  *
  * Creates a new #HildonButton. To add a child widget use gtk_container_add().
  *
  * Returns: a new #HildonButton
  **/
 GtkWidget *
-hildon_button_new                               (HildonButtonFlags  flags)
+hildon_button_new                               (HildonSizeType          size,
+                                                 HildonButtonArrangement arrangement)
 {
-    return hildon_button_new_full (flags, NULL, NULL, NULL, NULL);
+    return hildon_button_new_full (size, arrangement, NULL, NULL, NULL, NULL);
 }
 
 /**
  * hildon_button_new_with_text:
- * @flags: flags to set the size and layout of the button
- * @title: Title of the button (main label)
+ * @size: Flags to set the size of the button.
+ * @arrangement: How the labels must be arranged.
+ * @title: Title of the button (main label), or %NULL
  * @value: Value of the button (secondary label), or %NULL
  *
  * Creates a new #HildonButton with two labels, @title and @value.
  *
- * If you just want to use the main label, set @value to %NULL. You
- * can set it to a non-%NULL value at any time later.
+ * If you just don't want to use one of the labels, set it to
+ * %NULL. You can set it to a non-%NULL value at any time later.
  *
  * Returns: a new #HildonButton
  **/
 GtkWidget *
-hildon_button_new_with_text                     (HildonButtonFlags  flags,
-                                                 const char        *title,
-                                                 const char        *value)
+hildon_button_new_with_text                     (HildonSizeType           size,
+                                                 HildonButtonArrangement  arrangement,
+                                                 const gchar             *title,
+                                                 const gchar             *value)
 {
-    return hildon_button_new_full (flags, title, value, NULL, NULL);
+    return hildon_button_new_full (size, arrangement, title, value, NULL, NULL);
 }
 
 /**
  * hildon_button_new_full:
- * @flags: flags to set the size and layout of the button
+ * @size: Flags to set the size of the button.
+ * @arrangement: How the labels must be arranged.
  * @title: Title of the button (main label)
  * @value: Value of the button (secondary label), or %NULL
  * @title_size_group: a #GtkSizeGroup for the @title label, or %NULL
@@ -274,8 +294,8 @@ hildon_button_new_with_text                     (HildonButtonFlags  flags,
  * Creates a new #HildonButton with two labels, @title and @value, and
  * their respective size groups.
  *
- * If you just want to use the main label, set @value to %NULL. You
- * can set it to a non-%NULL value at any time later.
+ * If you just don't want to use one of the labels, set it to
+ * %NULL. You can set it to a non-%NULL value at any time later.
  *
  * @title and @value will be added to @title_size_group and
  * @value_size_group, respectively, if present.
@@ -283,17 +303,19 @@ hildon_button_new_with_text                     (HildonButtonFlags  flags,
  * Returns: a new #HildonButton
  **/
 GtkWidget *
-hildon_button_new_full                          (HildonButtonFlags  flags,
-                                                 const char        *title,
-                                                 const char        *value,
-                                                 GtkSizeGroup      *title_size_group,
-                                                 GtkSizeGroup      *value_size_group)
+hildon_button_new_full                          (HildonSizeType           size,
+                                                 HildonButtonArrangement  arrangement,
+                                                 const gchar             *title,
+                                                 const gchar             *value,
+                                                 GtkSizeGroup            *title_size_group,
+                                                 GtkSizeGroup            *value_size_group)
 {
     GtkWidget *button;
 
     /* Create widget */
     button = g_object_new (HILDON_TYPE_BUTTON,
-                           "arrangement-flags", flags,
+                           "size-flags", size,
+                           "arrangement", arrangement,
                            "title", title,
                            "value", value,
                            "name", "hildon-button",
@@ -306,51 +328,23 @@ hildon_button_new_full                          (HildonButtonFlags  flags,
 }
 
 static void
-hildon_button_set_arrangement (HildonButton *button,
-                               HildonButtonFlags flags)
+hildon_button_set_arrangement                   (HildonButton            *button,
+                                                 HildonButtonArrangement  arrangement)
 {
     GtkWidget *box;
     HildonButtonPrivate *priv;
     guint horizontal_spacing;
     guint vertical_spacing;
-    gint width = -1;
-    gint height = -1;
-    const char *widget_name = NULL;
 
     priv = HILDON_BUTTON_GET_PRIVATE (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";
-    }
-
-    if (widget_name) {
-        gtk_widget_set_name (GTK_WIDGET (button), widget_name);
-    }
-
-    /* Requested width */
-    if (flags & HILDON_BUTTON_HALFSCREEN_WIDTH) {
-        width = HALFSCREEN_BUTTON_WIDTH;
-    } else if (flags & HILDON_BUTTON_FULLSCREEN_WIDTH) {
-        width = FULLSCREEN_BUTTON_WIDTH;
-    }
-
-    g_object_set (button,
-                  "width-request", width,
-                  "height-request", height,
-                  NULL);
-
     /* Pack everything */
     gtk_widget_style_get (GTK_WIDGET (button),
                           "horizontal-spacing", &horizontal_spacing,
                           "vertical-spacing", &vertical_spacing,
                           NULL);
 
-    if (flags & HILDON_BUTTON_WITH_VERTICAL_VALUE) {
+    if (arrangement == HILDON_BUTTON_ARRANGEMENT_VERTICAL) {
         box = gtk_vbox_new (FALSE, vertical_spacing);
     } else {
         box = gtk_hbox_new (FALSE, horizontal_spacing);
@@ -373,7 +367,7 @@ hildon_button_set_arrangement (HildonButton *button,
  **/
 void
 hildon_button_set_title                         (HildonButton *button,
-                                                 const char   *title)
+                                                 const gchar  *title)
 {
     HildonButtonPrivate *priv;
 
@@ -403,7 +397,7 @@ hildon_button_set_title                         (HildonButton *button,
  **/
 void
 hildon_button_set_value                         (HildonButton *button,
-                                                 const char   *value)
+                                                 const gchar  *value)
 {
     HildonButtonPrivate *priv;
 
@@ -432,7 +426,7 @@ hildon_button_set_value                         (HildonButton *button,
  * Returns: The text of the title label. This string is owned by the
  * widget and must not be modified or freed.
  **/
-const char *
+const gchar *
 hildon_button_get_title                         (HildonButton *button)
 {
     HildonButtonPrivate *priv;
@@ -454,7 +448,7 @@ hildon_button_get_title                         (HildonButton *button)
  * Returns: The text of the value label. This string is owned by the
  * widget and must not be modified or freed.
  **/
-const char *
+const gchar *
 hildon_button_get_value                         (HildonButton *button)
 {
     HildonButtonPrivate *priv;
@@ -476,8 +470,8 @@ hildon_button_get_value                         (HildonButton *button)
  **/
 void
 hildon_button_set_text                          (HildonButton *button,
-                                                 const char   *title,
-                                                 const char   *value)
+                                                 const gchar  *title,
+                                                 const gchar  *value)
 {
     hildon_button_set_title (button, title);
     hildon_button_set_value (button, value);
index 8832ad0..36c8ea5 100644 (file)
@@ -19,7 +19,8 @@
 #ifndef                                         __HILDON_BUTTON_H__
 #define                                         __HILDON_BUTTON_H__
 
-#include <gtk/gtk.h>
+#include                                        <gtk/gtk.h>
+#include                                        "hildon-helper.h"
 
 G_BEGIN_DECLS
 
@@ -59,52 +60,49 @@ struct                                          _HildonButton
 };
 
 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;
+   HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
+   HILDON_BUTTON_ARRANGEMENT_VERTICAL
+}                                               HildonButtonArrangement;
 
 GType
 hildon_button_get_type                          (void) G_GNUC_CONST;
 
 GtkWidget *
-hildon_button_new                               (HildonButtonFlags flags);
+hildon_button_new                               (HildonSizeType          size,
+                                                 HildonButtonArrangement arrangement);
 
 GtkWidget *
-hildon_button_new_with_text                     (HildonButtonFlags  flags,
-                                                 const char        *title,
-                                                 const char        *value);
+hildon_button_new_with_text                     (HildonSizeType           size,
+                                                 HildonButtonArrangement  arrangement,
+                                                 const gchar             *title,
+                                                 const gchar             *value);
 
 GtkWidget *
-hildon_button_new_full                          (HildonButtonFlags  flags,
-                                                 const char        *title,
-                                                 const char        *value,
-                                                 GtkSizeGroup      *title_size_group,
-                                                 GtkSizeGroup      *value_size_group);
+hildon_button_new_full                          (HildonSizeType           size,
+                                                 HildonButtonArrangement  arrangement,
+                                                 const gchar             *title,
+                                                 const gchar             *value,
+                                                 GtkSizeGroup            *title_size_group,
+                                                 GtkSizeGroup            *value_size_group);
 
 void
 hildon_button_set_title                         (HildonButton *button,
-                                                 const char *title);
+                                                 const gchar  *title);
 
 void
 hildon_button_set_value                         (HildonButton *button,
-                                                 const char *value);
+                                                 const gchar  *value);
 
-const char *
+const gchar *
 hildon_button_get_title                         (HildonButton *button);
 
-const char *
+const gchar *
 hildon_button_get_value                         (HildonButton *button);
 
 void
 hildon_button_set_text                          (HildonButton *button,
-                                                 const char   *title,
-                                                 const char   *value);
+                                                 const gchar  *title,
+                                                 const gchar  *value);
 
 void
 hildon_button_set_size_groups                   (HildonButton *button,
index 0252bfe..fb3032d 100644 (file)
@@ -79,11 +79,13 @@ hildon_date_button_init (HildonDateButton * self)
 }
 
 GtkWidget *
-hildon_date_button_new (HildonButtonFlags flags)
+hildon_date_button_new (HildonSizeType          size,
+                        HildonButtonArrangement arrangement)
 {
   return g_object_new (HILDON_TYPE_DATE_BUTTON,
                        "title", "Date",
-                       "arrangement-flags", flags,
+                       "arrangement", arrangement,
+                       "size-flags", size,
                        NULL);
 }
 
index b8cc255..74ba8aa 100644 (file)
@@ -39,7 +39,8 @@ typedef struct
 } HildonDateButtonClass;
 
 GType      hildon_date_button_get_type (void);
-GtkWidget *hildon_date_button_new      (HildonButtonFlags flags);
+GtkWidget *hildon_date_button_new      (HildonSizeType          size,
+                                        HildonButtonArrangement arrangement);
 
 void hildon_date_button_get_date       (HildonDateButton * button,
                                         guint * year, guint * month, guint * day);
index 0f3608c..a043bc1 100644 (file)
 #include                                        "hildon-helper.h"
 #include                                        "hildon-banner.h"
 
+#define                                         HILDON_HEIGHT_FINGER 70
+
+#define                                         HILDON_HEIGHT_THUMB 105
+
+#define                                         HILDON_WIDTH_FULLSCREEN (gdk_screen_get_width (gdk_screen_get_default ()))
+
+#define                                         HILDON_WIDTH_HALFSCREEN (HILDON_WIDTH_FULLSCREEN / 2)
+
 #define                                         HILDON_FINGER_PRESSURE_THRESHOLD 0.4
 
 #define                                         HILDON_FINGER_BUTTON 8
@@ -501,6 +509,41 @@ hildon_helper_set_thumb_scrollbar               (GtkScrolledWindow *win,
         gtk_widget_set_name (win->vscrollbar, (thumb) ? "hildon-thumb-scrollbar" : NULL);
 }
 
+/**
+ * hildon_helper_set_theme_size
+ * @widget: A @GtkWidget
+ * @size: Flags indicating the size of the widget
+ *
+ * This function sets the requested size of a widget.
+ **/
+void
+hildon_helper_set_theme_size                    (GtkWidget      *widget,
+                                                 HildonSizeType  size)
+{
+    gint width = -1;
+    gint height = -1;
+    const gchar *widget_name = NULL;
 
+    g_return_if_fail (GTK_IS_WIDGET (widget));
 
+    /* Requested height */
+    if (size & HILDON_SIZE_FINGER_HEIGHT) {
+        height = HILDON_HEIGHT_FINGER;
+        widget_name = "hildon-finger-widget";
+    } else if (size & HILDON_SIZE_THUMB_HEIGHT) {
+        height = HILDON_HEIGHT_THUMB;
+        widget_name = "hildon-thumb-widget";
+    }
 
+    /* Requested width */
+    if (size & HILDON_SIZE_HALFSCREEN_WIDTH) {
+        width = HILDON_WIDTH_HALFSCREEN;
+    } else if (size & HILDON_SIZE_FULLSCREEN_WIDTH) {
+        width = HILDON_WIDTH_FULLSCREEN;
+    }
+
+    gtk_widget_set_size_request (widget, width, height);
+
+    if (widget_name)
+        gtk_widget_set_name (widget, widget_name);
+}
index 90a15d3..a8d9df1 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef enum {
+   HILDON_SIZE_AUTO_WIDTH                       = 0 << 0, /* set to automatic width */
+   HILDON_SIZE_HALFSCREEN_WIDTH                 = 1 << 0, /* set to 50% screen width */
+   HILDON_SIZE_FULLSCREEN_WIDTH                 = 2 << 0, /* set to 100% screen width */
+   HILDON_SIZE_AUTO_HEIGHT                      = 0 << 2, /* set to automatic height */
+   HILDON_SIZE_FINGER_HEIGHT                    = 1 << 2, /* set to finger height */
+   HILDON_SIZE_THUMB_HEIGHT                     = 2 << 2, /* set to thumb height */
+   HILDON_SIZE_AUTO                             = (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_AUTO_HEIGHT)
+}                                               HildonSizeType;
+
 gulong
 hildon_helper_set_logical_font                  (GtkWidget *widget, 
                                                  const gchar *logicalfontname);
@@ -57,6 +67,10 @@ void
 hildon_helper_set_thumb_scrollbar               (GtkScrolledWindow *win, 
                                                  gboolean thumb);
 
+void
+hildon_helper_set_theme_size                    (GtkWidget       *button,
+                                                 HildonSizeType   size);
+
 G_END_DECLS
 
 #endif                                          /* __HILDON_HELPER_H__ */
index 20a34f3..d869934 100644 (file)
@@ -156,12 +156,13 @@ hildon_picker_button_init (HildonPickerButton * self)
 }
 
 GtkWidget *
-hildon_picker_button_new (HildonButtonFlags flags)
+hildon_picker_button_new (HildonSizeType          size,
+                          HildonButtonArrangement arrangement)
 {
   GtkWidget *button;
 
   button = g_object_new (HILDON_TYPE_PICKER_BUTTON,
-                         "arrangement-flags", flags, NULL);
+                         "arrangement", arrangement, "size-flags", size, NULL);
 
   return button;
 }
index 0139088..6ceff2b 100644 (file)
@@ -41,7 +41,8 @@ typedef struct
 } HildonPickerButtonClass;
 
 GType      hildon_picker_button_get_type (void);
-GtkWidget *hildon_picker_button_new      (HildonButtonFlags flags);
+GtkWidget *hildon_picker_button_new      (HildonSizeType          size,
+                                          HildonButtonArrangement arrangement);
 
 void hildon_picker_button_set_selector     (HildonPickerButton * button,
                                             HildonTouchSelector * selector);
index b2926cf..a69c9e5 100644 (file)
@@ -78,10 +78,11 @@ hildon_time_button_init (HildonTimeButton * self)
 }
 
 GtkWidget *
-hildon_time_button_new (HildonButtonFlags flags)
+hildon_time_button_new (HildonSizeType          size,
+                        HildonButtonArrangement arrangement)
 {
   return g_object_new (HILDON_TYPE_TIME_BUTTON,
-                       "title", "Time", "arrangement-flags", flags, NULL);
+                       "title", "Time", "arrangement", arrangement, "size-flags", size, NULL);
 }
 
 void
index 6181cac..18f6257 100644 (file)
@@ -39,7 +39,8 @@ typedef struct
 } HildonTimeButtonClass;
 
 GType      hildon_time_button_get_type (void);
-GtkWidget *hildon_time_button_new      (HildonButtonFlags flags);
+GtkWidget *hildon_time_button_new      (HildonSizeType          size,
+                                        HildonButtonArrangement arrangement);
 
 void hildon_time_button_get_time       (HildonTimeButton * button,
                                         guint * hours, guint * minutes);
index 5dd2137..311d8e5 100644 (file)
@@ -74,6 +74,7 @@
 #include                                        "hildon-pannable-area.h"
 #include                                        "hildon-app-menu.h"
 #include                                        "hildon-button.h"
+#include                                        "hildon-button-helpers.h"
 #include                                        "hildon-dialog.h"
 
 #endif