+2008-10-14 Alejandro Pinheiro <apinheiro@igalia.com>
+
+ * src/hildon-touch-selector.h:
+ Set parent_instance and parent_class as GtkVBox and GtkVboxClass, as
+ currently the type definition was using GTK_TYPE_VBOX
+ * src/hildon-touch-selector.c:
+ Added some implementation notes in order to clarify that any other widget
+ added without the column related API will not be included on the
+ selection logic, and how the widget is freed, as some people ask about
+ it.
+ (hildon_touch_selector_remove): Reimplemented in order to free properly
+ the column related data when you remove the private hbox.
+ * doc/hildon.types: Added the type hildon_touch_selector_column, in order
+ to get a proper HildonTouchSelectorColumn documentation
+
2008-10-13 Claudio Saavedra <csaavedra@igalia.com>
* src/hildon-touch-selector-entry.c:
#include <src/hildon-text-view.h>
#include <src/hildon-button.h>
#include <src/hildon-touch-selector.h>
+#include <src/hildon-touch-selector-column.h>
#include <src/hildon-touch-selector-entry.h>
#include <src/hildon-time-selector.h>
#include <src/hildon-date-selector.h>
hildon_text_view_get_type
hildon_button_get_type
hildon_touch_selector_get_type
+hildon_touch_selector_column_get_type
hildon_touch_selector_entry_get_type
hildon_time_selector_get_type
hildon_date_selector_get_type
#define CENTER_ON_SELECTED_ITEM_DELAY 50
/*
+ * IMPLEMENTATION NOTES:
* Struct to maintain the data of each column. The columns are the elements
- * of the widget that belongs properly to the selection behaviour. As
- * the selector contents are arranged in a #GtkHBox, you can add more widgets,
- * like buttons etc. between the columns, but this doesn't belongs to the
- * selection logic
+ * of the widget that belongs properly to the selection behaviour. Although
+ * internally the columns are arranged in a private #GtkHBox, as the selector
+ * itself is a #GtkVBox, you can add more widgets, like buttons etc., so
+ * you finally could have a widget with more elements that the columns, but
+ * this doesn't belongs to the selection logic
*/
struct _HildonTouchSelectorColumnPrivate
{
gtk_widget_set_size_request (GTK_WIDGET (selector), -1, 320);
}
+/*
+ * IMPLEMENTATION NOTES:
+ * Some people sent questions regarding a missing dispose/finalize function on
+ * this widget that could lead to leak memory, so we will clarify this topic.
+ *
+ * This is not required as #HildonTouchSelector extends #GtkContainer. When the
+ * widget is freed, the #GtkContainer freeing memory functions are called. This
+ * process includes remove each widget individually, so all the widgets are
+ * properly freed.
+ *
+ * In the same way, this widget redefines gtk_container->remove function, in
+ * order to free the column related information if it is required.
+ *
+ * Please take a look to hildon_touch_selector_remove for more information.
+ */
static void
hildon_touch_selector_map (GtkWidget * widget)
{
hildon_touch_selector_remove (GtkContainer * container, GtkWidget * widget)
{
HildonTouchSelector *selector = NULL;
- GSList *iter = NULL;
- gint position = 0;
- HildonTouchSelectorColumn *current_column = NULL;
- gint num_columns = 0;
g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (container));
-
selector = HILDON_TOUCH_SELECTOR (container);
- num_columns = hildon_touch_selector_get_num_columns (selector);
- /* Check if the widget is inside a column and remove
- it from the list */
- iter = selector->priv->columns;
- position = 0;
- while (iter) {
- current_column = HILDON_TOUCH_SELECTOR_COLUMN (iter->data);
- if (widget == current_column->priv->panarea) {
- current_column = g_slist_nth_data (selector->priv->columns, position);
+ /* Remove the extra data related to the columns, if required. */
+ if (widget == selector->priv->hbox) {
+ g_slist_foreach (selector->priv->columns, (GFunc) g_object_unref, NULL);
- selector->priv->columns = g_slist_remove (selector->priv->columns,
- current_column);
- g_free (current_column);
+ g_slist_free (selector->priv->columns);
- break;
- }
-
- position++;
- iter = g_slist_next (iter);
- }
- if (position >= num_columns) {
- g_debug ("This widget was not inside the selector column");
+ selector->priv->columns = NULL;
+ } else {
+ g_debug ("Freeing a widget outside the columns logic");
}
+ /* Now remove the widget itself from the container */
GTK_CONTAINER_CLASS (hildon_touch_selector_parent_class)->remove (container, widget);
}