~ubuntu-branches/debian/experimental/brasero/experimental

« back to all changes in this revision

Viewing changes to libbrasero-media/brasero-medium-monitor.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * Libbrasero-media
 
4
 * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
 
5
 *
 
6
 * Libbrasero-media is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * The Libbrasero-media authors hereby grant permission for non-GPL compatible
 
12
 * GStreamer plugins to be used and distributed together with GStreamer
 
13
 * and Libbrasero-media. This permission is above and beyond the permissions granted
 
14
 * by the GPL license by which Libbrasero-media is covered. If you modify this code
 
15
 * you may extend this exception to your version of the code, but you are not
 
16
 * obligated to do so. If you do not wish to do so, delete this exception
 
17
 * statement from your version.
 
18
 * 
 
19
 * Libbrasero-media is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 * GNU Library General Public License for more details.
 
23
 * 
 
24
 * You should have received a copy of the GNU General Public License
 
25
 * along with this program; if not, write to:
 
26
 *      The Free Software Foundation, Inc.,
 
27
 *      51 Franklin Street, Fifth Floor
 
28
 *      Boston, MA  02110-1301, USA.
 
29
 */
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#  include <config.h>
 
33
#endif
 
34
 
 
35
#include <string.h>
 
36
 
 
37
#include <glib.h>
 
38
#include <glib/gi18n-lib.h>
 
39
 
 
40
#include <gio/gio.h>
 
41
 
 
42
#include <dbus/dbus.h>
 
43
#include <dbus/dbus-glib.h>
 
44
#include <dbus/dbus-glib-lowlevel.h>
 
45
 
 
46
#include <libhal.h>
 
47
 
 
48
#include "brasero-media-private.h"
 
49
 
 
50
#include "brasero-drive.h"
 
51
#include "brasero-medium.h"
 
52
#include "burn-hal-watch.h"
 
53
#include "brasero-medium-monitor.h"
 
54
 
 
55
typedef struct _BraseroMediumMonitorPrivate BraseroMediumMonitorPrivate;
 
56
struct _BraseroMediumMonitorPrivate
 
57
{
 
58
        GSList *drives;
 
59
        GVolumeMonitor *gmonitor;
 
60
 
 
61
        gint probing;
 
62
};
 
63
 
 
64
#define BRASERO_MEDIUM_MONITOR_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM_MONITOR, BraseroMediumMonitorPrivate))
 
65
 
 
66
enum
 
67
{
 
68
        MEDIUM_INSERTED,
 
69
        MEDIUM_REMOVED,
 
70
        DRIVE_ADDED,
 
71
        DRIVE_REMOVED,
 
72
 
 
73
        LAST_SIGNAL
 
74
};
 
75
 
 
76
 
 
77
static guint medium_monitor_signals[LAST_SIGNAL] = { 0 };
 
78
 
 
79
G_DEFINE_TYPE (BraseroMediumMonitor, brasero_medium_monitor, G_TYPE_OBJECT);
 
80
 
 
81
 
 
82
/**
 
83
 * These definitions go here as they shouldn't be public and they're used only 
 
84
 * here.
 
85
 */
 
86
 
 
87
BraseroDrive *
 
88
brasero_drive_new (const gchar *udi);
 
89
 
 
90
gboolean
 
91
brasero_drive_probing (BraseroDrive *drive);
 
92
 
 
93
/**
 
94
 * brasero_medium_monitor_get_drive:
 
95
 * @monitor: a #BraseroMediumMonitor
 
96
 * @device: the path of the device
 
97
 *
 
98
 * Returns the #BraseroDrive object whose path is @path.
 
99
 *
 
100
 * Return value: a #BraseroDrive or NULL
 
101
 **/
 
102
BraseroDrive *
 
103
brasero_medium_monitor_get_drive (BraseroMediumMonitor *monitor,
 
104
                                  const gchar *device)
 
105
{
 
106
        GSList *iter;
 
107
        BraseroMediumMonitorPrivate *priv;
 
108
 
 
109
        g_return_val_if_fail (monitor != NULL, NULL);
 
110
        g_return_val_if_fail (BRASERO_IS_MEDIUM_MONITOR (monitor), NULL);
 
111
 
 
112
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (monitor);
 
113
        for (iter = priv->drives; iter; iter = iter->next) {
 
114
                BraseroDrive *drive;
 
115
                const gchar *drive_device;
 
116
 
 
117
                drive = iter->data;
 
118
                drive_device = brasero_drive_get_device (drive);
 
119
                if (drive_device && !strcmp (drive_device, device)) {
 
120
                        g_object_ref (drive);
 
121
                        return drive;
 
122
                }
 
123
        }
 
124
 
 
125
        return NULL;
 
126
}
 
127
 
 
128
/**
 
129
 * brasero_medium_monitor_is_probing:
 
130
 * @monitor: a #BraseroMediumMonitor
 
131
 *
 
132
 * Returns if the library is still probing some other media.
 
133
 *
 
134
 * Return value: %TRUE if it is still probing some media
 
135
 **/
 
136
gboolean
 
137
brasero_medium_monitor_is_probing (BraseroMediumMonitor *monitor)
 
138
{
 
139
        GSList *iter;
 
140
        BraseroMediumMonitorPrivate *priv;
 
141
 
 
142
        g_return_val_if_fail (monitor != NULL, FALSE);
 
143
        g_return_val_if_fail (BRASERO_IS_MEDIUM_MONITOR (monitor), FALSE);
 
144
 
 
145
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (monitor);
 
146
 
 
147
        for (iter = priv->drives; iter; iter = iter->next) {
 
148
                BraseroDrive *drive;
 
149
 
 
150
                drive = iter->data;
 
151
                if (brasero_drive_is_fake (drive))
 
152
                        continue;
 
153
 
 
154
                if (brasero_drive_probing (drive))
 
155
                        return TRUE;
 
156
        }
 
157
 
 
158
        return FALSE;
 
159
}
 
160
 
 
161
/**
 
162
 * brasero_medium_monitor_get_drives:
 
163
 * @monitor: a #BraseroMediumMonitor
 
164
 * @type: a #BraseroDriveType to tell what type of drives to include in the list
 
165
 *
 
166
 * Gets the list of available drives that are of the given type.
 
167
 *
 
168
 * Return value: a #GSList or NULL
 
169
 **/
 
170
GSList *
 
171
brasero_medium_monitor_get_drives (BraseroMediumMonitor *monitor,
 
172
                                   BraseroDriveType type)
 
173
{
 
174
        BraseroMediumMonitorPrivate *priv;
 
175
        GSList *drives = NULL;
 
176
        GSList *iter;
 
177
 
 
178
        g_return_val_if_fail (monitor != NULL, NULL);
 
179
        g_return_val_if_fail (BRASERO_IS_MEDIUM_MONITOR (monitor), NULL);
 
180
 
 
181
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (monitor);
 
182
 
 
183
        for (iter = priv->drives; iter; iter = iter->next) {
 
184
                BraseroDrive *drive;
 
185
 
 
186
                drive = iter->data;
 
187
                if (brasero_drive_is_fake (drive)) {
 
188
                        if (type & BRASERO_DRIVE_TYPE_FILE)
 
189
                                drives = g_slist_prepend (drives, drive);
 
190
 
 
191
                        continue;
 
192
                }
 
193
 
 
194
                if (brasero_drive_can_write (drive)
 
195
                && (type & BRASERO_DRIVE_TYPE_WRITER)) {
 
196
                        drives = g_slist_prepend (drives, drive);
 
197
                        continue;
 
198
                }
 
199
 
 
200
                if (type & BRASERO_DRIVE_TYPE_READER) {
 
201
                        drives = g_slist_prepend (drives, drive);
 
202
                        continue;
 
203
                }
 
204
        }
 
205
        g_slist_foreach (drives, (GFunc) g_object_ref, NULL);
 
206
 
 
207
        return drives;
 
208
}
 
209
 
 
210
/**
 
211
 * brasero_medium_monitor_get_media:
 
212
 * @monitor: a #BraseroMediumMonitor
 
213
 * @type: the type of #BraseroMedium that should be in the list
 
214
 *
 
215
 * Obtains the list of available media that are of the given type.
 
216
 *
 
217
 * Return value: a #GSList or NULL
 
218
 **/
 
219
GSList *
 
220
brasero_medium_monitor_get_media (BraseroMediumMonitor *monitor,
 
221
                                  BraseroMediaType type)
 
222
{
 
223
        GSList *iter;
 
224
        GSList *list = NULL;
 
225
        BraseroMediumMonitorPrivate *priv;
 
226
 
 
227
        g_return_val_if_fail (monitor != NULL, NULL);
 
228
        g_return_val_if_fail (BRASERO_IS_MEDIUM_MONITOR (monitor), NULL);
 
229
 
 
230
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (monitor);
 
231
 
 
232
        for (iter = priv->drives; iter; iter = iter->next) {
 
233
                BraseroMedium *medium;
 
234
                BraseroDrive *drive;
 
235
 
 
236
                drive = iter->data;
 
237
 
 
238
                medium = brasero_drive_get_medium (drive);
 
239
                if (!medium)
 
240
                        continue;
 
241
 
 
242
                if ((type & BRASERO_MEDIA_TYPE_ANY_IN_BURNER)
 
243
                &&  (brasero_drive_can_write (drive))) {
 
244
                        list = g_slist_prepend (list, medium);
 
245
                        g_object_ref (medium);
 
246
                        continue;
 
247
                }
 
248
 
 
249
                if ((type & BRASERO_MEDIA_TYPE_AUDIO)
 
250
                && !(brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE)
 
251
                &&  (brasero_medium_get_status (medium) & BRASERO_MEDIUM_HAS_AUDIO)) {
 
252
                        list = g_slist_prepend (list, medium);
 
253
                        g_object_ref (medium);
 
254
                        continue;
 
255
                }
 
256
 
 
257
                if ((type & BRASERO_MEDIA_TYPE_DATA)
 
258
                && !(brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE)
 
259
                &&  (brasero_medium_get_status (medium) & BRASERO_MEDIUM_HAS_DATA)) {
 
260
                        list = g_slist_prepend (list, medium);
 
261
                        g_object_ref (medium);
 
262
                        continue;
 
263
                }
 
264
 
 
265
                if (type & BRASERO_MEDIA_TYPE_WRITABLE) {
 
266
                        if (brasero_medium_can_be_written (medium)) {
 
267
                                list = g_slist_prepend (list, medium);
 
268
                                g_object_ref (medium);
 
269
                                continue;
 
270
                        }
 
271
                }
 
272
 
 
273
                if (type & BRASERO_MEDIA_TYPE_REWRITABLE) {
 
274
                        if (brasero_medium_can_be_rewritten (medium)) {
 
275
                                list = g_slist_prepend (list, medium);
 
276
                                g_object_ref (medium);
 
277
                                continue;
 
278
                        }
 
279
                }
 
280
 
 
281
                if (type & BRASERO_MEDIA_TYPE_FILE) {
 
282
                        if (brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE) {
 
283
                                list = g_slist_prepend (list, medium);
 
284
                                g_object_ref (medium);
 
285
                        }
 
286
                }
 
287
        }
 
288
 
 
289
        return list;
 
290
}
 
291
 
 
292
static void
 
293
brasero_medium_monitor_medium_added_cb (BraseroDrive *drive,
 
294
                                        BraseroMedium *medium,
 
295
                                        BraseroMediumMonitor *self)
 
296
{
 
297
        g_signal_emit (self,
 
298
                       medium_monitor_signals [MEDIUM_INSERTED],
 
299
                       0,
 
300
                       medium);
 
301
}
 
302
 
 
303
static void
 
304
brasero_medium_monitor_medium_removed_cb (BraseroDrive *drive,
 
305
                                          BraseroMedium *medium,
 
306
                                          BraseroMediumMonitor *self)
 
307
{
 
308
        g_signal_emit (self,
 
309
                       medium_monitor_signals [MEDIUM_REMOVED],
 
310
                       0,
 
311
                       medium);
 
312
}
 
313
 
 
314
static void
 
315
brasero_medium_monitor_inserted_cb (BraseroHALWatch *watch,
 
316
                                    const char *udi,
 
317
                                    BraseroMediumMonitor *self)
 
318
{
 
319
        BraseroMediumMonitorPrivate *priv;
 
320
        BraseroDrive *drive = NULL;
 
321
        LibHalContext *ctx;
 
322
 
 
323
        ctx = brasero_hal_watch_get_ctx (watch);
 
324
        if (!libhal_device_query_capability (ctx, udi, "storage.cdrom", NULL))
 
325
                return;
 
326
 
 
327
        BRASERO_MEDIA_LOG ("New drive added");
 
328
 
 
329
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
 
330
 
 
331
        drive = brasero_drive_new (udi);
 
332
        priv->drives = g_slist_prepend (priv->drives, drive);
 
333
 
 
334
        /* connect to signals. This must come before the g_signal_emit () so we
 
335
         * are the first to get an update on the medium inside. */
 
336
        g_signal_connect (drive,
 
337
                          "medium-added",
 
338
                          G_CALLBACK (brasero_medium_monitor_medium_added_cb),
 
339
                          self);
 
340
        g_signal_connect (drive,
 
341
                          "medium-removed",
 
342
                          G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
 
343
                          self);
 
344
 
 
345
        g_signal_emit (self,
 
346
                       medium_monitor_signals [DRIVE_ADDED],
 
347
                       0,
 
348
                       drive);
 
349
 
 
350
        /* check if a medium is inserted */
 
351
        if (brasero_drive_get_medium (drive))
 
352
                g_signal_emit (self,
 
353
                               medium_monitor_signals [MEDIUM_INSERTED],
 
354
                               0,
 
355
                               brasero_drive_get_medium (drive));
 
356
}
 
357
 
 
358
static void
 
359
brasero_medium_monitor_removed_cb (BraseroHALWatch *watch,
 
360
                                   const char *udi,
 
361
                                   BraseroMediumMonitor *self)
 
362
{
 
363
        BraseroMediumMonitorPrivate *priv;
 
364
        LibHalContext *ctx;
 
365
        GSList *iter;
 
366
        GSList *next;
 
367
 
 
368
        ctx = brasero_hal_watch_get_ctx (watch);
 
369
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
 
370
 
 
371
        BRASERO_MEDIA_LOG ("Drive removed");
 
372
 
 
373
        for (iter = priv->drives; iter; iter = next) {
 
374
                const gchar *device_udi;
 
375
                BraseroDrive *drive;
 
376
 
 
377
                drive = iter->data;
 
378
                next = iter->next;
 
379
 
 
380
                device_udi = brasero_drive_get_udi (drive);
 
381
                if (!device_udi)
 
382
                        continue;
 
383
 
 
384
                if (!strcmp (device_udi, udi)) {
 
385
                        BraseroMedium *medium;
 
386
 
 
387
                        medium = brasero_drive_get_medium (drive);
 
388
                        if (medium)
 
389
                                g_signal_emit (self,
 
390
                                               medium_monitor_signals [MEDIUM_REMOVED],
 
391
                                               0,
 
392
                                               medium);
 
393
 
 
394
                        priv->drives = g_slist_remove (priv->drives, drive);
 
395
                        g_signal_emit (self,
 
396
                                       medium_monitor_signals [DRIVE_REMOVED],
 
397
                                       0,
 
398
                                       drive);
 
399
                        g_object_unref (drive);
 
400
                }
 
401
        }
 
402
}
 
403
 
 
404
static void
 
405
brasero_medium_monitor_init (BraseroMediumMonitor *object)
 
406
{
 
407
        DBusError error;
 
408
        int nb_devices, i;
 
409
        LibHalContext *ctx;
 
410
        BraseroDrive *drive;
 
411
        char **devices = NULL;
 
412
        BraseroHALWatch *watch;
 
413
        BraseroMediumMonitorPrivate *priv;
 
414
 
 
415
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (object);
 
416
 
 
417
        /* This must done early on. GVolumeMonitor when it relies on HAL (like
 
418
         * us) must be able to update its list of volumes before us so it must
 
419
         * connect to HAL before us. */
 
420
        priv->gmonitor = g_volume_monitor_get ();
 
421
 
 
422
        watch = brasero_hal_watch_get_default ();
 
423
        ctx = brasero_hal_watch_get_ctx (watch);
 
424
 
 
425
        g_signal_connect (watch,
 
426
                          "device-added",
 
427
                          G_CALLBACK (brasero_medium_monitor_inserted_cb),
 
428
                          object);
 
429
        g_signal_connect (watch,
 
430
                          "device-removed",
 
431
                          G_CALLBACK (brasero_medium_monitor_removed_cb),
 
432
                          object);
 
433
 
 
434
        /* Now we get the list and cache it */
 
435
        dbus_error_init (&error);
 
436
        BRASERO_MEDIA_LOG ("Polling for drives");
 
437
        devices = libhal_find_device_by_capability (ctx,
 
438
                                                    "storage.cdrom", &nb_devices,
 
439
                                                    &error);
 
440
        if (dbus_error_is_set (&error)) {
 
441
                BRASERO_MEDIA_LOG ("Hal is not running : %s\n", error.message);
 
442
                dbus_error_free (&error);
 
443
                return;
 
444
        }
 
445
 
 
446
        BRASERO_MEDIA_LOG ("Found %d drives", nb_devices);
 
447
        for (i = 0; i < nb_devices; i++) {
 
448
                /* create the drive */
 
449
                BRASERO_MEDIA_LOG ("Probing %s", devices [i]);
 
450
                drive = brasero_drive_new (devices [i]);
 
451
                priv->drives = g_slist_prepend (priv->drives, drive);
 
452
 
 
453
                g_signal_connect (drive,
 
454
                                  "medium-added",
 
455
                                  G_CALLBACK (brasero_medium_monitor_medium_added_cb),
 
456
                                  object);
 
457
                g_signal_connect (drive,
 
458
                                  "medium-removed",
 
459
                                  G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
 
460
                                  object);
 
461
        }
 
462
        libhal_free_string_array (devices);
 
463
 
 
464
        /* add fake/file drive */
 
465
        drive = brasero_drive_new (NULL);
 
466
        priv->drives = g_slist_prepend (priv->drives, drive);
 
467
 
 
468
        return;
 
469
}
 
470
 
 
471
static void
 
472
brasero_medium_monitor_finalize (GObject *object)
 
473
{
 
474
        BraseroMediumMonitorPrivate *priv;
 
475
 
 
476
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (object);
 
477
 
 
478
        if (priv->drives) {
 
479
                g_slist_foreach (priv->drives, (GFunc) g_object_unref, NULL);
 
480
                g_slist_free (priv->drives);
 
481
                priv->drives = NULL;
 
482
        }
 
483
 
 
484
        if (priv->gmonitor) {
 
485
                g_object_unref (priv->gmonitor);
 
486
                priv->gmonitor = NULL;
 
487
        }
 
488
 
 
489
        G_OBJECT_CLASS (brasero_medium_monitor_parent_class)->finalize (object);
 
490
}
 
491
 
 
492
static void
 
493
brasero_medium_monitor_class_init (BraseroMediumMonitorClass *klass)
 
494
{
 
495
        GObjectClass* object_class = G_OBJECT_CLASS (klass);
 
496
 
 
497
        g_type_class_add_private (klass, sizeof (BraseroMediumMonitorPrivate));
 
498
 
 
499
        object_class->finalize = brasero_medium_monitor_finalize;
 
500
 
 
501
        /**
 
502
        * BraseroMediumMonitor::medium-added:
 
503
        * @monitor: the object which received the signal
 
504
        * @medium: the new medium which was added
 
505
        *
 
506
        * This signal gets emitted when a new medium was detected
 
507
        **/
 
508
        medium_monitor_signals[MEDIUM_INSERTED] =
 
509
                g_signal_new ("medium_added",
 
510
                              G_OBJECT_CLASS_TYPE (klass),
 
511
                              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 
512
                              G_STRUCT_OFFSET (BraseroMediumMonitorClass, medium_added),
 
513
                              NULL, NULL,
 
514
                              g_cclosure_marshal_VOID__OBJECT,
 
515
                              G_TYPE_NONE, 1,
 
516
                              BRASERO_TYPE_MEDIUM);
 
517
 
 
518
        /**
 
519
        * BraseroMediumMonitor::medium-removed:
 
520
        * @monitor: the object which received the signal
 
521
        * @medium: the medium which was removed
 
522
        *
 
523
        * This signal gets emitted when a medium is not longer available
 
524
        **/
 
525
        medium_monitor_signals[MEDIUM_REMOVED] =
 
526
                g_signal_new ("medium_removed",
 
527
                              G_OBJECT_CLASS_TYPE (klass),
 
528
                              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 
529
                              G_STRUCT_OFFSET (BraseroMediumMonitorClass, medium_removed),
 
530
                              NULL, NULL,
 
531
                              g_cclosure_marshal_VOID__OBJECT,
 
532
                              G_TYPE_NONE, 1,
 
533
                              BRASERO_TYPE_MEDIUM);
 
534
 
 
535
        /**
 
536
        * BraseroMediumMonitor::drive-added:
 
537
        * @monitor: the object which received the signal
 
538
        * @medium: the new medium which was added
 
539
        *
 
540
        * This signal gets emitted when a new drive was detected
 
541
        **/
 
542
        medium_monitor_signals[DRIVE_ADDED] =
 
543
                g_signal_new ("drive_added",
 
544
                              G_OBJECT_CLASS_TYPE (klass),
 
545
                              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 
546
                              G_STRUCT_OFFSET (BraseroMediumMonitorClass, drive_added),
 
547
                              NULL, NULL,
 
548
                              g_cclosure_marshal_VOID__OBJECT,
 
549
                              G_TYPE_NONE, 1,
 
550
                              BRASERO_TYPE_DRIVE);
 
551
 
 
552
        /**
 
553
        * BraseroMediumMonitor::drive-removed:
 
554
        * @monitor: the object which received the signal
 
555
        * @medium: the medium which was removed
 
556
        *
 
557
        * This signal gets emitted when a drive is not longer available
 
558
        **/
 
559
        medium_monitor_signals[DRIVE_REMOVED] =
 
560
                g_signal_new ("drive_removed",
 
561
                              G_OBJECT_CLASS_TYPE (klass),
 
562
                              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 
563
                              G_STRUCT_OFFSET (BraseroMediumMonitorClass, drive_removed),
 
564
                              NULL, NULL,
 
565
                              g_cclosure_marshal_VOID__OBJECT,
 
566
                              G_TYPE_NONE, 1,
 
567
                              BRASERO_TYPE_DRIVE);
 
568
}
 
569
 
 
570
static BraseroMediumMonitor *singleton = NULL;
 
571
 
 
572
/**
 
573
 * brasero_medium_monitor_get_default:
 
574
 *
 
575
 * Gets the currently active monitor.
 
576
 *
 
577
 * Return value: a #BraseroMediumMonitor. Unref when it is not needed anymore.
 
578
 **/
 
579
BraseroMediumMonitor *
 
580
brasero_medium_monitor_get_default (void)
 
581
{
 
582
        if (singleton) {
 
583
                g_object_ref (singleton);
 
584
                return singleton;
 
585
        }
 
586
 
 
587
        singleton = g_object_new (BRASERO_TYPE_MEDIUM_MONITOR, NULL);
 
588
 
 
589
        /* keep a reference */
 
590
        g_object_ref (singleton);
 
591
        return singleton;
 
592
}