FIxing the default history-append handler to actually continue firing the other handl...
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Fri, 14 Sep 2007 11:48:48 +0000 (11:48 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Fri, 14 Sep 2007 11:48:48 +0000 (11:48 +0000)
ChangeLog
examples/hildon-find-toolbar-example.c
src/hildon-find-toolbar.c
src/hildon-find-toolbar.h

index 949b05c..4230618 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-09-14  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
+       * examples/hildon-find-toolbar-example.c:
+       * src/hildon-find-toolbar.c:
+       * src/hildon-find-toolbar.h: FIxing the default history-append handler to
+       actually continue firing the other handlers if connected. Adding a new
+       function:
+       hildon_find_toolbar_get_last_index that gets the index of the most
+       recently added (last) item. Fixes: NB#52301.
+
 2007-09-10  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * src/hildon-caption.c: Applying a patch by Tommi to fix the focus
index 314f092..a65eb91 100644 (file)
 #include                                        <gtk/gtk.h>
 #include                                        "hildon.h"
 
+HildonFindToolbar *toolbar = NULL;
+
+gboolean
+on_history_append                               (void);
+
+gboolean
+on_history_append                               (void)
+{
+    hildon_find_toolbar_set_active (toolbar, hildon_find_toolbar_get_last_index (toolbar));
+    return FALSE;
+}
+
 int
 main                                            (int argc, 
                                                  char **args)
@@ -52,10 +64,11 @@ main                                            (int argc,
     gtk_list_store_append (store, &iter);
     gtk_list_store_set (store, &iter, 0, "Third", -1);
 
-    HildonFindToolbar *toolbar = HILDON_FIND_TOOLBAR (hildon_find_toolbar_new_with_model ("Find", store, 0));
+    toolbar = HILDON_FIND_TOOLBAR (hildon_find_toolbar_new_with_model ("Find", store, 0));
     hildon_find_toolbar_set_active (toolbar, 0);
     
     g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+    g_signal_connect_after (G_OBJECT (toolbar), "history-append", G_CALLBACK (on_history_append), NULL);
     
     hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (toolbar));
     gtk_widget_show_all (GTK_WIDGET (toolbar));
index fb55823..006f9b0 100644 (file)
@@ -465,7 +465,7 @@ hildon_find_toolbar_history_append              (HildonFindToolbar *self,
 
     g_free (string);
 
-    return TRUE;
+    return FALSE;
 }
 
 static void
@@ -711,7 +711,7 @@ hildon_find_toolbar_init                        (HildonFindToolbar *self)
 #endif
 
     entry_combo_box_container = gtk_tool_item_new ();
-    alignment = gtk_alignment_new (0, 0.5, 1, 0);
+    alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
 
     gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
     gtk_container_add (GTK_CONTAINER (alignment),
@@ -921,3 +921,33 @@ hildon_find_toolbar_get_active_iter             (HildonFindToolbar *toolbar,
     return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
 }
 
+/**
+ * hildon_find_toolbar_get_last_index
+ * @toolbar: A find toolbar to query
+ *
+ * Returns the index of the last (most recently added) item in the toolbar.
+ * Can be used to set this item active in the history-append signal.
+ *
+ * 
+ * Returns: Index of the last entry
+ *
+ */
+gint32
+hildon_find_toolbar_get_last_index              (HildonFindToolbar *toolbar)
+{
+    HildonFindToolbarPrivate *priv;
+
+    g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    gint i = 0;
+    GtkTreeIter iter;
+
+    gtk_tree_model_get_iter_first (hildon_find_toolbar_get_list_model (priv), &iter);
+
+    while (gtk_tree_model_iter_next (hildon_find_toolbar_get_list_model (priv), &iter))
+        i++;
+
+    return i;
+}
+
index db1552d..b8345b0 100644 (file)
@@ -103,6 +103,9 @@ gboolean
 hildon_find_toolbar_get_active_iter             (HildonFindToolbar *toolbar, 
                                                  GtkTreeIter *iter);
 
+gint32
+hildon_find_toolbar_get_last_index              (HildonFindToolbar *toolbar);
+
 G_END_DECLS
 
 #endif                                          /* __HILDON_FIND_TOOLBAR_H__ */