~ubuntu-branches/ubuntu/raring/gcr/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/00git_gobject_gi_name.patch/gcr/gcr-collection.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-04-03 11:17:42 UTC
  • Revision ID: package-import@ubuntu.com-20130403111742-3pgbsva6v4cqrh1i
Tags: 3.6.2-0ubuntu2
Add 00git_gobject_gi_name.patch: Use GObject.Object instead of GLib.Object
in introspection annotations. Patch backported from 3.8. Fixes FTBFS.
(LP: #1163786)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * gnome-keyring
 
3
 *
 
4
 * Copyright (C) 2010 Stefan Walter
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as
 
8
 * published by the Free Software Foundation; either version 2.1 of
 
9
 * the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * 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 program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
19
 * 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include "gcr-collection.h"
 
25
 
 
26
/**
 
27
 * SECTION:gcr-collection
 
28
 * @title: GcrCollection
 
29
 * @short_description: A collection of objects.
 
30
 *
 
31
 * A #GcrCollection is used to group a set of objects. This is an abstract
 
32
 * interface which can be used to determine which objects show up in a selector
 
33
 * or other user interface element.
 
34
 *
 
35
 * Use gcr_simple_collection_new() to create a concrete implementation of this
 
36
 * interface which you can add objects to.
 
37
 */
 
38
 
 
39
/**
 
40
 * GcrCollection:
 
41
 *
 
42
 * A #GcrCollection is used to group a set of objects.
 
43
 */
 
44
 
 
45
enum {
 
46
        ADDED,
 
47
        REMOVED,
 
48
        LAST_SIGNAL,
 
49
};
 
50
 
 
51
static guint signals[LAST_SIGNAL] = { 0 };
 
52
 
 
53
 
 
54
typedef GcrCollectionIface GcrCollectionInterface;
 
55
 
 
56
G_DEFINE_INTERFACE (GcrCollection, gcr_collection, G_TYPE_OBJECT);
 
57
 
 
58
static void
 
59
gcr_collection_default_init (GcrCollectionIface *iface)
 
60
{
 
61
        static volatile gsize initialized = 0;
 
62
 
 
63
        if (g_once_init_enter (&initialized)) {
 
64
 
 
65
                /**
 
66
                 * GcrCollection::added:
 
67
                 * @self: the collection
 
68
                 * @object: (type GLib.Object): object that was added
 
69
                 *
 
70
                 * This signal is emitted when an object is added to the collection.
 
71
                 */
 
72
                signals[ADDED] = g_signal_new ("added", GCR_TYPE_COLLECTION,
 
73
                                               G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GcrCollectionIface, added),
 
74
                                               NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
 
75
                                               G_TYPE_NONE, 1, G_TYPE_OBJECT);
 
76
 
 
77
                /**
 
78
                 * GcrCollection::removed:
 
79
                 * @self: the collection
 
80
                 * @object: (type GLib.Object): object that was removed
 
81
                 *
 
82
                 * This signal is emitted when an object is removed from the collection.
 
83
                 */
 
84
                signals[REMOVED] = g_signal_new ("removed", GCR_TYPE_COLLECTION,
 
85
                                                 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GcrCollectionIface, removed),
 
86
                                                 NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
 
87
                                                 G_TYPE_NONE, 1, G_TYPE_OBJECT);
 
88
 
 
89
                g_once_init_leave (&initialized, 1);
 
90
        }
 
91
}
 
92
 
 
93
/* -----------------------------------------------------------------------------
 
94
 * PUBLIC
 
95
 */
 
96
 
 
97
 
 
98
/**
 
99
 * gcr_collection_get_length:
 
100
 * @self: The collection
 
101
 *
 
102
 * Get the number of objects in this collection.
 
103
 *
 
104
 * Returns: The number of objects.
 
105
 */
 
106
guint
 
107
gcr_collection_get_length (GcrCollection *self)
 
108
{
 
109
        g_return_val_if_fail (GCR_IS_COLLECTION (self), 0);
 
110
        g_return_val_if_fail (GCR_COLLECTION_GET_INTERFACE (self)->get_length, 0);
 
111
        return GCR_COLLECTION_GET_INTERFACE (self)->get_length (self);
 
112
}
 
113
 
 
114
/**
 
115
 * gcr_collection_get_objects:
 
116
 * @self: The collection
 
117
 *
 
118
 * Get a list of the objects in this collection.
 
119
 *
 
120
 * Returns: (transfer container) (element-type GLib.Object): a list of the objects
 
121
 *          in this collection, which should be freed with g_list_free()
 
122
 */
 
123
GList*
 
124
gcr_collection_get_objects (GcrCollection *self)
 
125
{
 
126
        g_return_val_if_fail (GCR_IS_COLLECTION (self), 0);
 
127
        g_return_val_if_fail (GCR_COLLECTION_GET_INTERFACE (self)->get_objects, 0);
 
128
        return GCR_COLLECTION_GET_INTERFACE (self)->get_objects (self);
 
129
}
 
130
 
 
131
/**
 
132
 * gcr_collection_contains:
 
133
 * @self: the collection
 
134
 * @object: object to check
 
135
 *
 
136
 * Check whether the collection contains an object or not.
 
137
 *
 
138
 * Returns: whether the collection contains this object
 
139
 */
 
140
gboolean
 
141
gcr_collection_contains (GcrCollection *self,
 
142
                         GObject *object)
 
143
{
 
144
        g_return_val_if_fail (GCR_IS_COLLECTION (self), FALSE);
 
145
        g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
 
146
        g_return_val_if_fail (GCR_COLLECTION_GET_INTERFACE (self)->contains, FALSE);
 
147
        return GCR_COLLECTION_GET_INTERFACE (self)->contains (self, object);
 
148
}
 
149
 
 
150
/**
 
151
 * gcr_collection_emit_added:
 
152
 * @self: The collection
 
153
 * @object: The object that was added
 
154
 *
 
155
 * Emit the #GcrCollection::added signal for the given object. This function
 
156
 * is used by implementors of this interface.
 
157
 */
 
158
void
 
159
gcr_collection_emit_added (GcrCollection *self, GObject *object)
 
160
{
 
161
        g_return_if_fail (GCR_IS_COLLECTION (self));
 
162
        g_signal_emit (self, signals[ADDED], 0, object);
 
163
}
 
164
 
 
165
/**
 
166
 * gcr_collection_emit_removed:
 
167
 * @self: The collection
 
168
 * @object: The object that was removed
 
169
 *
 
170
 * Emit the #GcrCollection::removed signal for the given object. This function
 
171
 * is used by implementors of this interface.
 
172
 */
 
173
void
 
174
gcr_collection_emit_removed (GcrCollection *self, GObject *object)
 
175
{
 
176
        g_return_if_fail (GCR_IS_COLLECTION (self));
 
177
        g_signal_emit (self, signals[REMOVED], 0, object);
 
178
}