/+junk/libgego

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/libgego

« back to all changes in this revision

Viewing changes to src/gego_global_notify.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-08 14:20:47 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150708142047-rmgvbdul1sff2p42
* Annotate everything!

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
/**
20
20
 * GegoGlobalNotify:
21
 
 * @short_description: aoeu
 
21
 * @short_description:
 
22
 * 
22
23
 */
23
24
 
24
25
 
25
26
////////////////////////////////////////////////////////////////////////////////
26
27
 
27
 
struct GegoGlobalNotifyPrivate {
28
 
  /* <--- private ---> */
29
 
  GHashTable * hash_table; /* GHashTable<gchar *><GLinkedList<GegoGlobalNotifyCallbackItem*>*>* */
 
28
/**
 
29
 * GegoGlobalNotifyPrivate: (skip)
 
30
 *
 
31
 * @hash_table:
 
32
 * GHashTable<gchar *><GLinkedList<GegoGlobalNotifyCallbackItem*>*>*
 
33
 */
 
34
struct _GegoGlobalNotifyPrivate {
 
35
  /* < private > */
 
36
  GHashTable * hash_table;
30
37
  
31
38
};
32
39
 
33
 
struct GegoCallbackItem {
34
 
  /* <--- private ---> */
 
40
 
 
41
/**
 
42
 * GegoCallbackItem: (skip)
 
43
 * 
 
44
 * @subscription_id: The id of the subscriber.
 
45
 * @key_id: The key id of the callback.
 
46
 * @subscriber_data: The data provided by the subscriber_data.
 
47
 * @callback: The callback to be run.
 
48
 */
 
49
struct _GegoCallbackItem {
 
50
  /* < private > */
35
51
  guint subscription_id;
36
52
  GQuark key_id;
37
53
  gpointer subscriber_data;
40
56
 
41
57
G_DEFINE_TYPE_WITH_PRIVATE (GegoGlobalNotify, gego_global_notify, G_TYPE_OBJECT);
42
58
 
 
59
/**
 
60
 * gego_global_notify_new: (skip)
 
61
 *
 
62
 * @void: (skip)
 
63
 */
43
64
GegoGlobalNotify *
44
65
gego_global_notify_new (void) {
45
66
  GegoGlobalNotify * self = g_object_new (GEGO_TYPE_GLOBEL_NOTIFY, NULL, NULL);
48
69
}
49
70
 
50
71
 
 
72
/**
 
73
 * gego_global_notify_constructor: (skip)
 
74
 * gtype: (skip)
 
75
 * n_properties: (skip)
 
76
 * properties: (skip)
 
77
 */
51
78
static GObject *
52
79
gego_global_notify_constructor (GType                   gtype,
53
80
                                guint                   n_properties,
65
92
  return g_object_ref (G_OBJECT (self));
66
93
}
67
94
 
 
95
/**
 
96
 * gego_global_notify_class_init: (skip)
 
97
 *
 
98
 * klass: (skip)
 
99
 */
68
100
static void
69
101
gego_global_notify_class_init (GegoGlobalNotifyClass * klass) {
70
102
  GObjectClass * object_class = G_OBJECT_CLASS (klass);
74
106
}
75
107
 
76
108
 
77
 
 
 
109
/**
 
110
 * gego_global_notify_init: (skip)
 
111
 *
 
112
 * @self: (skip)
 
113
 */
78
114
static void
79
115
gego_global_notify_init (GegoGlobalNotify * self) {
80
116
  
98
134
 * @err: (allow-none): NULL'ed errer to be passed to function.
99
135
 */
100
136
gboolean
101
 
gego_global_notify_initalize (GError * err) {
 
137
gego_global_notify_initalize (GError ** err) {
102
138
  if (_gego_global_notify_instance != NULL) {
103
 
    err = g_error_new (GEGO_GLOBAL_NOTIFY_ERROR,
 
139
    g_set_error (err, GEGO_GLOBAL_NOTIFY_ERROR,
104
140
                 GEGO_GLOBAL_NOTIFY_ERROR_ALREADY_INITALIZED,
105
141
                 "The Global Notify system is already initialized.");
106
142
    return;
117
153
  * @err: (allow-none):NULL'ed errer to be passed to function.
118
154
 */
119
155
gboolean
120
 
gego_global_notify_uninitalize (GError * err) {
 
156
gego_global_notify_uninitalize (GError ** err) {
 
157
  gego_global_notify_return_not_initialized(err);
121
158
  g_object_unref (_gego_global_notify_instance);
122
159
}
123
160
 
132
169
 * return: GUI for that callbacks. negative value on fail.
133
170
 */
134
171
gint
135
 
gego_global_notify_add_notification (gchar * name, GError * err) {
 
172
gego_global_notify_add_notification (gchar * name, GError ** err) {
 
173
  gego_global_notify_return_not_initialized(err);
 
174
  //TODO
136
175
  return 0;
137
176
}
138
177
 
149
188
void
150
189
gego_global_notify_remove_notification (gchar * name,
151
190
                                        gint notification_id,
152
 
                                        GError * err) {
153
 
  
 
191
                                        GError ** err) {
 
192
  gego_global_notify_return_not_initialized(err);
 
193
  //TODO
154
194
}
155
195
 
156
196
/**
173
213
 * returns: the subscription id of the signal.
174
214
 */
175
215
gint
176
 
gego_global_notify_subscribe (gchar * name, GCallback callback, gpointer subscriber_data, GError * err);
 
216
gego_global_notify_subscribe (gchar * name,
 
217
                              GCallback callback,
 
218
                              gpointer subscriber_data,
 
219
                              GError ** err) {
 
220
  gego_global_notify_return_not_initialized(err);
 
221
  // TODO
 
222
}
177
223
 
178
224
/**
179
225
 * gego_global_notify_unsubscribe:
180
 
 * @short_description: removes a callback from a 
 
226
 * @short_description: removes a callback from a notify.
 
227
 *
 
228
 * @name: The name of the notify to unsubscribed to.
 
229
 * @subscription_id: The Subscription ID that was got when the subscription was.
 
230
 *                   made.
 
231
 * @err: (out)(allow-none): Error to be filled with an error if such has occured.
181
232
 */
182
233
void
183
 
gego_global_notify_unsubscribe (gchar * name, gint subscription_id, GError * err);
 
234
gego_global_notify_unsubscribe (gchar * name,
 
235
                                gint subscription_id,
 
236
                                GError ** err) {
 
237
  gego_global_notify_return_not_initialized(err);
 
238
  // TODO
 
239
}
184
240
 
 
241
/**
 
242
 * gego_global_notify_call:
 
243
 * @short_description: Calls all subscribers to a notify.
 
244
 *
 
245
 * @name: The name of the notify to call.
 
246
 * @caller_data: The data to be passed to the callback.
 
247
 * @err: (out)(allow-none): Error to be filled with an error if such has occured.
 
248
 */
185
249
gint
186
 
gego_global_notify_call (gchar * name, gpointer caller_data, GError * err);
 
250
gego_global_notify_call (gchar * name,
 
251
                         gpointer caller_data,
 
252
                         GError ** err) {
 
253
  gego_global_notify_return_not_initialized(err);
 
254
  // TODO
 
255
}
187
256
 
188
257
/**
189
258
 * gego_global_notify_is_initialized:
192
261
 * return: #TRUE if Global Notify is initialized, otherwise #FALSE
193
262
 */
194
263
gboolean
195
 
gego_global_notify_is_initialized (void);
 
264
gego_global_notify_is_initialized () {
 
265
  if (_gego_global_notify_instance == 0) {
 
266
    return TRUE;
 
267
  } else {
 
268
    return FALSE;
 
269
  }
 
270
}
196
271
 
197
272
/**
198
273
 * gego_global_notify_error_quark: (skip)
199
274
 */
200
275
GQuark
201
 
gego_global_notify_error_quark (void) {
 
276
gego_global_notify_error_quark () {
202
277
  return g_quark_from_static_string ("gego-global-notify-error-quark");
203
278
}
 
279
 
 
280
/**
 
281
 * gego_global_notify_error_get_name:
 
282
 * @short_description: Get the string name of the #GegoGlobalNotifyError.
 
283
 * 
 
284
 * @k: The error to get the name of.
 
285
 * 
 
286
 * Anagalius to GegoGlobalNotifyErrorName[k], but included for binding
 
287
 * purposus.
 
288
 *
 
289
 * return: The string containing the name of the error. Or NULL on fail.
 
290
 */
 
291
gchar *
 
292
gego_global_notify_error_get_name (GegoGlobalNotifyError k) {
 
293
  if (k > GEGO_GLOBAL_NOTIFY_ERROR_LAST) {
 
294
    return NULL;
 
295
  }
 
296
  return GegoGlobalNotifyErrorName[k];
 
297
}