HildonLiveSearch

HildonLiveSearch — A widget for manipulating GtkTreeModelFilter instances.

Synopsis


#include <hildon/hildon.h>

                    HildonLiveSearch;
gboolean            (*HildonLiveSearchVisibleFunc)      (GtkTreeModel *model,
                                                         GtkTreeIter *iter,
                                                         gchar *text,
                                                         gpointer data);
void                hildon_live_search_append_text      (HildonLiveSearch *livesearch,
                                                         const char *text);
void                hildon_live_search_set_text         (HildonLiveSearch *livesearch,
                                                         const char *text);
const char*         hildon_live_search_get_text         (HildonLiveSearch *livesearch);
GtkWidget*          hildon_live_search_new              (void);
void                hildon_live_search_restore_state    (HildonLiveSearch *livesearch,
                                                         GKeyFile *key_file);
void                hildon_live_search_save_state       (HildonLiveSearch *livesearch,
                                                         GKeyFile *key_file);
void                hildon_live_search_set_filter       (HildonLiveSearch *livesearch,
                                                         GtkTreeModelFilter *filter);
GtkTreeModelFilter* hildon_live_search_get_filter       (HildonLiveSearch *livesearch);
void                hildon_live_search_set_visible_func (HildonLiveSearch *livesearch,
                                                         HildonLiveSearchVisibleFunc func,
                                                         gpointer data,
                                                         GDestroyNotify destroy);
void                hildon_live_search_set_text_column  (HildonLiveSearch *livesearch,
                                                         gint text_column);
void                hildon_live_search_widget_hook      (HildonLiveSearch *livesearch,
                                                         GtkWidget *hook_widget,
                                                         GtkWidget *kb_focus);
void                hildon_live_search_widget_unhook    (HildonLiveSearch *livesearch);
void                hildon_live_search_clean_selection_map
                                                        (HildonLiveSearch *livesearch);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkToolbar
                                 +----HildonLiveSearch

Implemented Interfaces

HildonLiveSearch implements AtkImplementorIface, GtkBuildable and GtkToolShell.

Properties

  "filter"                   GtkTreeModelFilter*   : Read / Write
  "text"                     gchar*                : Read / Write
  "text-column"              gint                  : Read / Write

Signals

  "refilter"                                       : Run Last

Description

This widget provides a user interface for manipulating GtkTreeModelFilter instances.

To set a GtkTreeFilterModel to filter with, use hildon_live_search_set_filter(). By default, HildonLiveSearch filters on the child model of the filter model set using a case sensitive prefix comparison on the model's column specified by "text-column". If a more refined filtering is necessary, you can use hildon_live_search_set_visible_func() to specify a HildonLiveSearchVisibleFunc to use.

Details

HildonLiveSearch

typedef struct _HildonLiveSearch HildonLiveSearch;


HildonLiveSearchVisibleFunc ()

gboolean            (*HildonLiveSearchVisibleFunc)      (GtkTreeModel *model,
                                                         GtkTreeIter *iter,
                                                         gchar *text,
                                                         gpointer data);

model : The child model of the GtkTreeModelFilter in the live search widget
iter : a GtkTreeIter pointing to the row in model whose visibility is to be determined
text : the text in the HildonLiveSearch entry that is triggering this method call
data : user data given to hildon_live_search_set_visible_func()
Returns : whether the row indicated by iter should be visible

Since 2.2.5


hildon_live_search_append_text ()

void                hildon_live_search_append_text      (HildonLiveSearch *livesearch,
                                                         const char *text);

Appends a string to the entry text in the live search widget.

livesearch : An HildonLiveSearch widget
text : Text to append. text is copied internally can be freed later by the caller.

Since 2.2.4


hildon_live_search_set_text ()

void                hildon_live_search_set_text         (HildonLiveSearch *livesearch,
                                                         const char *text);

Sets a string to the entry text in the live search widget.

livesearch : An HildonLiveSearch widget
text : Text to set. text is copied internally can be freed later by the caller.

Since 2.2.15


hildon_live_search_get_text ()

const char*         hildon_live_search_get_text         (HildonLiveSearch *livesearch);

Retrieves the text contents of the HildonLiveSearch widget.

livesearch : An HildonLiveSearch widget
Returns : a pointer to the text contents of the widget as a string. This string should not be freed, modified, or stored.

Since 2.2.4


hildon_live_search_new ()

GtkWidget*          hildon_live_search_new              (void);

Creates and returns a new HildonLiveSearch widget.

Returns : The newly created live search widget.

Since 2.2.4


hildon_live_search_restore_state ()

void                hildon_live_search_restore_state    (HildonLiveSearch *livesearch,
                                                         GKeyFile *key_file);

Restores a live search widget's text from a GKeyFile.

livesearch : An HildonLiveSearch widget
key_file : The key file to read from

Since 2.2.4


hildon_live_search_save_state ()

void                hildon_live_search_save_state       (HildonLiveSearch *livesearch,
                                                         GKeyFile *key_file);

Saves the live search text to a GKeyFile.

livesearch : An HildonLiveSearch widget
key_file : The key file to save to

Since 2.2.4


hildon_live_search_set_filter ()

void                hildon_live_search_set_filter       (HildonLiveSearch *livesearch,
                                                         GtkTreeModelFilter *filter);

Sets a filter for livesearch.

livesearch : An HildonLiveSearch widget
filter : a GtkTreeModelFilter, or NULL

Since 2.2.4


hildon_live_search_get_filter ()

GtkTreeModelFilter* hildon_live_search_get_filter       (HildonLiveSearch *livesearch);

livesearch : An HildonLiveSearch widget
Returns : The GtkTreeModelFilter set with hildon_live_search_set_filter()

Since 2.2.5


hildon_live_search_set_visible_func ()

void                hildon_live_search_set_visible_func (HildonLiveSearch *livesearch,
                                                         HildonLiveSearchVisibleFunc func,
                                                         gpointer data,
                                                         GDestroyNotify destroy);

Sets the function to use to determine whether a row should be visible when the text in the entry changes. Internally, gtk_tree_model_filter_set_visible_func() is used.

This is convenience API to replace GtkTreeModelFilter's visible function by one that gives the current text in the entry.

If this function is unset, "text-column" is used.

livesearch : a HildonLiveSearch
func : a HildonLiveSearchVisibleFunc
data : user data to pass to func or NULL
destroy : Destroy notifier of data, or NULL.

Since 2.2.5


hildon_live_search_set_text_column ()

void                hildon_live_search_set_text_column  (HildonLiveSearch *livesearch,
                                                         gint text_column);

Sets the column to be used by the default filtering method. This column must be of type G_TYPE_STRING.

Calling this method will trigger filtering of the model, so use with moderation. Note that you can only use either "text-column" or hildon_live_search_set_visible_func().

livesearch : a HildonLiveSearch
text_column : the column in the model of livesearch to get the strings to filter from

Since 2.2.4


hildon_live_search_widget_hook ()

void                hildon_live_search_widget_hook      (HildonLiveSearch *livesearch,
                                                         GtkWidget *hook_widget,
                                                         GtkWidget *kb_focus);

This function must be called after a HildonLiveSearch widget is constructed to set the hook widget and the focus widget for livesearch. After that, the HildonLiveSearch widget can be packed into a container and used.

livesearch : An HildonLiveSearch widget
hook_widget : A widget on which we listen for key events
kb_focus : The widget which we grab focus on

Since 2.2.4


hildon_live_search_widget_unhook ()

void                hildon_live_search_widget_unhook    (HildonLiveSearch *livesearch);

This function unsets the hook and focus widgets which were set earlier using hildon_live_search_widget_hook().

livesearch : An HildonLiveSearch widget

Since 2.2.4


hildon_live_search_clean_selection_map ()

void                hildon_live_search_clean_selection_map
                                                        (HildonLiveSearch *livesearch);

Cleans the selection map maintained by livesearch. When used together with a GtkTreeView, HildonLiveSearch maintains internally a selection map, to make sure that selection is invariant to filtering.

In some cases, you might want to clean this selection mapping, to ensure that after removing the entered text from livesearch, the selection is not restored. This is useful in particular when you are using livesearch with a GtkTreeModel in a GtkTreeView with GtkSelectionMode set to GTK_SELECTION_SINGLE.

livesearch : a HildonLiveSearch

Since 2.2.10

Property Details

The "filter" property

  "filter"                   GtkTreeModelFilter*   : Read / Write

The GtkTreeModelFilter to filter.

Since 2.2.4


The "text" property

  "text"                     gchar*                : Read / Write

The text used to filter

Default value: ""

Since 2.2.15


The "text-column" property

  "text-column"              gint                  : Read / Write

A G_TYPE_STRING column in the child model of "filter", to be used by the default filtering function of HildonLiveSearch.

Allowed values: >= -1

Default value: -1

Since 2.2.4

Signal Details

The "refilter" signal

gboolean            user_function                      (HildonLiveSearch *livesearch,
                                                        gpointer          user_data)       : Run Last

The "refilter" signal is emitted when the text in the entry changed and a refilter is needed.

If this signal is not stopped, gtk_tree_model_filter_refilter() will be called on the filter model. Otherwise the handler is responsible to refilter it.

livesearch : the object which received the signal
user_data : user data set when the signal handler was connected.
Returns : TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.

Since 2.2.5