~ubuntu-branches/ubuntu/lucid/giggle/lucid

« back to all changes in this revision

Viewing changes to libgiggle/giggle-searchable.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrea Corradi
  • Date: 2009-03-30 19:41:43 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090330194143-nyr9ze1xola1shm5
Tags: 0.4.91-1
* New upstream release (Closes:  #519014)
* Use Standards-Version 3.8.1
* Add new Build-Depends
* Update Homepage and watch file
* Update debian/copyright
* Remove patch
* Update path in debian/rules
* Remove defs option from LDFLAGS

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
/*
 
3
 * Copyright (C) 2007 Imendio AB
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#include "giggle-searchable.h"
 
22
 
 
23
GType
 
24
giggle_searchable_get_type (void)
 
25
{
 
26
  static GType searchable_type = 0;
 
27
 
 
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 */
 
36
                  0,
 
37
                  0,            /* n_preallocs */
 
38
                  NULL
 
39
          };
 
40
 
 
41
          searchable_type =
 
42
                  g_type_register_static (G_TYPE_INTERFACE, "GiggleSearchable",
 
43
                                          &giggle_searchable_info, 0);
 
44
 
 
45
          g_type_interface_add_prerequisite (searchable_type, G_TYPE_OBJECT);
 
46
  }
 
47
 
 
48
  return searchable_type;
 
49
}
 
50
 
 
51
gboolean
 
52
giggle_searchable_search (GiggleSearchable      *searchable,
 
53
                          const gchar           *search_term,
 
54
                          GiggleSearchDirection  direction,
 
55
                          gboolean               full_search)
 
56
{
 
57
        GiggleSearchableIface *iface;
 
58
        gboolean result = FALSE;
 
59
 
 
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);
 
63
 
 
64
        iface = GIGGLE_SEARCHABLE_GET_IFACE (searchable);
 
65
 
 
66
        if (iface->search) {
 
67
                gchar *casefold_search_term;
 
68
 
 
69
                casefold_search_term = g_utf8_casefold (search_term, -1);
 
70
                result = (* iface->search) (searchable, casefold_search_term,
 
71
                                            direction, full_search);
 
72
 
 
73
                g_free (casefold_search_term);
 
74
        }
 
75
 
 
76
        return result;
 
77
}
 
78
 
 
79
void
 
80
giggle_searchable_cancel (GiggleSearchable *searchable)
 
81
{
 
82
        GiggleSearchableIface *iface;
 
83
 
 
84
        g_return_if_fail (GIGGLE_IS_SEARCHABLE (searchable));
 
85
 
 
86
        iface = GIGGLE_SEARCHABLE_GET_IFACE (searchable);
 
87
 
 
88
        if (iface->cancel) {
 
89
                (* iface->cancel) (searchable);
 
90
        }
 
91
}