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.
43 #include <gdk/gdkkeysyms.h>
45 #include "hildon-find-toolbar.h"
46 #include "hildon-defines.h"
47 #include "hildon-find-toolbar-private.h"
50 dgettext("hildon-libs", String)
52 /* Same define as gtkentry.c as entry will further handle this */
54 #define MAX_SIZE G_MAXUSHORT
56 #define FIND_LABEL_XPADDING 6
58 #define FIND_LABEL_YPADDING 0
61 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv);
64 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv);
67 hildon_find_toolbar_filter (GtkTreeModel *model,
72 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
76 hildon_find_toolbar_get_property (GObject *object,
82 hildon_find_toolbar_set_property (GObject *object,
88 hildon_find_toolbar_find_string (HildonFindToolbar *self,
94 hildon_find_toolbar_history_append (HildonFindToolbar *self,
98 hildon_find_toolbar_emit_search (GtkButton *button,
102 hildon_find_toolbar_emit_close (GtkButton *button,
107 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
108 GtkInvalidInputType type,
113 hildon_find_toolbar_entry_activate (GtkWidget *widget,
117 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass);
120 hildon_find_toolbar_init (HildonFindToolbar *self);
143 static guint HildonFindToolbar_signal [LAST_SIGNAL] = {0};
146 * hildon_find_toolbar_get_type:
148 * Initializes and returns the type of a hildon fond toolbar.
150 * @Returns: GType of #HildonFindToolbar
153 hildon_find_toolbar_get_type (void)
155 static GType find_toolbar_type = 0;
157 if (! find_toolbar_type) {
158 static const GTypeInfo find_toolbar_info = {
159 sizeof(HildonFindToolbarClass),
160 NULL, /* base_init */
161 NULL, /* base_finalize */
162 (GClassInitFunc) hildon_find_toolbar_class_init,
163 NULL, /* class_finalize */
164 NULL, /* class_data */
165 sizeof(HildonFindToolbar),
167 (GInstanceInitFunc) hildon_find_toolbar_init,
169 find_toolbar_type = g_type_register_static (GTK_TYPE_TOOLBAR,
171 &find_toolbar_info, 0);
174 return find_toolbar_type;
178 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv)
180 GtkTreeModel *filter_model =
181 gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
183 return filter_model == NULL ? NULL :
184 gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
188 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv)
190 return GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->entry_combo_box)));
194 hildon_find_toolbar_filter (GtkTreeModel *model,
204 total = gtk_tree_model_iter_n_children (model, NULL);
205 g_object_get (self, "history_limit", &limit, NULL);
206 path = gtk_tree_model_get_path (model, iter);
207 indices = gtk_tree_path_get_indices (path);
209 /* set the row's index, list store has only one level */
211 gtk_tree_path_free (path);
213 /*if the row is among the latest "history_limit" additions of the
214 * model, then we show it */
215 if( (total - limit <= n) && (n < total) )
222 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
225 GtkTreeModel *filter;
226 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
229 /* Create a filter for the given model. Its only purpose is to hide
230 the oldest entries so only "history_limit" entries are visible. */
231 filter = gtk_tree_model_filter_new (model, NULL);
233 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(filter),
234 hildon_find_toolbar_filter,
237 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->entry_combo_box), filter);
239 /* ComboBox keeps the only needed reference to the filter */
240 g_object_unref (filter);
244 hildon_find_toolbar_get_property (GObject *object,
249 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
258 string = gtk_label_get_text (GTK_LABEL (priv->label));
259 g_value_set_string (value, string);
263 string = gtk_entry_get_text (hildon_find_toolbar_get_entry(priv));
264 g_value_set_string (value, string);
268 g_value_set_object (value, hildon_find_toolbar_get_list_model(priv));
272 c_n = gtk_combo_box_entry_get_text_column (priv->entry_combo_box);
273 g_value_set_int (value, c_n);
277 max_len = gtk_entry_get_max_length (hildon_find_toolbar_get_entry(priv));
278 g_value_set_int (value, max_len);
281 case PROP_HISTORY_LIMIT:
282 g_value_set_int (value, priv->history_limit);
286 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
292 hildon_find_toolbar_set_property (GObject *object,
297 HildonFindToolbar *self = HILDON_FIND_TOOLBAR(object);
298 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
307 string = g_value_get_string (value);
308 gtk_label_set_text (GTK_LABEL (priv->label), string);
312 string = g_value_get_string (value);
313 gtk_entry_set_text (hildon_find_toolbar_get_entry(priv), string);
317 model = GTK_TREE_MODEL (g_value_get_object(value));
318 hildon_find_toolbar_apply_filter (self, model);
322 gtk_combo_box_entry_set_text_column (priv->entry_combo_box,
323 g_value_get_int (value));
327 gtk_entry_set_max_length (hildon_find_toolbar_get_entry(priv),
328 g_value_get_int (value));
331 case PROP_HISTORY_LIMIT:
332 priv->history_limit = g_value_get_int (value);
334 /* Re-apply the history limit to the model. */
335 model = hildon_find_toolbar_get_list_model (priv);
338 /* Note that refilter function doesn't update the status of the
339 combobox popup arrow, so we'll just recreate the filter. */
340 hildon_find_toolbar_apply_filter (self, model);
342 if (gtk_combo_box_entry_get_text_column (priv->entry_combo_box) == -1)
344 /* FIXME: This is only for backwards compatibility, although
345 probably nothing actually relies on it. The behavior was only
346 an accidental side effect of original code */
347 gtk_combo_box_entry_set_text_column (priv->entry_combo_box, 0);
353 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
359 hildon_find_toolbar_find_string (HildonFindToolbar *self,
364 GtkTreeModel *model = NULL;
366 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
369 model = hildon_find_toolbar_get_list_model (priv);
371 if (gtk_tree_model_get_iter_first (model, iter))
374 gtk_tree_model_get (model, iter, column, &old_string, -1);
375 if (old_string != NULL && strcmp (string, old_string) == 0)
380 } while (gtk_tree_model_iter_next (model, iter));
387 hildon_find_toolbar_history_append (HildonFindToolbar *self,
390 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
395 GtkTreeModel *model = NULL;
396 GtkListStore *list = NULL;
398 gboolean self_create = FALSE;
400 g_object_get (self, "prefix", &string, NULL);
404 /* empty prefix, ignore */
410 /* If list store is set, get it */
411 model = hildon_find_toolbar_get_list_model(priv);
414 list = GTK_LIST_STORE (model);
415 g_object_get(self, "column", &column, NULL);
419 /* Column number is -1 if "column" property hasn't been set but
420 "list" property is. */
425 /* Latest string is always the first one in list. If the string
426 already exists, remove it so there are no duplicates in list. */
427 if (hildon_find_toolbar_find_string (self, &iter, column, string))
428 gtk_list_store_remove (list, &iter);
432 /* No list store set. Create our own. */
433 list = gtk_list_store_new (1, G_TYPE_STRING);
434 model = GTK_TREE_MODEL (list);
438 /* Add the string to first in list */
439 gtk_list_store_append (list, &iter);
440 gtk_list_store_set (list, &iter, column, string, -1);
444 /* Add the created list to ComboBoxEntry */
445 hildon_find_toolbar_apply_filter (self, model);
446 /* ComboBoxEntry keeps the only needed reference to this list */
447 g_object_unref (list);
449 /* Set the column only after ComboBoxEntry's model is set
450 in hildon_find_toolbar_apply_filter() */
451 g_object_set (self, "column", 0, NULL);
455 /* Refilter to get the oldest entry hidden from history */
456 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(
457 gtk_combo_box_get_model (GTK_COMBO_BOX(priv->entry_combo_box))));
466 hildon_find_toolbar_emit_search (GtkButton *button,
471 /* Clicked search button. Perform search and add search prefix to history */
472 g_signal_emit_by_name(self, "search", NULL);
473 g_signal_emit_by_name(self, "history_append", &rb, NULL);
477 hildon_find_toolbar_emit_close (GtkButton *button,
481 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
484 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (priv->entry_combo_box));
485 if (GTK_WIDGET_HAS_FOCUS (entry))
487 hildon_gtk_im_context_hide (GTK_ENTRY (entry)->im_context);
491 /* Clicked close button */
492 g_signal_emit_by_name (self, "close", NULL);
497 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
498 GtkInvalidInputType type,
501 if(type == GTK_INVALID_INPUT_MAX_CHARS_REACHED)
502 g_signal_emit_by_name (self, "invalid_input", NULL);
507 hildon_find_toolbar_entry_activate (GtkWidget *widget,
510 GtkWidget *find_toolbar = GTK_WIDGET (user_data);
513 /* NB#40936 stop focus from moving to next widget */
514 g_signal_stop_emission_by_name (widget, "activate");
516 g_signal_emit_by_name (find_toolbar, "search", NULL);
517 g_signal_emit_by_name (find_toolbar, "history_append", &rb, NULL);
521 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass)
523 GObjectClass *object_class;
525 g_type_class_add_private (klass, sizeof (HildonFindToolbarPrivate));
527 object_class = G_OBJECT_CLASS(klass);
529 object_class->get_property = hildon_find_toolbar_get_property;
530 object_class->set_property = hildon_find_toolbar_set_property;
532 klass->history_append = (gpointer) hildon_find_toolbar_history_append;
535 * HildonFindToolbar:label:
537 * The label to display before the search box.
540 g_object_class_install_property (object_class, PROP_LABEL,
541 g_param_spec_string ("label",
542 "Label", "Displayed name for"
544 _("ecdg_ti_find_toolbar_label"),
549 * HildonFindToolbar:label:
551 * The label to display before the search box.
554 g_object_class_install_property (object_class, PROP_PREFIX,
555 g_param_spec_string ("prefix",
556 "Prefix", "Search string", NULL,
560 * HildonFindToolbar:list:
562 * A #GtkListStore where the search history is kept.
565 g_object_class_install_property (object_class, PROP_LIST,
566 g_param_spec_object ("list",
567 "List"," GtkListStore model where "
568 "history list is kept",
573 * HildonFindToolbar:column:
575 * The column number in GtkListStore where strings of
576 * search history are kept.
579 g_object_class_install_property(object_class, PROP_COLUMN,
580 g_param_spec_int ("column",
581 "Column", "Column number in GtkListStore "
582 "where history list strings are kept",
584 0, G_PARAM_READWRITE));
587 * HildonFindToolbar:label:
589 * The label to display before the search box.
592 g_object_class_install_property (object_class, PROP_MAX,
593 g_param_spec_int ("max_characters",
594 "Maximum number of characters",
595 "Maximum number of characters "
598 0, G_PARAM_READWRITE |
602 * HildonFindToolbar:history-limit:
604 * Maximum number of history items in the combobox.
607 g_object_class_install_property (object_class, PROP_HISTORY_LIMIT,
608 g_param_spec_int ("history-limit",
609 "Maximum number of history items",
610 "Maximum number of history items "
611 "in search combobox",
613 5, G_PARAM_READWRITE |
617 * HildonFindToolbar::search:
618 * @toolbar: the toolbar which received the signal
620 * Gets emitted when the find button is pressed.
622 HildonFindToolbar_signal[SEARCH] =
624 "search", HILDON_TYPE_FIND_TOOLBAR,
625 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
626 (HildonFindToolbarClass, search),
627 NULL, NULL, gtk_marshal_VOID__VOID,
631 * HildonFindToolbar::close:
632 * @toolbar: the toolbar which received the signal
634 * Gets emitted when the close button is pressed.
636 HildonFindToolbar_signal[CLOSE] =
638 "close", HILDON_TYPE_FIND_TOOLBAR,
639 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
640 (HildonFindToolbarClass, close),
641 NULL, NULL, gtk_marshal_VOID__VOID,
645 * HildonFindToolbar::invalid-input:
646 * @toolbar: the toolbar which received the signal
648 * Gets emitted when the maximum search prefix length is reached and
649 * user tries to type more.
651 HildonFindToolbar_signal[INVALID_INPUT] =
653 "invalid_input", HILDON_TYPE_FIND_TOOLBAR,
654 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
655 (HildonFindToolbarClass, invalid_input),
656 NULL, NULL, gtk_marshal_VOID__VOID,
660 * HildonFindToolbar::history-append:
661 * @toolbar: the toolbar which received the signal
663 * Gets emitted when the current search prefix should be added to history.
665 HildonFindToolbar_signal[HISTORY_APPEND] =
667 "history_append", HILDON_TYPE_FIND_TOOLBAR,
668 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
669 (HildonFindToolbarClass, history_append),
670 g_signal_accumulator_true_handled, NULL,
671 gtk_marshal_BOOLEAN__VOID,
676 hildon_find_toolbar_init (HildonFindToolbar *self)
678 GtkToolItem *label_container;
679 GtkToolItem *entry_combo_box_container;
680 GtkAlignment *alignment;
682 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
685 /* Create the label */
686 priv->label = gtk_label_new (_("ecdg_ti_find_toolbar_label"));
688 gtk_misc_set_padding (GTK_MISC (priv->label), FIND_LABEL_XPADDING,
689 FIND_LABEL_YPADDING);
691 label_container = gtk_tool_item_new ();
692 gtk_container_add (GTK_CONTAINER (label_container),
695 gtk_widget_show_all (GTK_WIDGET (label_container));
696 gtk_toolbar_insert (GTK_TOOLBAR (self), label_container, -1);
698 /* ComboBoxEntry for search prefix string / history list */
699 priv->entry_combo_box = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new ());
702 g_signal_connect (hildon_find_toolbar_get_entry(priv),
704 G_CALLBACK(hildon_find_toolbar_emit_invalid_input), self);
707 entry_combo_box_container = gtk_tool_item_new ();
708 alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
710 gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
711 gtk_container_add (GTK_CONTAINER (alignment),
712 GTK_WIDGET (priv->entry_combo_box));
713 gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
714 GTK_WIDGET (alignment));
715 gtk_widget_show_all(GTK_WIDGET (entry_combo_box_container));
716 gtk_toolbar_insert (GTK_TOOLBAR (self), entry_combo_box_container, -1);
717 g_signal_connect (hildon_find_toolbar_get_entry (priv),
719 G_CALLBACK(hildon_find_toolbar_entry_activate), self);
722 priv->find_button = gtk_tool_button_new (
723 gtk_image_new_from_icon_name ("qgn_toolb_browser_gobutton",
724 HILDON_ICON_SIZE_TOOLBAR),
727 g_signal_connect (priv->find_button, "clicked",
728 G_CALLBACK(hildon_find_toolbar_emit_search), self);
729 gtk_widget_show_all( GTK_WIDGET(priv->find_button));
730 gtk_toolbar_insert ( GTK_TOOLBAR(self), priv->find_button, -1);
731 gtk_widget_set_size_request (GTK_WIDGET (priv->find_button), 72, -1);
732 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->find_button)->child) )
733 GTK_WIDGET_UNSET_FLAGS(
734 GTK_BIN(priv->find_button)->child, GTK_CAN_FOCUS);
737 priv->separator = gtk_separator_tool_item_new();
738 gtk_widget_show(GTK_WIDGET(priv->separator));
739 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->separator, -1);
742 priv->close_button = gtk_tool_button_new (
743 gtk_image_new_from_icon_name ("qgn_toolb_gene_close",
744 HILDON_ICON_SIZE_TOOLBAR),
746 gtk_widget_set_size_request (GTK_WIDGET (priv->close_button), 72, -1);
747 g_signal_connect(priv->close_button, "clicked",
748 G_CALLBACK(hildon_find_toolbar_emit_close), self);
749 gtk_widget_show_all(GTK_WIDGET(priv->close_button));
750 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->close_button, -1);
751 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->close_button)->child) )
752 GTK_WIDGET_UNSET_FLAGS(
753 GTK_BIN(priv->close_button)->child, GTK_CAN_FOCUS);
757 * hildon_find_toolbar_new:
758 * @label: label for the find_toolbar, NULL to set the label to
761 * Creates a new HildonFindToolbar.
763 * Returns: a new HildonFindToolbar
766 hildon_find_toolbar_new (const gchar *label)
768 GtkWidget *findtoolbar;
770 findtoolbar = GTK_WIDGET (g_object_new (HILDON_TYPE_FIND_TOOLBAR, NULL));
773 g_object_set(findtoolbar, "label", label, NULL);
779 * hildon_find_toolbar_new_with_model:
780 * @label: label for the find_toolbar, NULL to set the label to
782 * @model: a @GtkListStore
783 * @column: indicating which column the search histry list will
784 * retreive string from
786 * Creates a new HildonFindToolbar with a model.
788 * Returns: a new #HildonFindToolbar
791 hildon_find_toolbar_new_with_model (const gchar *label,
795 GtkWidget *findtoolbar;
797 findtoolbar = hildon_find_toolbar_new (label);
799 g_object_set (findtoolbar, "list", model, "column", column, NULL);
805 * hildon_find_toolbar_highlight_entry:
806 * @ftb: find Toolbar whose entry is to be highlighted
807 * @get_focus: if user passes TRUE to this value, then the text in
808 * the entry will not only get highlighted, but also get focused.
810 * Highlights the current entry in the find toolbar.
814 hildon_find_toolbar_highlight_entry (HildonFindToolbar *self,
817 GtkEntry *entry = NULL;
818 HildonFindToolbarPrivate *priv;
820 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (self));
821 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
824 entry = hildon_find_toolbar_get_entry (priv);
826 gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
829 gtk_widget_grab_focus (GTK_WIDGET (entry));
833 * hildon_find_toolbar_set_active:
834 * @toolbar: A find toolbar to operate on
835 * @index: An index in the model passed during construction, or -1 to have no active item
837 * Sets the active item on the toolbar's combo-box. Simply calls gtk_combo_box_set_active on
838 * the HildonFindToolbar's combo.
842 hildon_find_toolbar_set_active (HildonFindToolbar *toolbar,
845 HildonFindToolbarPrivate *priv;
847 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
848 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
850 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->entry_combo_box), index);
854 * hildon_find_toolbar_get_active:
855 * @toolbar: A find toolbar to query
857 * Gets the index of the currently active item, or -1 if there's no active item. Simply
858 * calls gtk_combo_box_get_active on the HildonFindToolbar's combo.
860 * Returns: An integer which is the index of the currently active item, or -1 if there's no active item.
864 hildon_find_toolbar_get_active (HildonFindToolbar *toolbar)
866 HildonFindToolbarPrivate *priv;
868 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), -1);
869 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
871 return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->entry_combo_box));
875 * hildon_find_toolbar_set_active_iter:
876 * @toolbar: A find toolbar to operate on
877 * @iter: An iter to make active
879 * Sets the current active item to be the one referenced by iter. Simply calls
880 * gtk_combo_box_set_active_iter on the HildonFindToolbar's combo.
884 hildon_find_toolbar_set_active_iter (HildonFindToolbar *toolbar,
887 HildonFindToolbarPrivate *priv;
889 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
890 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
892 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
896 * hildon_find_toolbar_get_active_iter:
897 * @toolbar: A find toolbar to query
898 * @iter: The uninitialized GtkTreeIter
900 * Sets iter to point to the current active item, if it exists. Simply calls
901 * gtk_combo_box_get_active_iter on the HildonFindToolbar's combo.
903 * Returns: TRUE, if iter was set
907 hildon_find_toolbar_get_active_iter (HildonFindToolbar *toolbar,
910 HildonFindToolbarPrivate *priv;
912 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
913 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
915 return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
919 * hildon_find_toolbar_get_last_index
920 * @toolbar: A find toolbar to query
922 * Returns the index of the last (most recently added) item in the toolbar.
923 * Can be used to set this item active in the history-append signal.
926 * Returns: Index of the last entry
930 hildon_find_toolbar_get_last_index (HildonFindToolbar *toolbar)
932 HildonFindToolbarPrivate *priv;
933 GtkTreeModel *filter_model;
935 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
936 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
938 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
940 if (filter_model == NULL)
946 gtk_tree_model_get_iter_first (filter_model, &iter);
948 while (gtk_tree_model_iter_next (filter_model, &iter))