~ubuntu-branches/ubuntu/maverick/indicator-applet/maverick

« back to all changes in this revision

Viewing changes to libindicate/indicator.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Ted Gould
  • Date: 2009-08-05 00:22:54 UTC
  • Revision ID: james.westby@ubuntu.com-20090805002254-fzamyyqlltcru23z
Tags: 0.2.0~bzr319-0ubuntu1
[ Ted Gould ]
* Merging in upstream code to split out libindicate-gtk
* debian/control:
  * Changing the version number of libindcate to 2 to match
    the .so numbering.
  * Creating packages for libindicate-gtk
* Added libindicate-gtk-dev.install and libindicate-gtk0.install
  for the new library.
* Renamed libindicate1.install to libindicate2.install to match
  the package name change.
* Modified libindicate-dev to be more specific about the header
  files that it grabs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
        gobj->finalize = indicate_indicator_finalize;
78
78
 
 
79
        /** 
 
80
                IndicateIndicator::display:
 
81
                @arg0: The #IndicateIndicator object
 
82
 
 
83
                Emitted when the user has clicked on this indicator.  In the
 
84
                messaging indicator this would be when someone clicks on the
 
85
                menu item for the indicator.
 
86
        */
79
87
        signals[USER_DISPLAY] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAY,
80
88
                                             G_TYPE_FROM_CLASS(class),
81
89
                                             G_SIGNAL_RUN_LAST,
83
91
                                             NULL, NULL,
84
92
                                             g_cclosure_marshal_VOID__VOID,
85
93
                                             G_TYPE_NONE, 0);
 
94
        /**
 
95
                IndicateIndicator::hide:
 
96
                @arg0: The #IndicateIndicator object
 
97
 
 
98
                Emitted every time this indicator is hidden.  This
 
99
                is mostly used by #IndicateServer.
 
100
 
 
101
                Typically this results in an emition of #IndicateServer::indicator-removed.
 
102
        */
86
103
        signals[HIDE] = g_signal_new(INDICATE_INDICATOR_SIGNAL_HIDE,
87
104
                                             G_TYPE_FROM_CLASS(class),
88
105
                                             G_SIGNAL_RUN_LAST,
90
107
                                             NULL, NULL,
91
108
                                             g_cclosure_marshal_VOID__VOID,
92
109
                                             G_TYPE_NONE, 0);
 
110
        /**
 
111
                IndicateIndicator::show:
 
112
                @arg0: The #IndicateIndicator object
 
113
 
 
114
                Emitted every time this indicator is shown.  This
 
115
                is mostly used by #IndicateServer.
 
116
 
 
117
                Typically this results in an emition of #IndicateServer::indicator-added.
 
118
        */
93
119
        signals[SHOW] = g_signal_new(INDICATE_INDICATOR_SIGNAL_SHOW,
94
120
                                             G_TYPE_FROM_CLASS(class),
95
121
                                             G_SIGNAL_RUN_LAST,
97
123
                                             NULL, NULL,
98
124
                                             g_cclosure_marshal_VOID__VOID,
99
125
                                             G_TYPE_NONE, 0);
 
126
        /**
 
127
                IndicateIndicator::modified:
 
128
                @arg0: The #IndicateIndicator object
 
129
                @arg1: The name of the property that changed.
 
130
 
 
131
                Emitted every time an indicator property is changed.
 
132
                This is mostly used by #IndicateServer.
 
133
 
 
134
                Typically this results in an emition of #IndicateServer::indicator-modified.
 
135
        */
100
136
        signals[MODIFIED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_MODIFIED,
101
137
                                             G_TYPE_FROM_CLASS(class),
102
138
                                             G_SIGNAL_RUN_LAST,
145
181
        return;
146
182
}
147
183
 
 
184
/**
 
185
        indicate_indicator_get_type:
 
186
 
 
187
        Gets a unique #GType for the #IndicateIndicator objects.
 
188
 
 
189
        Return value: A unique #GType value.
 
190
*/
 
191
 
 
192
/**
 
193
        indicate_indicator_new:
 
194
 
 
195
        Builds a new indicator object using g_object_new().
 
196
 
 
197
        Return value: A pointer to a new #IndicateIndicator object.
 
198
*/
148
199
IndicateIndicator *
149
200
indicate_indicator_new (void)
150
201
{
152
203
        return indicator;
153
204
}
154
205
 
 
206
/**
 
207
        indicate_indicator_new_with_server:
 
208
        @server: The server that should be associated with this indicator.
 
209
 
 
210
        Builds a new indicator object using g_object_new() and sets
 
211
        the server to the specified server.  Also, adds a reference
 
212
        to the server.
 
213
 
 
214
        Return value: A pointer to a new #IndicateIndicator object.
 
215
*/
 
216
IndicateIndicator *
 
217
indicate_indicator_new_with_server (IndicateServer * server)
 
218
{
 
219
        g_return_val_if_fail(server != NULL, NULL);
 
220
 
 
221
        IndicateIndicator * indicator = g_object_new(INDICATE_TYPE_INDICATOR, NULL);
 
222
 
 
223
        IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
 
224
        if (priv->server != NULL) {
 
225
                g_object_unref(priv->server);
 
226
                priv->server = NULL;
 
227
        }
 
228
 
 
229
        priv->server = server;
 
230
        g_object_ref(priv->server);
 
231
 
 
232
        return indicator;
 
233
}
 
234
 
 
235
 
 
236
/**
 
237
        indicate_indicator_show:
 
238
        @indicator: a #IndicateIndicator to act on
 
239
 
 
240
        Shows this indicator on the bus.  If the #IndicateServer that it's
 
241
        connected to is not shown itself this function will show the server
 
242
        as well using #indicate_server_show.
 
243
*/
155
244
void
156
245
indicate_indicator_show (IndicateIndicator * indicator)
157
246
{
171
260
        return;
172
261
}
173
262
 
 
263
/**
 
264
        indicate_indicator_hide:
 
265
        @indicator: a #IndicateIndicator to act on
 
266
 
 
267
        Hides the indicator from the bus.  Does not effect the
 
268
        indicator's #IndicateServer in any way.
 
269
*/
174
270
void
175
271
indicate_indicator_hide (IndicateIndicator * indicator)
176
272
{
186
282
        return;
187
283
}
188
284
 
 
285
/**
 
286
        indicate_indicator_is_visible:
 
287
        @indicator: a #IndicateIndicator to act on
 
288
 
 
289
        Checkes the visibility status of @indicator.
 
290
 
 
291
        Return value: %TRUE if the indicator is visible else %FALSE.
 
292
*/
189
293
gboolean
190
294
indicate_indicator_is_visible (IndicateIndicator * indicator)
191
295
{
194
298
        return priv->is_visible;
195
299
}
196
300
 
 
301
/**
 
302
        indicate_indicator_get_id:
 
303
        @indicator: a #IndicateIndicator to act on
 
304
 
 
305
        Gets the ID value of the @indicator.
 
306
 
 
307
        Return value: The ID of the indicator.  Can not be zero.
 
308
                Zero represents an error.
 
309
*/
197
310
guint
198
311
indicate_indicator_get_id (IndicateIndicator * indicator)
199
312
{
202
315
        return priv->id;
203
316
}
204
317
 
 
318
/**
 
319
        indicate_indicator_get_indicator_type:
 
320
        @indicator: a #IndicateIndicator to act on
 
321
 
 
322
        Returns the type of @indicator.  This is largely set by the subclass
 
323
        that the indicator was built with and should not be free'd.
 
324
 
 
325
        Return value: A string defining the type or NULL for no type.
 
326
*/
205
327
const gchar *
206
328
indicate_indicator_get_indicator_type (IndicateIndicator * indicator)
207
329
{
215
337
        return NULL;
216
338
}
217
339
 
 
340
/**
 
341
        indicate_indicator_user_display:
 
342
        @indicator: a #IndicateIndicator to act on
 
343
 
 
344
        Emits the #IndicateIndicator::user-display signal simliar to a user
 
345
        clicking on @indicator over the bus.  Signal will not be sent if the
 
346
        @indicator is not visible.
 
347
*/
218
348
void
219
349
indicate_indicator_user_display (IndicateIndicator * indicator)
220
350
{
227
357
        return;
228
358
}
229
359
 
 
360
/**
 
361
        indicate_indicator_set_property:
 
362
        @indicator: a #IndicateIndicator to act on
 
363
        @key: name of the property
 
364
        @data: value of the property
 
365
 
 
366
        Sets a simple string property on @indicator.  If the property
 
367
        had previously been set it will replace it with the new value,
 
368
        otherwise it will create the property.  This will include an
 
369
        emition of #IndicateIndicator::modified if the property value
 
370
        was changed.
 
371
*/
230
372
void
231
373
indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data)
232
374
{
238
380
        return class->set_property(indicator, key, data);
239
381
}
240
382
 
241
 
void
242
 
indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data)
243
 
{
244
 
        if (!GDK_IS_PIXBUF(data)) {
245
 
                g_warning("Invalide GdkPixbuf");
246
 
                return;
247
 
        }
248
 
 
249
 
        GError * error = NULL;
250
 
        gchar * png_data;
251
 
        gsize png_data_len;
252
 
 
253
 
        if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) {
254
 
                if (error == NULL) {
255
 
                        g_warning("Unable to create pixbuf data stream: %d", png_data_len);
256
 
                } else {
257
 
                        g_warning("Unable to create pixbuf data stream: %s", error->message);
258
 
                        g_error_free(error);
259
 
                        error = NULL;
260
 
                }
261
 
 
262
 
                return;
263
 
        }
264
 
 
265
 
        gchar * prop_str = g_base64_encode((guchar *)png_data, png_data_len);
266
 
        indicate_indicator_set_property(indicator, key, prop_str);
267
 
 
268
 
        g_free(prop_str);
269
 
        g_free(png_data);
270
 
 
271
 
        return;
272
 
}
273
 
 
 
383
/**
 
384
        indicate_indicator_set_property_time:
 
385
        @indicator: a #IndicateIndicator to act on
 
386
        @key: name of the property
 
387
        @time: time to set property with
 
388
 
 
389
        This is a helper function that wraps around #indicate_indicator_set_property
 
390
        but takes an #GTimeVal parameter.  It then takes the @data
 
391
        parameter converts it to an ISO 8601 time string and
 
392
        uses that data to call #indicate_indicator_set_property.
 
393
*/
274
394
void
275
395
indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time)
276
396
{
282
402
        return;
283
403
}
284
404
 
 
405
/**
 
406
        indicate_indicator_get_property:
 
407
        @indicator: a #IndicateIndicator to act on
 
408
        @key: name of the property
 
409
 
 
410
        Returns the value that is set for a property or %NULL if that
 
411
        property is not set.
 
412
 
 
413
        Return value: A constant string or NULL.
 
414
*/
285
415
const gchar *
286
416
indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key)
287
417
{
293
423
        return class->get_property(indicator, key);
294
424
}
295
425
 
 
426
/**
 
427
        indicate_indicator_list_properties:
 
428
        @indicator: a #IndicateIndicator to act on
 
429
 
 
430
        This function gets a list of all the properties that exist
 
431
        on a @indicator.  The array may have zero entries but almost
 
432
        always at least has 'type' in it.
 
433
 
 
434
        Return value: An array of strings that is the keys of all
 
435
                the properties on this indicator.
 
436
*/
296
437
GPtrArray *
297
438
indicate_indicator_list_properties (IndicateIndicator * indicator)
298
439
{