2008-08-01 Claudio Saavedra <csaavedra@igalia.com>
authorClaudio Saavedra <csaavedra@igalia.com>
Fri, 1 Aug 2008 17:09:11 +0000 (17:09 +0000)
committerClaudio Saavedra <csaavedra@igalia.com>
Fri, 1 Aug 2008 17:09:11 +0000 (17:09 +0000)
* src/hildon-picker-button.c: Removed the simple _text() API.
* src/hildon-picker-button.h: Likewise.

* src/hildon-touch-selector.h:
* src/hildon-touch-selector.c:
(hildon_touch_selector_new_text),
(hildon_touch_selector_append_text),
(hildon_touch_selector_prepend_text),
(hildon_touch_selector_insert_text):

Moved the simple _text() API from HildonPickerButton to
HildonTouchPicker, to provide better escalability and not to tie
that API to HildonPickerButton.

* examples/hildon-picker-button-example.c: (main): Example updated.

ChangeLog
examples/hildon-picker-button-example.c
src/hildon-picker-button.c
src/hildon-picker-button.h
src/hildon-touch-selector.c
src/hildon-touch-selector.h

index c110874..3699eac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-08-01  Claudio Saavedra  <csaavedra@igalia.com>
+
+       * src/hildon-picker-button.c: Removed the simple _text() API.
+       * src/hildon-picker-button.h: Likewise.
+
+       * src/hildon-touch-selector.h:
+       * src/hildon-touch-selector.c:
+       (hildon_touch_selector_new_text),
+       (hildon_touch_selector_append_text),
+       (hildon_touch_selector_prepend_text),
+       (hildon_touch_selector_insert_text):
+
+       Moved the simple _text() API from HildonPickerButton to
+       HildonTouchPicker, to provide better escalability and not to tie
+       that API to HildonPickerButton.
+
+       * examples/hildon-picker-button-example.c: (main): Example updated.
+
 2008-07-31  Alberto Garcia  <agarcia@igalia.com>
 
        * src/hildon-button.c: Updated documentation.
index a1d2528..6b6c92f 100644 (file)
@@ -21,6 +21,7 @@
 #include "hildon-stackable-window.h"
 
 #include "hildon-picker-button.h"
+#include "hildon-touch-selector.h"
 
 static void
 on_picker_value_changed (HildonPickerButton * button, gpointer data)
@@ -35,6 +36,7 @@ main (int argc, char **args)
   HildonProgram *program = NULL;
   GtkWidget *window = NULL;
   GtkWidget *button;
+  GtkWidget *selector;
 
   gtk_init (&argc, &args);
 
@@ -45,15 +47,19 @@ 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_text (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  button = hildon_picker_button_new (HILDON_BUTTON_WITH_VERTICAL_VALUE);
+  selector = hildon_touch_selector_new_text ();
   hildon_button_set_title (HILDON_BUTTON (button), "Continent");
 
-  hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "America");
-  hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Europe");
-  hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Asia");
-  hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Africa");
-  hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button),
-                                    "Australia");
+  hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "America");
+  hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Europe");
+  hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Asia");
+  hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Africa");
+  hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+                                     "Australia");
+
+  hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                     HILDON_TOUCH_SELECTOR (selector));
 
   g_signal_connect (G_OBJECT (button), "value-changed",
                     G_CALLBACK (on_picker_value_changed), NULL);
index ffdc4f2..20a34f3 100644 (file)
@@ -166,94 +166,6 @@ hildon_picker_button_new (HildonButtonFlags flags)
   return button;
 }
 
-GtkWidget *
-hildon_picker_button_new_text (HildonButtonFlags flags)
-{
-  GtkWidget *button;
-  GtkWidget *selector;
-  GtkListStore *store;
-
-  button = hildon_picker_button_new (flags);
-
-  selector = hildon_touch_selector_new ();
-  store = gtk_list_store_new (1, G_TYPE_STRING);
-
-  hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
-                                            GTK_TREE_MODEL (store));
-
-  hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
-                                     HILDON_TOUCH_SELECTOR (selector));
-
-  return button;
-}
-
-void
-hildon_picker_button_append_text (HildonPickerButton * button,
-                                  const gchar * text)
-{
-  HildonPickerButtonPrivate *priv;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-
-  g_return_if_fail (HILDON_IS_PICKER_BUTTON (button));
-  g_return_if_fail (text != NULL);
-
-  priv = GET_PRIVATE (button);
-
-  model =
-    hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (priv->selector), 0);
-
-  g_return_if_fail (GTK_IS_LIST_STORE (model));
-
-  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
-}
-
-void
-hildon_picker_button_prepend_text (HildonPickerButton * button,
-                                   const gchar * text)
-{
-  HildonPickerButtonPrivate *priv;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-
-  g_return_if_fail (HILDON_IS_PICKER_BUTTON (button));
-  g_return_if_fail (text != NULL);
-
-  priv = GET_PRIVATE (button);
-
-  model =
-    hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (priv->selector), 0);
-
-  g_return_if_fail (GTK_IS_LIST_STORE (model));
-
-  gtk_list_store_prepend (GTK_LIST_STORE (model), &iter);
-  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
-}
-
-void
-hildon_picker_button_insert_text (HildonPickerButton * button,
-                                  gint position, const gchar * text)
-{
-  HildonPickerButtonPrivate *priv;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-
-  g_return_if_fail (HILDON_IS_PICKER_BUTTON (button));
-  g_return_if_fail (text != NULL);
-  g_return_if_fail (position >= 0);
-
-  priv = GET_PRIVATE (button);
-
-  model =
-    hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (priv->selector), 0);
-
-  g_return_if_fail (GTK_IS_LIST_STORE (model));
-
-  gtk_list_store_insert (GTK_LIST_STORE (model), &iter, position);
-  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
-}
-
 void
 hildon_picker_button_set_selector (HildonPickerButton * button,
                                    HildonTouchSelector * selector)
index 650e41a..0139088 100644 (file)
@@ -42,14 +42,6 @@ typedef struct
 
 GType      hildon_picker_button_get_type (void);
 GtkWidget *hildon_picker_button_new      (HildonButtonFlags flags);
-GtkWidget *hildon_picker_button_new_text (HildonButtonFlags flags);
-
-void hildon_picker_button_append_text    (HildonPickerButton * button,
-                                          const gchar * text);
-void hildon_picker_button_prepend_text   (HildonPickerButton * button,
-                                          const gchar * text);
-void hildon_picker_button_insert_text    (HildonPickerButton * button,
-                                          gint position, const gchar * text);
 
 void hildon_picker_button_set_selector     (HildonPickerButton * button,
                                             HildonTouchSelector * selector);
index 10a1c36..844e3d3 100644 (file)
@@ -399,6 +399,112 @@ hildon_touch_selector_new ()
 }
 
 /**
+ * hildon_touch_selector_new_text:
+ * @void: 
+ *
+ * Creates a #HildonTouchSelector with a single text column that
+ * can be populated conveniently through hildon_touch_selector_append_text(),
+ * hildon_touch_selector_prepend_text(), hildon_touch_selector_insert_text().
+ *
+ * Returns: A new #HildonTouchSelector
+ **/
+GtkWidget *
+hildon_touch_selector_new_text (void)
+{
+  GtkWidget *selector;
+  GtkListStore *store;
+
+  selector = hildon_touch_selector_new ();
+  store = gtk_list_store_new (1, G_TYPE_STRING);
+
+  hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
+                                            GTK_TREE_MODEL (store));
+
+  return selector;
+}
+
+/**
+ * hildon_touch_selector_append_text:
+ * @selector: A #HildonTouchSelector.
+ * @text: a non %NULL text string.
+ *
+ * Appends a new entry in a #HildonTouchSelector created with
+ * hildon_touch_selector_new_text().
+ **/
+void
+hildon_touch_selector_append_text (HildonTouchSelector * selector,
+                                   const gchar * text)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+  g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
+  g_return_if_fail (text != NULL);
+
+  model = hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (selector), 0);
+
+  g_return_if_fail (GTK_IS_LIST_STORE (model));
+
+  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
+}
+
+/**
+ * hildon_touch_selector_prepend_text:
+ * @selector: A #HildonTouchSelector.
+ * @text: a non %NULL text string.
+ *
+ * Prepends a new entry in a #HildonTouchSelector created with
+ * hildon_touch_selector_new_text().
+ **/
+void
+hildon_touch_selector_prepend_text (HildonTouchSelector * selector,
+                                    const gchar * text)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+  g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
+  g_return_if_fail (text != NULL);
+
+  model = hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (selector), 0);
+
+  g_return_if_fail (GTK_IS_LIST_STORE (model));
+
+  gtk_list_store_prepend (GTK_LIST_STORE (model), &iter);
+  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
+}
+
+/**
+ * hildon_touch_selector_insert_text:
+ * @selector: a #HildonTouchSelector.
+ * @position: the position to insert @text.
+ * @text: A non %NULL text string.
+ *
+ * Inserts a new entry in particular positio of a #HildoTouchSelector created
+ * with hildon_touch_selector_new_text().
+ *
+ **/
+void
+hildon_touch_selector_insert_text (HildonTouchSelector * selector,
+                                   gint position, const gchar * text)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+  g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
+  g_return_if_fail (text != NULL);
+  g_return_if_fail (position >= 0);
+
+  model = hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (selector), 0);
+
+  g_return_if_fail (GTK_IS_LIST_STORE (model));
+
+  gtk_list_store_insert (GTK_LIST_STORE (model), &iter, position);
+  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
+}
+
+/**
  * hildon_touch_selector_append_text_column
  * @selector: the #HildonTouchSelector widget
  * @model: the #GtkTreeModel with the data of the column
index 0306fcb..77e6888 100644 (file)
@@ -64,6 +64,16 @@ typedef enum
 GType      hildon_touch_selector_get_type (void) G_GNUC_CONST;
 GtkWidget *hildon_touch_selector_new      (void);
 
+/* Simple (and recommended) API for one-text-column selectors. */
+GtkWidget *hildon_touch_selector_new_text (void);
+
+void hildon_touch_selector_append_text    (HildonTouchSelector * selector,
+                                          const gchar * text);
+void hildon_touch_selector_prepend_text   (HildonTouchSelector * selector,
+                                          const gchar * text);
+void hildon_touch_selector_insert_text    (HildonTouchSelector * selector,
+                                          gint position, const gchar * text);
+
 /* column related  */
 gboolean hildon_touch_selector_append_text_column     (HildonTouchSelector * selector,
                                                        GtkTreeModel * model);