1 /*
2  * Copyright (C) 2011 Collabora Ltd.
3  * Copyright (C) 2010 Collabora Ltd.
4  * Copyright (C) 2007-2010 Nokia Corporation.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * Authors: Felix Kaser <felix.kaser@collabora.co.uk>
21  *          Xavier Claessens <xavier.claessens@collabora.co.uk>
22  *          Claudio Saavedra <csaavedra@igalia.com>
23  *          Stef Walter <stefw@collabora.co.uk>
24  */
25 
26 /* Code borrowed from Empathy */
27 
28 #ifndef __GCR_LIVE_SEARCH_H__
29 #define __GCR_LIVE_SEARCH_H__
30 
31 #include <gtk/gtk.h>
32 
33 G_BEGIN_DECLS
34 
35 #define GCR_TYPE_LIVE_SEARCH         (_gcr_live_search_get_type ())
36 #define GCR_LIVE_SEARCH(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GCR_TYPE_LIVE_SEARCH, GcrLiveSearch))
37 #define GCR_LIVE_SEARCH_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GCR_TYPE_LIVE_SEARCH, GcrLiveSearchClass))
38 #define GCR_IS_LIVE_SEARCH(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GCR_TYPE_LIVE_SEARCH))
39 #define GCR_IS_LIVE_SEARCH_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GCR_TYPE_LIVE_SEARCH))
40 #define GCR_LIVE_SEARCH_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GCR_TYPE_LIVE_SEARCH, GcrLiveSearchClass))
41 
42 typedef struct _GcrLiveSearch      GcrLiveSearch;
43 typedef struct _GcrLiveSearchClass GcrLiveSearchClass;
44 typedef struct _GcrLiveSearchPrivate GcrLiveSearchPrivate;
45 
46 struct _GcrLiveSearch {
47 	/*< private >*/
48 	GtkBox parent;
49 	GcrLiveSearchPrivate *pv;
50 };
51 
52 struct _GcrLiveSearchClass {
53 	GtkBoxClass parent_class;
54 };
55 
56 GType             _gcr_live_search_get_type               (void) G_GNUC_CONST;
57 
58 GtkWidget *       _gcr_live_search_new                    (GtkWidget *hook);
59 
60 GtkWidget *       _gcr_live_search_get_hook_widget        (GcrLiveSearch *self);
61 void              _gcr_live_search_set_hook_widget        (GcrLiveSearch *self,
62                                                            GtkWidget *hook);
63 
64 const gchar *     _gcr_live_search_get_text               (GcrLiveSearch *self);
65 void              _gcr_live_search_set_text               (GcrLiveSearch *self,
66                                                            const gchar *text);
67 
68 gboolean          _gcr_live_search_match                  (GcrLiveSearch *self,
69                                                            const gchar *string);
70 
71 GPtrArray *       _gcr_live_search_strip_utf8_string      (const gchar *string);
72 
73 gboolean          _gcr_live_search_match_words            (const gchar *string,
74                                                            GPtrArray *words);
75 
76 GPtrArray *       _gcr_live_search_get_words              (GcrLiveSearch *self);
77 
78 /* Made public for unit tests */
79 gboolean          _gcr_live_search_match_string           (const gchar *string,
80                                                            const gchar *prefix);
81 
82 G_END_DECLS
83 
84 #endif /* __GCR_LIVE_SEARCH_H__ */
85