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_close (GtkButton *button,
104 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
105 GtkInvalidInputType type,
110 hildon_find_toolbar_entry_activate (GtkWidget *widget,
114 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass);
117 hildon_find_toolbar_init (HildonFindToolbar *self);
140 static guint HildonFindToolbar_signal [LAST_SIGNAL] = {0};
143 * hildon_find_toolbar_get_type:
145 * Initializes and returns the type of a #HildonFindToolbar.
147 * Returns: GType of #HildonFindToolbar
150 hildon_find_toolbar_get_type (void)
152 static GType find_toolbar_type = 0;
154 if (! find_toolbar_type) {
155 static const GTypeInfo find_toolbar_info = {
156 sizeof(HildonFindToolbarClass),
157 NULL, /* base_init */
158 NULL, /* base_finalize */
159 (GClassInitFunc) hildon_find_toolbar_class_init,
160 NULL, /* class_finalize */
161 NULL, /* class_data */
162 sizeof(HildonFindToolbar),
164 (GInstanceInitFunc) hildon_find_toolbar_init,
166 find_toolbar_type = g_type_register_static (GTK_TYPE_TOOLBAR,
168 &find_toolbar_info, 0);
171 return find_toolbar_type;
175 hildon_find_toolbar_get_list_model (HildonFindToolbarPrivate *priv)
177 GtkTreeModel *filter_model =
178 gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
180 return filter_model == NULL ? NULL :
181 gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
185 hildon_find_toolbar_get_entry (HildonFindToolbarPrivate *priv)
187 return GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->entry_combo_box)));
191 hildon_find_toolbar_filter (GtkTreeModel *model,
201 total = gtk_tree_model_iter_n_children (model, NULL);
202 g_object_get (self, "history_limit", &limit, NULL);
203 path = gtk_tree_model_get_path (model, iter);
204 indices = gtk_tree_path_get_indices (path);
206 /* set the row's index, list store has only one level */
208 gtk_tree_path_free (path);
210 /*if the row is among the latest "history_limit" additions of the
211 * model, then we show it */
212 if( (total - limit <= n) && (n < total) )
219 hildon_find_toolbar_apply_filter (HildonFindToolbar *self,
222 GtkTreeModel *filter;
223 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
226 /* Create a filter for the given model. Its only purpose is to hide
227 the oldest entries so only "history_limit" entries are visible. */
228 filter = gtk_tree_model_filter_new (model, NULL);
230 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(filter),
231 hildon_find_toolbar_filter,
234 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->entry_combo_box), filter);
236 /* ComboBox keeps the only needed reference to the filter */
237 g_object_unref (filter);
241 hildon_find_toolbar_get_property (GObject *object,
246 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
255 string = gtk_label_get_text (GTK_LABEL (priv->label));
256 g_value_set_string (value, string);
260 string = gtk_entry_get_text (hildon_find_toolbar_get_entry(priv));
261 g_value_set_string (value, string);
265 g_value_set_object (value, hildon_find_toolbar_get_list_model(priv));
269 c_n = gtk_combo_box_entry_get_text_column (priv->entry_combo_box);
270 g_value_set_int (value, c_n);
274 max_len = gtk_entry_get_max_length (hildon_find_toolbar_get_entry(priv));
275 g_value_set_int (value, max_len);
278 case PROP_HISTORY_LIMIT:
279 g_value_set_int (value, priv->history_limit);
283 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
289 hildon_find_toolbar_set_property (GObject *object,
294 HildonFindToolbar *self = HILDON_FIND_TOOLBAR(object);
295 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object);
304 string = g_value_get_string (value);
305 gtk_label_set_text (GTK_LABEL (priv->label), string);
309 string = g_value_get_string (value);
310 gtk_entry_set_text (hildon_find_toolbar_get_entry(priv), string);
314 model = GTK_TREE_MODEL (g_value_get_object(value));
315 hildon_find_toolbar_apply_filter (self, model);
319 gtk_combo_box_entry_set_text_column (priv->entry_combo_box,
320 g_value_get_int (value));
324 gtk_entry_set_max_length (hildon_find_toolbar_get_entry(priv),
325 g_value_get_int (value));
328 case PROP_HISTORY_LIMIT:
329 priv->history_limit = g_value_get_int (value);
331 /* Re-apply the history limit to the model. */
332 model = hildon_find_toolbar_get_list_model (priv);
335 /* Note that refilter function doesn't update the status of the
336 combobox popup arrow, so we'll just recreate the filter. */
337 hildon_find_toolbar_apply_filter (self, model);
339 if (gtk_combo_box_entry_get_text_column (priv->entry_combo_box) == -1)
341 /* FIXME: This is only for backwards compatibility, although
342 probably nothing actually relies on it. The behavior was only
343 an accidental side effect of original code */
344 gtk_combo_box_entry_set_text_column (priv->entry_combo_box, 0);
350 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
356 hildon_find_toolbar_find_string (HildonFindToolbar *self,
361 GtkTreeModel *model = NULL;
363 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
366 model = hildon_find_toolbar_get_list_model (priv);
368 if (gtk_tree_model_get_iter_first (model, iter))
371 gtk_tree_model_get (model, iter, column, &old_string, -1);
372 if (old_string != NULL && strcmp (string, old_string) == 0)
377 } while (gtk_tree_model_iter_next (model, iter));
384 hildon_find_toolbar_history_append (HildonFindToolbar *self,
387 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
392 GtkTreeModel *model = NULL;
393 GtkListStore *list = NULL;
395 gboolean self_create = FALSE;
397 g_object_get (self, "prefix", &string, NULL);
401 /* empty prefix, ignore */
407 /* If list store is set, get it */
408 model = hildon_find_toolbar_get_list_model(priv);
411 list = GTK_LIST_STORE (model);
412 g_object_get(self, "column", &column, NULL);
416 /* Column number is -1 if "column" property hasn't been set but
417 "list" property is. */
422 /* Latest string is always the first one in list. If the string
423 already exists, remove it so there are no duplicates in list. */
424 if (hildon_find_toolbar_find_string (self, &iter, column, string))
425 gtk_list_store_remove (list, &iter);
429 /* No list store set. Create our own. */
430 list = gtk_list_store_new (1, G_TYPE_STRING);
431 model = GTK_TREE_MODEL (list);
435 /* Add the string to first in list */
436 gtk_list_store_append (list, &iter);
437 gtk_list_store_set (list, &iter, column, string, -1);
441 /* Add the created list to ComboBoxEntry */
442 hildon_find_toolbar_apply_filter (self, model);
443 /* ComboBoxEntry keeps the only needed reference to this list */
444 g_object_unref (list);
446 /* Set the column only after ComboBoxEntry's model is set
447 in hildon_find_toolbar_apply_filter() */
448 g_object_set (self, "column", 0, NULL);
452 /* Refilter to get the oldest entry hidden from history */
453 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(
454 gtk_combo_box_get_model (GTK_COMBO_BOX(priv->entry_combo_box))));
463 hildon_find_toolbar_emit_close (GtkButton *button,
467 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
470 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (priv->entry_combo_box));
471 if (GTK_WIDGET_HAS_FOCUS (entry))
473 hildon_gtk_im_context_hide (GTK_ENTRY (entry)->im_context);
477 /* Clicked close button */
478 g_signal_emit (self, HildonFindToolbar_signal [CLOSE], 0);
483 hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
484 GtkInvalidInputType type,
487 if(type == GTK_INVALID_INPUT_MAX_CHARS_REACHED)
488 g_signal_emit (self, HildonFindToolbar_signal [INVALID_INPUT], 0);
493 hildon_find_toolbar_entry_activate (GtkWidget *widget,
496 GtkWidget *find_toolbar = GTK_WIDGET (user_data);
499 /* NB#40936 stop focus from moving to next widget */
500 g_signal_stop_emission_by_name (widget, "activate");
502 g_signal_emit (find_toolbar, HildonFindToolbar_signal [SEARCH], 0);
503 g_signal_emit (find_toolbar, HildonFindToolbar_signal [HISTORY_APPEND], 0, &rb);
507 hildon_find_toolbar_class_init (HildonFindToolbarClass *klass)
509 GObjectClass *object_class;
511 g_type_class_add_private (klass, sizeof (HildonFindToolbarPrivate));
513 object_class = G_OBJECT_CLASS(klass);
515 object_class->get_property = hildon_find_toolbar_get_property;
516 object_class->set_property = hildon_find_toolbar_set_property;
518 klass->history_append = (gpointer) hildon_find_toolbar_history_append;
521 * HildonFindToolbar:label:
523 * The label to display before the search box.
526 g_object_class_install_property (object_class, PROP_LABEL,
527 g_param_spec_string ("label",
528 "Label", "Displayed name for"
530 _("ecdg_ti_find_toolbar_label"),
535 * HildonFindToolbar:prefix:
540 g_object_class_install_property (object_class, PROP_PREFIX,
541 g_param_spec_string ("prefix",
542 "Prefix", "Search string", NULL,
546 * HildonFindToolbar:list:
548 * A #GtkListStore where the search history is kept.
551 g_object_class_install_property (object_class, PROP_LIST,
552 g_param_spec_object ("list",
553 "List"," GtkListStore model where "
554 "history list is kept",
559 * HildonFindToolbar:column:
561 * The column number in GtkListStore where strings of
562 * search history are kept.
565 g_object_class_install_property(object_class, PROP_COLUMN,
566 g_param_spec_int ("column",
567 "Column", "Column number in GtkListStore "
568 "where history list strings are kept",
570 0, G_PARAM_READWRITE));
573 * HildonFindToolbar:max-characters:
575 * Maximum number of characters in search string.
578 g_object_class_install_property (object_class, PROP_MAX,
579 g_param_spec_int ("max_characters",
580 "Maximum number of characters",
581 "Maximum number of characters "
584 0, G_PARAM_READWRITE |
588 * HildonFindToolbar:history-limit:
590 * Maximum number of history items in the combobox.
593 g_object_class_install_property (object_class, PROP_HISTORY_LIMIT,
594 g_param_spec_int ("history-limit",
595 "Maximum number of history items",
596 "Maximum number of history items "
597 "in search combobox",
599 5, G_PARAM_READWRITE |
603 * HildonFindToolbar::search:
604 * @toolbar: the toolbar which received the signal
606 * Gets emitted when the find button is pressed.
608 HildonFindToolbar_signal[SEARCH] =
610 "search", HILDON_TYPE_FIND_TOOLBAR,
611 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
612 (HildonFindToolbarClass, search),
613 NULL, NULL, g_cclosure_marshal_VOID__VOID,
617 * HildonFindToolbar::close:
618 * @toolbar: the toolbar which received the signal
620 * Gets emitted when the close button is pressed.
622 HildonFindToolbar_signal[CLOSE] =
624 "close", HILDON_TYPE_FIND_TOOLBAR,
625 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
626 (HildonFindToolbarClass, close),
627 NULL, NULL, g_cclosure_marshal_VOID__VOID,
631 * HildonFindToolbar::invalid-input:
632 * @toolbar: the toolbar which received the signal
634 * Gets emitted when the maximum search prefix length is reached and
635 * user tries to type more.
637 HildonFindToolbar_signal[INVALID_INPUT] =
639 "invalid_input", HILDON_TYPE_FIND_TOOLBAR,
640 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
641 (HildonFindToolbarClass, invalid_input),
642 NULL, NULL, g_cclosure_marshal_VOID__VOID,
646 * HildonFindToolbar::history-append:
647 * @toolbar: the toolbar which received the signal
649 * Gets emitted when the current search prefix should be added to history.
651 HildonFindToolbar_signal[HISTORY_APPEND] =
653 "history_append", HILDON_TYPE_FIND_TOOLBAR,
654 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
655 (HildonFindToolbarClass, history_append),
656 g_signal_accumulator_true_handled, NULL,
657 _hildon_marshal_BOOLEAN__VOID,
662 hildon_find_toolbar_init (HildonFindToolbar *self)
664 GtkToolItem *label_container;
665 GtkToolItem *entry_combo_box_container;
666 GtkAlignment *alignment;
668 HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
671 /* Create the label */
672 priv->label = gtk_label_new (_("ecdg_ti_find_toolbar_label"));
674 gtk_misc_set_padding (GTK_MISC (priv->label), FIND_LABEL_XPADDING,
675 FIND_LABEL_YPADDING);
677 label_container = gtk_tool_item_new ();
678 gtk_container_add (GTK_CONTAINER (label_container),
681 gtk_widget_show_all (GTK_WIDGET (label_container));
682 gtk_toolbar_insert (GTK_TOOLBAR (self), label_container, -1);
684 /* ComboBoxEntry for search prefix string / history list */
685 priv->entry_combo_box = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new ());
688 g_signal_connect (hildon_find_toolbar_get_entry(priv),
690 G_CALLBACK(hildon_find_toolbar_emit_invalid_input), self);
693 entry_combo_box_container = gtk_tool_item_new ();
694 alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
696 gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
697 gtk_container_add (GTK_CONTAINER (alignment),
698 GTK_WIDGET (priv->entry_combo_box));
699 gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
700 GTK_WIDGET (alignment));
701 gtk_widget_show_all(GTK_WIDGET (entry_combo_box_container));
702 gtk_toolbar_insert (GTK_TOOLBAR (self), entry_combo_box_container, -1);
703 g_signal_connect (hildon_find_toolbar_get_entry (priv),
705 G_CALLBACK(hildon_find_toolbar_entry_activate), self);
708 priv->separator = gtk_separator_tool_item_new();
709 gtk_widget_set_size_request (GTK_WIDGET (priv->separator), 72, -1);
710 gtk_widget_show(GTK_WIDGET(priv->separator));
711 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->separator, -1);
714 priv->close_button = gtk_tool_button_new (
715 gtk_image_new_from_icon_name ("general_close",
716 HILDON_ICON_PIXEL_SIZE_FINGER),
718 g_signal_connect(priv->close_button, "clicked",
719 G_CALLBACK(hildon_find_toolbar_emit_close), self);
720 gtk_widget_show_all(GTK_WIDGET(priv->close_button));
721 gtk_toolbar_insert (GTK_TOOLBAR(self), priv->close_button, -1);
722 if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->close_button)->child) )
723 GTK_WIDGET_UNSET_FLAGS(
724 GTK_BIN(priv->close_button)->child, GTK_CAN_FOCUS);
728 * hildon_find_toolbar_new:
729 * @label: label for the #HildonFindToolbar, %NULL to set the label to
732 * Creates a new #HildonFindToolbar.
734 * Returns: a new #HildonFindToolbar.
737 hildon_find_toolbar_new (const gchar *label)
739 GtkWidget *findtoolbar;
741 findtoolbar = GTK_WIDGET (g_object_new (HILDON_TYPE_FIND_TOOLBAR, NULL));
744 g_object_set(findtoolbar, "label", label, NULL);
750 * hildon_find_toolbar_new_with_model:
751 * @label: label for the #HildonFindToolbar, %NULL to set the label to
753 * @model: a #GtkListStore.
754 * @column: indicates which column the search history list will
755 * retrieve the string from.
757 * Creates a new #HildonFindToolbar with an initial #GtkTreeModel.
759 * Returns: a new #HildonFindToolbar.
762 hildon_find_toolbar_new_with_model (const gchar *label,
766 GtkWidget *findtoolbar;
768 findtoolbar = hildon_find_toolbar_new (label);
770 g_object_set (findtoolbar, "list", model, "column", column, NULL);
776 * hildon_find_toolbar_highlight_entry:
777 * @ftb: #HildonFindToolbar whose entry is to be highlighted.
778 * @get_focus: if user passes %TRUE to this value, then the text in
779 * the entry will not only get highlighted, but also get focused.
781 * Highlights the current entry in the #HildonFindToolbar.
785 hildon_find_toolbar_highlight_entry (HildonFindToolbar *self,
788 GtkEntry *entry = NULL;
789 HildonFindToolbarPrivate *priv;
791 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (self));
792 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
795 entry = hildon_find_toolbar_get_entry (priv);
797 gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
800 gtk_widget_grab_focus (GTK_WIDGET (entry));
804 * hildon_find_toolbar_set_active:
805 * @toolbar: A #HildonFindToolbar to operate on.
806 * @index: An index in the model, or -1 to have no active item.
808 * Sets the active item on the #HildonFindToolbar's #GtkComboBox. Simply calls
809 * gtk_combo_box_set_active() on the #HildonFindToolbar's #GtkComboBox.
813 hildon_find_toolbar_set_active (HildonFindToolbar *toolbar,
816 HildonFindToolbarPrivate *priv;
818 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
819 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
821 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->entry_combo_box), index);
825 * hildon_find_toolbar_get_active:
826 * @toolbar: A #HildonFindToolbar to query.
828 * Gets the index of the currently active item, or -1 if there's no active item.
829 * Simply calls gtk_combo_box_get_active() on the #HildonFindToolbar's
832 * Returns: the index of the currently active item, or -1 if there is no active
837 hildon_find_toolbar_get_active (HildonFindToolbar *toolbar)
839 HildonFindToolbarPrivate *priv;
841 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), -1);
842 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
844 return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->entry_combo_box));
848 * hildon_find_toolbar_set_active_iter:
849 * @toolbar: A #HildonFindToolbar to operate on.
850 * @iter: A #GtkTreeIter to activate.
852 * Sets the current active item to be the one referenced by @iter. Simply calls
853 * gtk_combo_box_set_active_iter() on the #HildonFindToolbar's #GtkComboBox.
857 hildon_find_toolbar_set_active_iter (HildonFindToolbar *toolbar,
860 HildonFindToolbarPrivate *priv;
862 g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
863 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
865 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
869 * hildon_find_toolbar_get_active_iter:
870 * @toolbar: A #HildonFindToolbar to query.
871 * @iter: The uninitialized #GtkTreeIter.
873 * Sets @iter to point to the current active item, if it exists. Simply calls
874 * gtk_combo_box_get_active_iter() on the #HildonFindToolbar's #GtkComboBox.
876 * Returns: %TRUE, if @iter was set.
880 hildon_find_toolbar_get_active_iter (HildonFindToolbar *toolbar,
883 HildonFindToolbarPrivate *priv;
885 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
886 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
888 return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
892 * hildon_find_toolbar_get_last_index
893 * @toolbar: A #HildonFindToolbar to query.
895 * Returns the index of the last (most recently added) item in the
896 * #HildonFindToolbar. Can be used to set this item active in the
897 * #HildonFindToolbar::history-append signal.
900 * Returns: Index of the most recent entry.
904 hildon_find_toolbar_get_last_index (HildonFindToolbar *toolbar)
906 HildonFindToolbarPrivate *priv;
907 GtkTreeModel *filter_model;
909 g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
910 priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
912 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
914 if (filter_model == NULL)
920 gtk_tree_model_get_iter_first (filter_model, &iter);
922 while (gtk_tree_model_iter_next (filter_model, &iter))