2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Rodrigo Novo <rodrigo.novo@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"
48 #include "hildon-marshalers.h"
51 dgettext("hildon-libs", String)
53 /* Same define as gtkentry.c as entry will further handle this */
55 #define MAX_SIZE G_MAXUSHORT
57 #define FIND_LABEL_XPADDING 6
59 #define FIND_LABEL_YPADDING 0
62 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv);
65 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv);
68 hildon_find_toolbar_filter (GtkTreeModel *model,
73 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
77 hildon_find_toolbar_get_property (GObject *object,
83 hildon_find_toolbar_set_property (GObject *object,
89 hildon_find_toolbar_find_string (HildonFindToolbar *self,
95 hildon_find_toolbar_history_append (HildonFindToolbar *self,
99 hildon_find_toolbar_emit_search (GtkButton *button,
103 hildon_find_toolbar_emit_close (GtkButton *button,
108 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
109 GtkInvalidInputType type,
114 hildon_find_toolbar_entry_activate (GtkWidget *widget,
118 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass);
121 hildon_find_toolbar_init (HildonFindToolbar *self);
144 static guint HildonFindToolbar_signal [LAST_SIGNAL] = {0};
147 * hildon_find_toolbar_get_type:
149 * Initializes and returns the type of a hildon fond toolbar.
151 * Returns: GType of #HildonFindToolbar
154 hildon_find_toolbar_get_type (void)
156 static GType find_toolbar_type = 0;
158 if (! find_toolbar_type) {
159 static const GTypeInfo find_toolbar_info = {
160 sizeof(HildonFindToolbarClass),
161 NULL, /* base_init */
162 NULL, /* base_finalize */
163 (GClassInitFunc) hildon_find_toolbar_class_init,
164 NULL, /* class_finalize */
165 NULL, /* class_data */
166 sizeof(HildonFindToolbar),
168 (GInstanceInitFunc) hildon_find_toolbar_init,
170 find_toolbar_type = g_type_register_static (GTK_TYPE_TOOLBAR,
172 &find_toolbar_info, 0);
175 return find_toolbar_type;
179 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv)
181 GtkTreeModel *filter_model =
182 gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
184 return filter_model == NULL ? NULL :
185 gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
189 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv)
191 return GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->entry_combo_box)));
195 hildon_find_toolbar_filter (GtkTreeModel *model,
205 total = gtk_tree_model_iter_n_children (model, NULL);
206 g_object_get (self, "history_limit", &limit, NULL);
207 path = gtk_tree_model_get_path (model, iter);
208 indices = gtk_tree_path_get_indices (path);
210 /* set the row's index, list store has only one level */
212 gtk_tree_path_free (path);
214 /*if the row is among the latest "history_limit" additions of the
215 * model, then we show it */
216 if( (total - limit <= n) && (n < total) )
223 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
226 GtkTreeModel *filter;
227 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
230 /* Create a filter for the given model. Its only purpose is to hide
231 the oldest entries so only "history_limit" entries are visible. */
232 filter = gtk_tree_model_filter_new (model, NULL);
234 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(filter),
235 hildon_find_toolbar_filter,
238 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->entry_combo_box), filter);
240 /* ComboBox keeps the only needed reference to the filter */
241 g_object_unref (filter);
245 hildon_find_toolbar_get_property (GObject *object,
250 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
259 string = gtk_label_get_text (GTK_LABEL (priv->label));
260 g_value_set_string (value, string);
264 string = gtk_entry_get_text (hildon_find_toolbar_get_entry(priv));
265 g_value_set_string (value, string);
269 g_value_set_object (value, hildon_find_toolbar_get_list_model(priv));
273 c_n = gtk_combo_box_entry_get_text_column (priv->entry_combo_box);
274 g_value_set_int (value, c_n);
278 max_len = gtk_entry_get_max_length (hildon_find_toolbar_get_entry(priv));
279 g_value_set_int (value, max_len);
282 case PROP_HISTORY_LIMIT:
283 g_value_set_int (value, priv->history_limit);
287 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
293 hildon_find_toolbar_set_property (GObject *object,
298 HildonFindToolbar *self = HILDON_FIND_TOOLBAR(object);
299 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
308 string = g_value_get_string (value);
309 gtk_label_set_text (GTK_LABEL (priv->label), string);
313 string = g_value_get_string (value);
314 gtk_entry_set_text (hildon_find_toolbar_get_entry(priv), string);
318 model = GTK_TREE_MODEL (g_value_get_object(value));
319 hildon_find_toolbar_apply_filter (self, model);
323 gtk_combo_box_entry_set_text_column (priv->entry_combo_box,
324 g_value_get_int (value));
328 gtk_entry_set_max_length (hildon_find_toolbar_get_entry(priv),
329 g_value_get_int (value));
332 case PROP_HISTORY_LIMIT:
333 priv->history_limit = g_value_get_int (value);
335 /* Re-apply the history limit to the model. */
336 model = hildon_find_toolbar_get_list_model (priv);
339 /* Note that refilter function doesn't update the status of the
340 combobox popup arrow, so we'll just recreate the filter. */
341 hildon_find_toolbar_apply_filter (self, model);
343 if (gtk_combo_box_entry_get_text_column (priv->entry_combo_box) == -1)
345 /* FIXME: This is only for backwards compatibility, although
346 probably nothing actually relies on it. The behavior was only
347 an accidental side effect of original code */
348 gtk_combo_box_entry_set_text_column (priv->entry_combo_box, 0);
354 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
360 hildon_find_toolbar_find_string (HildonFindToolbar *self,
365 GtkTreeModel *model = NULL;
367 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
370 model = hildon_find_toolbar_get_list_model (priv);
372 if (gtk_tree_model_get_iter_first (model, iter))
375 gtk_tree_model_get (model, iter, column, &old_string, -1);
376 if (old_string != NULL && strcmp (string, old_string) == 0)
381 } while (gtk_tree_model_iter_next (model, iter));
388 hildon_find_toolbar_history_append (HildonFindToolbar *self,
391 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
396 GtkTreeModel *model = NULL;
397 GtkListStore *list = NULL;
399 gboolean self_create = FALSE;
401 g_object_get (self, "prefix", &string, NULL);
405 /* empty prefix, ignore */
411 /* If list store is set, get it */
412 model = hildon_find_toolbar_get_list_model(priv);
415 list = GTK_LIST_STORE (model);
416 g_object_get(self, "column", &column, NULL);
420 /* Column number is -1 if "column" property hasn't been set but
421 "list" property is. */
426 /* Latest string is always the first one in list. If the string
427 already exists, remove it so there are no duplicates in list. */
428 if (hildon_find_toolbar_find_string (self, &iter, column, string))
429 gtk_list_store_remove (list, &iter);
433 /* No list store set. Create our own. */
434 list = gtk_list_store_new (1, G_TYPE_STRING);
435 model = GTK_TREE_MODEL (list);
439 /* Add the string to first in list */
440 gtk_list_store_append (list, &iter);
441 gtk_list_store_set (list, &iter, column, string, -1);
445 /* Add the created list to ComboBoxEntry */
446 hildon_find_toolbar_apply_filter (self, model);
447 /* ComboBoxEntry keeps the only needed reference to this list */
448 g_object_unref (list);
450 /* Set the column only after ComboBoxEntry's model is set
451 in hildon_find_toolbar_apply_filter() */
452 g_object_set (self, "column", 0, NULL);
456 /* Refilter to get the oldest entry hidden from history */
457 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(
458 gtk_combo_box_get_model (GTK_COMBO_BOX(priv->entry_combo_box))));
467 hildon_find_toolbar_emit_search (GtkButton *button,
472 /* Clicked search button. Perform search and add search prefix to history */
473 g_signal_emit_by_name(self, "search", NULL);
474 g_signal_emit_by_name(self, "history_append", &rb, NULL);
478 hildon_find_toolbar_emit_close (GtkButton *button,
482 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
485 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (priv->entry_combo_box));
486 if (GTK_WIDGET_HAS_FOCUS (entry))
488 hildon_gtk_im_context_hide (GTK_ENTRY (entry)->im_context);
492 /* Clicked close button */
493 g_signal_emit_by_name (self, "close", NULL);
498 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
499 GtkInvalidInputType type,
502 if(type == GTK_INVALID_INPUT_MAX_CHARS_REACHED)
503 g_signal_emit_by_name (self, "invalid_input", NULL);
508 hildon_find_toolbar_entry_activate (GtkWidget *widget,
511 GtkWidget *find_toolbar = GTK_WIDGET (user_data);
514 /* NB#40936 stop focus from moving to next widget */
515 g_signal_stop_emission_by_name (widget, "activate");
517 g_signal_emit_by_name (find_toolbar, "search", NULL);
518 g_signal_emit_by_name (find_toolbar, "history_append", &rb, NULL);
522 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass)
524 GObjectClass *object_class;
526 g_type_class_add_private (klass, sizeof (HildonFindToolbarPrivate));
528 object_class = G_OBJECT_CLASS(klass);
530 object_class->get_property = hildon_find_toolbar_get_property;
531 object_class->set_property = hildon_find_toolbar_set_property;
533 klass->history_append = (gpointer) hildon_find_toolbar_history_append;
536 * HildonFindToolbar:label:
538 * The label to display before the search box.
541 g_object_class_install_property (object_class, PROP_LABEL,
542 g_param_spec_string ("label",
543 "Label", "Displayed name for"
545 _("ecdg_ti_find_toolbar_label"),
550 * HildonFindToolbar:label:
552 * The label to display before the search box.
555 g_object_class_install_property (object_class, PROP_PREFIX,
556 g_param_spec_string ("prefix",
557 "Prefix", "Search string", NULL,
561 * HildonFindToolbar:list:
563 * A #GtkListStore where the search history is kept.
566 g_object_class_install_property (object_class, PROP_LIST,
567 g_param_spec_object ("list",
568 "List"," GtkListStore model where "
569 "history list is kept",
574 * HildonFindToolbar:column:
576 * The column number in GtkListStore where strings of
577 * search history are kept.
580 g_object_class_install_property(object_class, PROP_COLUMN,
581 g_param_spec_int ("column",
582 "Column", "Column number in GtkListStore "
583 "where history list strings are kept",
585 0, G_PARAM_READWRITE));
588 * HildonFindToolbar:label:
590 * The label to display before the search box.
593 g_object_class_install_property (object_class, PROP_MAX,
594 g_param_spec_int ("max_characters",
595 "Maximum number of characters",
596 "Maximum number of characters "
599 0, G_PARAM_READWRITE |
603 * HildonFindToolbar:history-limit:
605 * Maximum number of history items in the combobox.
608 g_object_class_install_property (object_class, PROP_HISTORY_LIMIT,
609 g_param_spec_int ("history-limit",
610 "Maximum number of history items",
611 "Maximum number of history items "
612 "in search combobox",
614 5, G_PARAM_READWRITE |
618 * HildonFindToolbar::search:
619 * @toolbar: the toolbar which received the signal
621 * Gets emitted when the find button is pressed.
623 HildonFindToolbar_signal[SEARCH] =
625 "search", HILDON_TYPE_FIND_TOOLBAR,
626 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
627 (HildonFindToolbarClass, search),
628 NULL, NULL, g_cclosure_marshal_VOID__VOID,
632 * HildonFindToolbar::close:
633 * @toolbar: the toolbar which received the signal
635 * Gets emitted when the close button is pressed.
637 HildonFindToolbar_signal[CLOSE] =
639 "close", HILDON_TYPE_FIND_TOOLBAR,
640 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
641 (HildonFindToolbarClass, close),
642 NULL, NULL, g_cclosure_marshal_VOID__VOID,
646 * HildonFindToolbar::invalid-input:
647 * @toolbar: the toolbar which received the signal
649 * Gets emitted when the maximum search prefix length is reached and
650 * user tries to type more.
652 HildonFindToolbar_signal[INVALID_INPUT] =
654 "invalid_input", HILDON_TYPE_FIND_TOOLBAR,
655 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
656 (HildonFindToolbarClass, invalid_input),
657 NULL, NULL, g_cclosure_marshal_VOID__VOID,
661 * HildonFindToolbar::history-append:
662 * @toolbar: the toolbar which received the signal
664 * Gets emitted when the current search prefix should be added to history.
666 HildonFindToolbar_signal[HISTORY_APPEND] =
668 "history_append", HILDON_TYPE_FIND_TOOLBAR,
669 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
670 (HildonFindToolbarClass, history_append),
671 g_signal_accumulator_true_handled, NULL,
672 _hildon_marshal_BOOLEAN__VOID,
677 hildon_find_toolbar_init (HildonFindToolbar *self)
679 GtkToolItem *label_container;
680 GtkToolItem *entry_combo_box_container;
681 GtkAlignment *alignment;
683 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
686 /* Create the label */
687 priv->label = gtk_label_new (_("ecdg_ti_find_toolbar_label"));
689 gtk_misc_set_padding (GTK_MISC (priv->label), FIND_LABEL_XPADDING,
690 FIND_LABEL_YPADDING);
692 label_container = gtk_tool_item_new ();
693 gtk_container_add (GTK_CONTAINER (label_container),
696 gtk_widget_show_all (GTK_WIDGET (label_container));
697 gtk_toolbar_insert (GTK_TOOLBAR (self), label_container, -1);
699 /* ComboBoxEntry for search prefix string / history list */
700 priv->entry_combo_box = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new ());
703 g_signal_connect (hildon_find_toolbar_get_entry(priv),
705 G_CALLBACK(hildon_find_toolbar_emit_invalid_input), self);
708 entry_combo_box_container = gtk_tool_item_new ();
709 alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
711 gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
712 gtk_container_add (GTK_CONTAINER (alignment),
713 GTK_WIDGET (priv->entry_combo_box));
714 gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
715 GTK_WIDGET (alignment));
716 gtk_widget_show_all(GTK_WIDGET (entry_combo_box_container));
717 gtk_toolbar_insert (GTK_TOOLBAR (self), entry_combo_box_container, -1);
718 g_signal_connect (hildon_find_toolbar_get_entry (priv),
720 G_CALLBACK(hildon_find_toolbar_entry_activate), self);
723 priv->find_button = gtk_tool_button_new (
724 gtk_image_new_from_icon_name ("qgn_toolb_browser_gobutton",
725 HILDON_ICON_SIZE_TOOLBAR),
728 g_signal_connect (priv->find_button, "clicked",
729 G_CALLBACK(hildon_find_toolbar_emit_search), self);
730 gtk_widget_show_all( GTK_WIDGET(priv->find_button));
731 gtk_toolbar_insert ( GTK_TOOLBAR(self), priv->find_button, -1);
732 gtk_widget_set_size_request (GTK_WIDGET (priv->find_button), 72, -1);
733 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->find_button)->child) )
734 GTK_WIDGET_UNSET_FLAGS(
735 GTK_BIN(priv->find_button)->child, GTK_CAN_FOCUS);
738 priv->separator = gtk_separator_tool_item_new();
739 gtk_widget_show(GTK_WIDGET(priv->separator));
740 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->separator, -1);
743 priv->close_button = gtk_tool_button_new (
744 gtk_image_new_from_icon_name ("qgn_toolb_gene_close",
745 HILDON_ICON_SIZE_TOOLBAR),
747 gtk_widget_set_size_request (GTK_WIDGET (priv->close_button), 72, -1);
748 g_signal_connect(priv->close_button, "clicked",
749 G_CALLBACK(hildon_find_toolbar_emit_close), self);
750 gtk_widget_show_all(GTK_WIDGET(priv->close_button));
751 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->close_button, -1);
752 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->close_button)->child) )
753 GTK_WIDGET_UNSET_FLAGS(
754 GTK_BIN(priv->close_button)->child, GTK_CAN_FOCUS);
758 * hildon_find_toolbar_new:
759 * @label: label for the find_toolbar, NULL to set the label to
762 * Creates a new HildonFindToolbar.
764 * Returns: a new HildonFindToolbar
767 hildon_find_toolbar_new (const gchar *label)
769 GtkWidget *findtoolbar;
771 findtoolbar = GTK_WIDGET (g_object_new (HILDON_TYPE_FIND_TOOLBAR, NULL));
774 g_object_set(findtoolbar, "label", label, NULL);
780 * hildon_find_toolbar_new_with_model:
781 * @label: label for the find_toolbar, NULL to set the label to
783 * @model: a @GtkListStore
784 * @column: indicating which column the search histry list will
785 * retreive string from
787 * Creates a new HildonFindToolbar with a model.
789 * Returns: a new #HildonFindToolbar
792 hildon_find_toolbar_new_with_model (const gchar *label,
796 GtkWidget *findtoolbar;
798 findtoolbar = hildon_find_toolbar_new (label);
800 g_object_set (findtoolbar, "list", model, "column", column, NULL);
806 * hildon_find_toolbar_highlight_entry:
807 * @ftb: find Toolbar whose entry is to be highlighted
808 * @get_focus: if user passes TRUE to this value, then the text in
809 * the entry will not only get highlighted, but also get focused.
811 * Highlights the current entry in the find toolbar.
815 hildon_find_toolbar_highlight_entry (HildonFindToolbar *self,
818 GtkEntry *entry = NULL;
819 HildonFindToolbarPrivate *priv;
821 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (self));
822 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
825 entry = hildon_find_toolbar_get_entry (priv);
827 gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
830 gtk_widget_grab_focus (GTK_WIDGET (entry));
834 * hildon_find_toolbar_set_active:
835 * @toolbar: A find toolbar to operate on
836 * @index: An index in the model passed during construction, or -1 to have no active item
838 * Sets the active item on the toolbar's combo-box. Simply calls gtk_combo_box_set_active on
839 * the HildonFindToolbar's combo.
843 hildon_find_toolbar_set_active (HildonFindToolbar *toolbar,
846 HildonFindToolbarPrivate *priv;
848 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
849 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
851 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->entry_combo_box), index);
855 * hildon_find_toolbar_get_active:
856 * @toolbar: A find toolbar to query
858 * Gets the index of the currently active item, or -1 if there's no active item. Simply
859 * calls gtk_combo_box_get_active on the HildonFindToolbar's combo.
861 * Returns: An integer which is the index of the currently active item, or -1 if there's no active item.
865 hildon_find_toolbar_get_active (HildonFindToolbar *toolbar)
867 HildonFindToolbarPrivate *priv;
869 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), -1);
870 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
872 return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->entry_combo_box));
876 * hildon_find_toolbar_set_active_iter:
877 * @toolbar: A find toolbar to operate on
878 * @iter: An iter to make active
880 * Sets the current active item to be the one referenced by iter. Simply calls
881 * gtk_combo_box_set_active_iter on the HildonFindToolbar's combo.
885 hildon_find_toolbar_set_active_iter (HildonFindToolbar *toolbar,
888 HildonFindToolbarPrivate *priv;
890 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
891 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
893 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
897 * hildon_find_toolbar_get_active_iter:
898 * @toolbar: A find toolbar to query
899 * @iter: The uninitialized GtkTreeIter
901 * Sets iter to point to the current active item, if it exists. Simply calls
902 * gtk_combo_box_get_active_iter on the HildonFindToolbar's combo.
904 * Returns: TRUE, if iter was set
908 hildon_find_toolbar_get_active_iter (HildonFindToolbar *toolbar,
911 HildonFindToolbarPrivate *priv;
913 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
914 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
916 return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
920 * hildon_find_toolbar_get_last_index
921 * @toolbar: A find toolbar to query
923 * Returns the index of the last (most recently added) item in the toolbar.
924 * Can be used to set this item active in the history-append signal.
927 * Returns: Index of the last entry
931 hildon_find_toolbar_get_last_index (HildonFindToolbar *toolbar)
933 HildonFindToolbarPrivate *priv;
934 GtkTreeModel *filter_model;
936 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
937 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
939 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
941 if (filter_model == NULL)
947 gtk_tree_model_get_iter_first (filter_model, &iter);
949 while (gtk_tree_model_iter_next (filter_model, &iter))