2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * SECTION:hildon-find-toolbar
27 * @short_description: A toolbar with a search field.
28 * @see_also: #HildonWindow
30 * HildonFindToolbar is a toolbar that contains a search entry and a dropdown
31 * list with previously searched strings. The list is represented using a
32 * #GtkListStore and can be accesed using a property 'list'. Entries are added
33 * automatically to the list when the search button is pressed.
41 #include "hildon-find-toolbar.h"
42 #include "hildon-defines.h"
43 #include <gdk/gdkkeysyms.h>
44 #include <gtk/gtklabel.h>
45 #include <gtk/gtkentry.h>
46 #include <gtk/gtkbutton.h>
47 #include <gtk/gtktoolbutton.h>
48 #include <gtk/gtktoolitem.h>
49 #include <gtk/gtkcomboboxentry.h>
50 #include <gtk/gtkseparatortoolitem.h>
53 #include "hildon-find-toolbar-private.h"
56 dgettext("hildon-libs", String)
58 /* Same define as gtkentry.c as entry will further handle this */
60 #define MAX_SIZE G_MAXUSHORT
62 #define FIND_LABEL_XPADDING 6
64 #define FIND_LABEL_YPADDING 0
67 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv);
70 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv);
73 hildon_find_toolbar_filter (GtkTreeModel *model,
78 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
82 hildon_find_toolbar_get_property (GObject *object,
88 hildon_find_toolbar_set_property (GObject *object,
94 hildon_find_toolbar_find_string (HildonFindToolbar *self,
100 hildon_find_toolbar_history_append (HildonFindToolbar *self,
104 hildon_find_toolbar_emit_search (GtkButton *button,
108 hildon_find_toolbar_emit_close (GtkButton *button,
113 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
114 GtkInvalidInputType type,
119 hildon_find_toolbar_entry_activate (GtkWidget *widget,
123 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass);
126 hildon_find_toolbar_init (HildonFindToolbar *self);
149 static guint HildonFindToolbar_signal [LAST_SIGNAL] = {0};
152 * hildon_find_toolbar_get_type:
154 * Initializes and returns the type of a hildon fond toolbar.
156 * @Returns: GType of #HildonFindToolbar
159 hildon_find_toolbar_get_type (void)
161 static GType find_toolbar_type = 0;
163 if (! find_toolbar_type) {
164 static const GTypeInfo find_toolbar_info = {
165 sizeof(HildonFindToolbarClass),
166 NULL, /* base_init */
167 NULL, /* base_finalize */
168 (GClassInitFunc) hildon_find_toolbar_class_init,
169 NULL, /* class_finalize */
170 NULL, /* class_data */
171 sizeof(HildonFindToolbar),
173 (GInstanceInitFunc) hildon_find_toolbar_init,
175 find_toolbar_type = g_type_register_static (GTK_TYPE_TOOLBAR,
177 &find_toolbar_info, 0);
180 return find_toolbar_type;
184 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv)
186 GtkTreeModel *filter_model =
187 gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
189 return filter_model == NULL ? NULL :
190 gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
194 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv)
196 return GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->entry_combo_box)));
200 hildon_find_toolbar_filter (GtkTreeModel *model,
210 total = gtk_tree_model_iter_n_children (model, NULL);
211 g_object_get (self, "history_limit", &limit, NULL);
212 path = gtk_tree_model_get_path (model, iter);
213 indices = gtk_tree_path_get_indices (path);
215 /* set the row's index, list store has only one level */
217 gtk_tree_path_free (path);
219 /*if the row is among the latest "history_limit" additions of the
220 * model, then we show it */
221 if( (total - limit <= n) && (n < total) )
228 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
231 GtkTreeModel *filter;
232 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
235 /* Create a filter for the given model. Its only purpose is to hide
236 the oldest entries so only "history_limit" entries are visible. */
237 filter = gtk_tree_model_filter_new (model, NULL);
239 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(filter),
240 hildon_find_toolbar_filter,
243 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->entry_combo_box), filter);
245 /* ComboBox keeps the only needed reference to the filter */
246 g_object_unref (filter);
250 hildon_find_toolbar_get_property (GObject *object,
255 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
264 string = gtk_label_get_text (GTK_LABEL (priv->label));
265 g_value_set_string (value, string);
269 string = gtk_entry_get_text (hildon_find_toolbar_get_entry(priv));
270 g_value_set_string (value, string);
274 g_value_set_object (value, hildon_find_toolbar_get_list_model(priv));
278 c_n = gtk_combo_box_entry_get_text_column (priv->entry_combo_box);
279 g_value_set_int (value, c_n);
283 max_len = gtk_entry_get_max_length (hildon_find_toolbar_get_entry(priv));
284 g_value_set_int (value, max_len);
287 case PROP_HISTORY_LIMIT:
288 g_value_set_int (value, priv->history_limit);
292 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
298 hildon_find_toolbar_set_property (GObject *object,
303 HildonFindToolbar *self = HILDON_FIND_TOOLBAR(object);
304 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
313 string = g_value_get_string (value);
314 gtk_label_set_text (GTK_LABEL (priv->label), string);
318 string = g_value_get_string (value);
319 gtk_entry_set_text (hildon_find_toolbar_get_entry(priv), string);
323 model = GTK_TREE_MODEL (g_value_get_object(value));
324 hildon_find_toolbar_apply_filter (self, model);
328 gtk_combo_box_entry_set_text_column (priv->entry_combo_box,
329 g_value_get_int (value));
333 gtk_entry_set_max_length (hildon_find_toolbar_get_entry(priv),
334 g_value_get_int (value));
337 case PROP_HISTORY_LIMIT:
338 priv->history_limit = g_value_get_int (value);
340 /* Re-apply the history limit to the model. */
341 model = hildon_find_toolbar_get_list_model (priv);
344 /* Note that refilter function doesn't update the status of the
345 combobox popup arrow, so we'll just recreate the filter. */
346 hildon_find_toolbar_apply_filter (self, model);
348 if (gtk_combo_box_entry_get_text_column (priv->entry_combo_box) == -1)
350 /* FIXME: This is only for backwards compatibility, although
351 probably nothing actually relies on it. The behavior was only
352 an accidental side effect of original code */
353 gtk_combo_box_entry_set_text_column (priv->entry_combo_box, 0);
359 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
365 hildon_find_toolbar_find_string (HildonFindToolbar *self,
370 GtkTreeModel *model = NULL;
372 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
375 model = hildon_find_toolbar_get_list_model (priv);
377 if (gtk_tree_model_get_iter_first (model, iter))
380 gtk_tree_model_get (model, iter, column, &old_string, -1);
381 if (old_string != NULL && strcmp (string, old_string) == 0)
386 } while (gtk_tree_model_iter_next (model, iter));
393 hildon_find_toolbar_history_append (HildonFindToolbar *self,
396 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
401 GtkTreeModel *model = NULL;
402 GtkListStore *list = NULL;
404 gboolean self_create = FALSE;
406 g_object_get (self, "prefix", &string, NULL);
410 /* empty prefix, ignore */
416 /* If list store is set, get it */
417 model = hildon_find_toolbar_get_list_model(priv);
420 list = GTK_LIST_STORE (model);
421 g_object_get(self, "column", &column, NULL);
425 /* Column number is -1 if "column" property hasn't been set but
426 "list" property is. */
431 /* Latest string is always the first one in list. If the string
432 already exists, remove it so there are no duplicates in list. */
433 if (hildon_find_toolbar_find_string (self, &iter, column, string))
434 gtk_list_store_remove (list, &iter);
438 /* No list store set. Create our own. */
439 list = gtk_list_store_new (1, G_TYPE_STRING);
440 model = GTK_TREE_MODEL (list);
444 /* Add the string to first in list */
445 gtk_list_store_append (list, &iter);
446 gtk_list_store_set (list, &iter, column, string, -1);
450 /* Add the created list to ComboBoxEntry */
451 hildon_find_toolbar_apply_filter (self, model);
452 /* ComboBoxEntry keeps the only needed reference to this list */
453 g_object_unref (list);
455 /* Set the column only after ComboBoxEntry's model is set
456 in hildon_find_toolbar_apply_filter() */
457 g_object_set (self, "column", 0, NULL);
461 /* Refilter to get the oldest entry hidden from history */
462 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(
463 gtk_combo_box_get_model (GTK_COMBO_BOX(priv->entry_combo_box))));
472 hildon_find_toolbar_emit_search (GtkButton *button,
477 /* Clicked search button. Perform search and add search prefix to history */
478 g_signal_emit_by_name(self, "search", NULL);
479 g_signal_emit_by_name(self, "history_append", &rb, NULL);
483 hildon_find_toolbar_emit_close (GtkButton *button,
487 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
490 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (priv->entry_combo_box));
491 if (GTK_WIDGET_HAS_FOCUS (entry))
493 hildon_gtk_im_context_hide (GTK_ENTRY (entry)->im_context);
497 /* Clicked close button */
498 g_signal_emit_by_name (self, "close", NULL);
503 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
504 GtkInvalidInputType type,
507 if(type == GTK_INVALID_INPUT_MAX_CHARS_REACHED)
508 g_signal_emit_by_name (self, "invalid_input", NULL);
513 hildon_find_toolbar_entry_activate (GtkWidget *widget,
516 GtkWidget *find_toolbar = GTK_WIDGET (user_data);
519 /* NB#40936 stop focus from moving to next widget */
520 g_signal_stop_emission_by_name (widget, "activate");
522 g_signal_emit_by_name (find_toolbar, "search", NULL);
523 g_signal_emit_by_name (find_toolbar, "history_append", &rb, NULL);
527 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass)
529 GObjectClass *object_class;
531 g_type_class_add_private (klass, sizeof (HildonFindToolbarPrivate));
533 object_class = G_OBJECT_CLASS(klass);
535 object_class->get_property = hildon_find_toolbar_get_property;
536 object_class->set_property = hildon_find_toolbar_set_property;
538 klass->history_append = (gpointer) hildon_find_toolbar_history_append;
541 * HildonFindToolbar:label:
543 * The label to display before the search box.
546 g_object_class_install_property (object_class, PROP_LABEL,
547 g_param_spec_string ("label",
548 "Label", "Displayed name for"
550 _("ecdg_ti_find_toolbar_label"),
555 * HildonFindToolbar:label:
557 * The label to display before the search box.
560 g_object_class_install_property (object_class, PROP_PREFIX,
561 g_param_spec_string ("prefix",
562 "Prefix", "Search string", NULL,
566 * HildonFindToolbar:list:
568 * A #GtkListStore where the search history is kept.
571 g_object_class_install_property (object_class, PROP_LIST,
572 g_param_spec_object ("list",
573 "List"," GtkListStore model where "
574 "history list is kept",
579 * HildonFindToolbar:column:
581 * The column number in GtkListStore where strings of
582 * search history are kept.
585 g_object_class_install_property(object_class, PROP_COLUMN,
586 g_param_spec_int ("column",
587 "Column", "Column number in GtkListStore "
588 "where history list strings are kept",
590 0, G_PARAM_READWRITE));
593 * HildonFindToolbar:label:
595 * The label to display before the search box.
598 g_object_class_install_property (object_class, PROP_MAX,
599 g_param_spec_int ("max_characters",
600 "Maximum number of characters",
601 "Maximum number of characters "
604 0, G_PARAM_READWRITE |
608 * HildonFindToolbar:history-limit:
610 * Maximum number of history items in the combobox.
613 g_object_class_install_property (object_class, PROP_HISTORY_LIMIT,
614 g_param_spec_int ("history-limit",
615 "Maximum number of history items",
616 "Maximum number of history items "
617 "in search combobox",
619 5, G_PARAM_READWRITE |
623 * HildonFindToolbar::search:
624 * @toolbar: the toolbar which received the signal
626 * Gets emitted when the find button is pressed.
628 HildonFindToolbar_signal[SEARCH] =
630 "search", HILDON_TYPE_FIND_TOOLBAR,
631 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
632 (HildonFindToolbarClass, search),
633 NULL, NULL, gtk_marshal_VOID__VOID,
637 * HildonFindToolbar::close:
638 * @toolbar: the toolbar which received the signal
640 * Gets emitted when the close button is pressed.
642 HildonFindToolbar_signal[CLOSE] =
644 "close", HILDON_TYPE_FIND_TOOLBAR,
645 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
646 (HildonFindToolbarClass, close),
647 NULL, NULL, gtk_marshal_VOID__VOID,
651 * HildonFindToolbar::invalid-input:
652 * @toolbar: the toolbar which received the signal
654 * Gets emitted when the maximum search prefix length is reached and
655 * user tries to type more.
657 HildonFindToolbar_signal[INVALID_INPUT] =
659 "invalid_input", HILDON_TYPE_FIND_TOOLBAR,
660 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
661 (HildonFindToolbarClass, invalid_input),
662 NULL, NULL, gtk_marshal_VOID__VOID,
666 * HildonFindToolbar::history-append:
667 * @toolbar: the toolbar which received the signal
669 * Gets emitted when the current search prefix should be added to history.
671 HildonFindToolbar_signal[HISTORY_APPEND] =
673 "history_append", HILDON_TYPE_FIND_TOOLBAR,
674 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
675 (HildonFindToolbarClass, history_append),
676 g_signal_accumulator_true_handled, NULL,
677 gtk_marshal_BOOLEAN__VOID,
682 hildon_find_toolbar_init (HildonFindToolbar *self)
684 GtkToolItem *label_container;
685 GtkToolItem *entry_combo_box_container;
686 GtkAlignment *alignment;
688 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
691 /* Create the label */
692 priv->label = gtk_label_new (_("ecdg_ti_find_toolbar_label"));
694 gtk_misc_set_padding (GTK_MISC (priv->label), FIND_LABEL_XPADDING,
695 FIND_LABEL_YPADDING);
697 label_container = gtk_tool_item_new ();
698 gtk_container_add (GTK_CONTAINER (label_container),
701 gtk_widget_show_all (GTK_WIDGET (label_container));
702 gtk_toolbar_insert (GTK_TOOLBAR (self), label_container, -1);
704 /* ComboBoxEntry for search prefix string / history list */
705 priv->entry_combo_box = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new ());
708 g_signal_connect (hildon_find_toolbar_get_entry(priv),
710 G_CALLBACK(hildon_find_toolbar_emit_invalid_input), self);
713 entry_combo_box_container = gtk_tool_item_new ();
714 alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
716 gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
717 gtk_container_add (GTK_CONTAINER (alignment),
718 GTK_WIDGET (priv->entry_combo_box));
719 gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
720 GTK_WIDGET (alignment));
721 gtk_widget_show_all(GTK_WIDGET (entry_combo_box_container));
722 gtk_toolbar_insert (GTK_TOOLBAR (self), entry_combo_box_container, -1);
723 g_signal_connect (hildon_find_toolbar_get_entry (priv),
725 G_CALLBACK(hildon_find_toolbar_entry_activate), self);
728 priv->find_button = gtk_tool_button_new (
729 gtk_image_new_from_icon_name ("qgn_toolb_browser_gobutton",
730 HILDON_ICON_SIZE_TOOLBAR),
733 g_signal_connect (priv->find_button, "clicked",
734 G_CALLBACK(hildon_find_toolbar_emit_search), self);
735 gtk_widget_show_all( GTK_WIDGET(priv->find_button));
736 gtk_toolbar_insert ( GTK_TOOLBAR(self), priv->find_button, -1);
737 gtk_widget_set_size_request (GTK_WIDGET (priv->find_button), 72, -1);
738 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->find_button)->child) )
739 GTK_WIDGET_UNSET_FLAGS(
740 GTK_BIN(priv->find_button)->child, GTK_CAN_FOCUS);
743 priv->separator = gtk_separator_tool_item_new();
744 gtk_widget_show(GTK_WIDGET(priv->separator));
745 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->separator, -1);
748 priv->close_button = gtk_tool_button_new (
749 gtk_image_new_from_icon_name ("qgn_toolb_gene_close",
750 HILDON_ICON_SIZE_TOOLBAR),
752 gtk_widget_set_size_request (GTK_WIDGET (priv->close_button), 72, -1);
753 g_signal_connect(priv->close_button, "clicked",
754 G_CALLBACK(hildon_find_toolbar_emit_close), self);
755 gtk_widget_show_all(GTK_WIDGET(priv->close_button));
756 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->close_button, -1);
757 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->close_button)->child) )
758 GTK_WIDGET_UNSET_FLAGS(
759 GTK_BIN(priv->close_button)->child, GTK_CAN_FOCUS);
763 * hildon_find_toolbar_new:
764 * @label: label for the find_toolbar, NULL to set the label to
767 * Creates a new HildonFindToolbar.
769 * Returns: a new HildonFindToolbar
772 hildon_find_toolbar_new (const gchar *label)
774 GtkWidget *findtoolbar;
776 findtoolbar = GTK_WIDGET (g_object_new (HILDON_TYPE_FIND_TOOLBAR, NULL));
779 g_object_set(findtoolbar, "label", label, NULL);
785 * hildon_find_toolbar_new_with_model:
786 * @label: label for the find_toolbar, NULL to set the label to
788 * @model: a @GtkListStore
789 * @column: indicating which column the search histry list will
790 * retreive string from
792 * Creates a new HildonFindToolbar with a model.
794 * Returns: a new #HildonFindToolbar
797 hildon_find_toolbar_new_with_model (const gchar *label,
801 GtkWidget *findtoolbar;
803 findtoolbar = hildon_find_toolbar_new (label);
805 g_object_set (findtoolbar, "list", model, "column", column, NULL);
811 * hildon_find_toolbar_highlight_entry:
812 * @ftb: find Toolbar whose entry is to be highlighted
813 * @get_focus: if user passes TRUE to this value, then the text in
814 * the entry will not only get highlighted, but also get focused.
816 * Highlights the current entry in the find toolbar.
820 hildon_find_toolbar_highlight_entry (HildonFindToolbar *self,
823 GtkEntry *entry = NULL;
824 HildonFindToolbarPrivate *priv;
826 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (self));
827 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
830 entry = hildon_find_toolbar_get_entry (priv);
832 gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
835 gtk_widget_grab_focus (GTK_WIDGET (entry));
839 * hildon_find_toolbar_set_active:
840 * @toolbar: A find toolbar to operate on
841 * @index: An index in the model passed during construction, or -1 to have no active item
843 * Sets the active item on the toolbar's combo-box. Simply calls gtk_combo_box_set_active on
844 * the HildonFindToolbar's combo.
848 hildon_find_toolbar_set_active (HildonFindToolbar *toolbar,
851 HildonFindToolbarPrivate *priv;
853 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
854 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
856 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->entry_combo_box), index);
860 * hildon_find_toolbar_get_active:
861 * @toolbar: A find toolbar to query
863 * Gets the index of the currently active item, or -1 if there's no active item. Simply
864 * calls gtk_combo_box_get_active on the HildonFindToolbar's combo.
866 * Returns: An integer which is the index of the currently active item, or -1 if there's no active item.
870 hildon_find_toolbar_get_active (HildonFindToolbar *toolbar)
872 HildonFindToolbarPrivate *priv;
874 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), -1);
875 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
877 return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->entry_combo_box));
881 * hildon_find_toolbar_set_active_iter:
882 * @toolbar: A find toolbar to operate on
883 * @iter: An iter to make active
885 * Sets the current active item to be the one referenced by iter. Simply calls
886 * gtk_combo_box_set_active_iter on the HildonFindToolbar's combo.
890 hildon_find_toolbar_set_active_iter (HildonFindToolbar *toolbar,
893 HildonFindToolbarPrivate *priv;
895 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
896 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
898 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
902 * hildon_find_toolbar_get_active_iter:
903 * @toolbar: A find toolbar to query
904 * @iter: The uninitialized GtkTreeIter
906 * Sets iter to point to the current active item, if it exists. Simply calls
907 * gtk_combo_box_get_active_iter on the HildonFindToolbar's combo.
909 * Returns: TRUE, if iter was set
913 hildon_find_toolbar_get_active_iter (HildonFindToolbar *toolbar,
916 HildonFindToolbarPrivate *priv;
918 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
919 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
921 return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
925 * hildon_find_toolbar_get_last_index
926 * @toolbar: A find toolbar to query
928 * Returns the index of the last (most recently added) item in the toolbar.
929 * Can be used to set this item active in the history-append signal.
932 * Returns: Index of the last entry
936 hildon_find_toolbar_get_last_index (HildonFindToolbar *toolbar)
938 HildonFindToolbarPrivate *priv;
939 GtkTreeModel *filter_model;
941 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
942 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
944 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
946 if (filter_model == NULL)
952 gtk_tree_model_get_iter_first (filter_model, &iter);
954 while (gtk_tree_model_iter_next (filter_model, &iter))