2008-09-15 Alberto Garcia <agarcia@igalia.com>
[hildon] / src / hildon-find-toolbar.c
index fb55823..b8deb4e 100644 (file)
  * #GtkListStore and can be accesed using a property 'list'. Entries are added
  * automatically to the list when the search button is pressed.
  *
- */    
+ */
 
 #ifdef                                          HAVE_CONFIG_H
 #include                                        <config.h>
 #endif
 
-#include                                        "hildon-find-toolbar.h"
-#include                                        "hildon-defines.h"
-#include                                        <gdk/gdkkeysyms.h>
-#include                                        <gtk/gtklabel.h>
-#include                                        <gtk/gtkentry.h>
-#include                                        <gtk/gtkbutton.h>
-#include                                        <gtk/gtktoolbutton.h>
-#include                                        <gtk/gtktoolitem.h>
-#include                                        <gtk/gtkcomboboxentry.h>
-#include                                        <gtk/gtkseparatortoolitem.h>
 #include                                        <string.h>
 #include                                        <libintl.h>
+#include                                        <gdk/gdkkeysyms.h>
+
+#include                                        "hildon-find-toolbar.h"
+#include                                        "hildon-defines.h"
 #include                                        "hildon-find-toolbar-private.h"
 
 #define                                         _(String) \
@@ -465,7 +459,7 @@ hildon_find_toolbar_history_append              (HildonFindToolbar *self,
 
     g_free (string);
 
-    return TRUE;
+    return FALSE;
 }
 
 static void
@@ -711,7 +705,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 +915,39 @@ 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;
+    GtkTreeModel *filter_model;
+    
+    g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
+
+    if (filter_model == NULL)
+        return 0;
+
+    gint i = 0;
+    GtkTreeIter iter;
+
+    gtk_tree_model_get_iter_first (filter_model, &iter);
+
+    while (gtk_tree_model_iter_next (filter_model, &iter))
+        i++;
+
+    return i;
+}
+