[goobox] allow to start with no drive, fixed drive change in the preferences



commit af3caa5fdf7f49a244f739a3e463f77e7a1edfe0
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Feb 15 21:19:23 2015 +0100

    allow to start with no drive, fixed drive change in the preferences

 src/goo-player.c |   28 ++++++++++++++++++----------
 src/goo-window.c |    3 +--
 2 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/src/goo-player.c b/src/goo-player.c
index e49bcbf..4e211af 100644
--- a/src/goo-player.c
+++ b/src/goo-player.c
@@ -318,10 +318,12 @@ goo_player_set_state (GooPlayer       *self,
                      GooPlayerState   state,
                      gboolean         notify)
 {
-       if (state == GOO_PLAYER_STATE_PLAYING)
-               brasero_drive_lock (self->priv->drive, _("Playing CD"), NULL);
-       else
-               brasero_drive_unlock (self->priv->drive);
+       if (self->priv->drive != NULL) {
+               if (state == GOO_PLAYER_STATE_PLAYING)
+                       brasero_drive_lock (self->priv->drive, _("Playing CD"), NULL);
+               else
+                       brasero_drive_unlock (self->priv->drive);
+       }
 
        self->priv->state = state;
        if (notify)
@@ -477,8 +479,6 @@ goo_player_new (BraseroDrive *drive)
 {
        GooPlayer *self;
 
-       g_return_val_if_fail (drive != NULL, NULL);
-
        self = GOO_PLAYER (g_object_new (GOO_TYPE_PLAYER, NULL));
        goo_player_set_drive (self, drive);
 
@@ -743,17 +743,25 @@ void
 goo_player_set_drive (GooPlayer    *self,
                      BraseroDrive *drive)
 {
-       g_return_if_fail (drive != NULL);
+       if (self->priv->drive == drive)
+               return;
 
        if (self->priv->drive != NULL) {
-               if (self->priv->medium_added_event != 0)
+               if (self->priv->medium_added_event != 0) {
                        g_signal_handler_disconnect (self->priv->drive, self->priv->medium_added_event);
-               if (self->priv->medium_removed_event != 0)
+                       self->priv->medium_added_event = 0;
+               }
+               if (self->priv->medium_removed_event != 0) {
                        g_signal_handler_disconnect (self->priv->drive, self->priv->medium_removed_event);
+                       self->priv->medium_removed_event = 0;
+               }
                g_object_unref (self->priv->drive);
        }
 
-       self->priv->drive = g_object_ref (drive);
+       self->priv->drive = _g_object_ref (drive);
+       if (self->priv->drive == NULL)
+               return;
+
        self->priv->medium_added_event =
                        g_signal_connect (self->priv->drive,
                                          "medium-added",
diff --git a/src/goo-window.c b/src/goo-window.c
index ea4b1ab..c95ac72 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -2319,8 +2319,6 @@ goo_window_new (BraseroDrive *drive)
                g_free (default_device);
        }
 
-       g_return_val_if_fail (drive != NULL, NULL);
-
        window = (GooWindow*) g_object_new (GOO_TYPE_WINDOW, NULL);
        goo_window_construct (window, drive);
 
@@ -2521,6 +2519,7 @@ goo_window_set_drive (GooWindow    *window,
                      BraseroDrive *drive)
 {
        goo_player_set_drive (window->priv->player, drive);
+       goo_player_update (window->priv->player);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]