changed the refresh hotkey
[giggle.git] / libgiggle / giggle-searchable.c
blobfc1c4624efd4b405b41b841affac8243d7afdc26
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * Copyright (C) 2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include "giggle-searchable.h"
23 GType
24 giggle_searchable_get_type (void)
26 static GType searchable_type = 0;
28 if (G_UNLIKELY (!searchable_type)) {
29 const GTypeInfo giggle_searchable_info = {
30 sizeof (GiggleSearchableIface), /* class_size */
31 NULL, /* base_init */
32 NULL, /* base_finalize */
33 NULL,
34 NULL, /* class_finalize */
35 NULL, /* class_data */
37 0, /* n_preallocs */
38 NULL
41 searchable_type =
42 g_type_register_static (G_TYPE_INTERFACE, "GiggleSearchable",
43 &giggle_searchable_info, 0);
45 g_type_interface_add_prerequisite (searchable_type, G_TYPE_OBJECT);
48 return searchable_type;
51 gboolean
52 giggle_searchable_search (GiggleSearchable *searchable,
53 const gchar *search_term,
54 GiggleSearchDirection direction,
55 gboolean full_search)
57 GiggleSearchableIface *iface;
58 gboolean result = FALSE;
60 g_return_val_if_fail (GIGGLE_IS_SEARCHABLE (searchable), FALSE);
61 g_return_val_if_fail (direction == GIGGLE_SEARCH_DIRECTION_NEXT ||
62 direction == GIGGLE_SEARCH_DIRECTION_PREV, FALSE);
64 iface = GIGGLE_SEARCHABLE_GET_IFACE (searchable);
66 if (iface->search) {
67 gchar *casefold_search_term;
69 casefold_search_term = g_utf8_casefold (search_term, -1);
70 result = (* iface->search) (searchable, casefold_search_term,
71 direction, full_search);
73 g_free (casefold_search_term);
76 return result;
79 void
80 giggle_searchable_cancel (GiggleSearchable *searchable)
82 GiggleSearchableIface *iface;
84 g_return_if_fail (GIGGLE_IS_SEARCHABLE (searchable));
86 iface = GIGGLE_SEARCHABLE_GET_IFACE (searchable);
88 if (iface->cancel) {
89 (* iface->cancel) (searchable);