[goobox] allow to change drive
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goobox] allow to change drive
- Date: Sat, 14 Nov 2009 12:21:53 +0000 (UTC)
commit 918699ebe667a3aabc4051982d4ec66ba272c44d
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Nov 14 13:00:29 2009 +0100
allow to change drive
src/dlg-preferences.c | 15 +++-----
src/goo-player.c | 92 +++++++++++++++++++++++++-----------------------
src/goo-player.h | 7 +++-
src/goo-window.c | 22 +++---------
src/goo-window.h | 4 +-
src/main.c | 79 ++++++++----------------------------------
src/main.h | 15 +++-----
7 files changed, 87 insertions(+), 147 deletions(-)
---
diff --git a/src/dlg-preferences.c b/src/dlg-preferences.c
index d993b7e..8141992 100644
--- a/src/dlg-preferences.c
+++ b/src/dlg-preferences.c
@@ -64,8 +64,7 @@ apply_button_clicked_cb (GtkWidget *widget,
DialogData *data)
{
const char *destination;
- BraseroDrive *br_drive;
- const char *device;
+ BraseroDrive *drive;
destination = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
eel_gconf_set_uri (PREF_EXTRACT_DESTINATION, destination);
@@ -76,16 +75,14 @@ apply_button_clicked_cb (GtkWidget *widget,
/**/
- br_drive = brasero_drive_selection_get_active (BRASERO_DRIVE_SELECTION (data->drive_selector));
- if (br_drive == NULL)
+ drive = brasero_drive_selection_get_active (BRASERO_DRIVE_SELECTION (data->drive_selector));
+ if (drive == NULL)
return;
- device = brasero_drive_get_device (br_drive);
- eel_gconf_set_string (PREF_GENERAL_DEVICE, device);
- goo_window_set_device (data->window, device);
- goo_window_update (data->window);
+ eel_gconf_set_string (PREF_GENERAL_DEVICE, brasero_drive_get_device (drive));
+ goo_window_set_drive (data->window, drive);
- g_object_unref (br_drive);
+ g_object_unref (drive);
}
diff --git a/src/goo-player.c b/src/goo-player.c
index 130ed7d..292517d 100644
--- a/src/goo-player.c
+++ b/src/goo-player.c
@@ -51,6 +51,7 @@ struct _GooPlayerPrivate {
double volume_value;
gboolean is_busy;
gboolean audio_cd;
+ gboolean hibernate;
GstElement *pipeline;
GstElement *source;
@@ -194,9 +195,6 @@ create_pipeline (GooPlayer *self)
destroy_pipeline (self, FALSE);
- /*remove_state_polling (self);
- goo_cdrom_lock_tray (self->priv->cdrom); FIXME */
-
self->priv->pipeline = gst_pipeline_new ("pipeline");
/*self->priv->source = gst_element_make_from_uri (GST_URI_SRC, "cdda://1", "source");*/
@@ -260,11 +258,10 @@ goo_player_set_state (GooPlayer *self,
GooPlayerState state,
gboolean notify)
{
- /* FIXME
if (state == GOO_PLAYER_STATE_PLAYING)
brasero_drive_lock (self->priv->drive, _("Playing CD"), NULL);
else
- brasero_drive_unlock (self->priv->drive);*/
+ brasero_drive_unlock (self->priv->drive);
self->priv->state = state;
if (notify)
@@ -341,6 +338,7 @@ goo_player_init (GooPlayer *self)
self->priv->state = GOO_PLAYER_STATE_LISTING;
self->priv->action = GOO_PLAYER_ACTION_NONE;
self->priv->is_busy = FALSE;
+ self->priv->hibernate = FALSE;
self->priv->yes_or_no = g_mutex_new ();
self->priv->check_id = 0;
self->priv->exiting = FALSE,
@@ -399,9 +397,7 @@ drive_medium_removed_cb (BraseroDrive *drive,
BraseroMedium *medium,
gpointer user_data)
{
- GooPlayer *self = user_data;
-
- goo_player_update (self);
+ goo_player_update ((GooPlayer *) user_data);
}
@@ -413,17 +409,7 @@ goo_player_new (BraseroDrive *drive)
g_return_val_if_fail (drive != NULL, NULL);
self = GOO_PLAYER (g_object_new (GOO_TYPE_PLAYER, NULL));
- self->priv->drive = g_object_ref (drive);
- self->priv->medium_added_event =
- g_signal_connect (self->priv->drive,
- "medium-added",
- G_CALLBACK (drive_medium_added_cb),
- self);
- self->priv->medium_removed_event =
- g_signal_connect (self->priv->drive,
- "medium-removed",
- G_CALLBACK (drive_medium_removed_cb),
- self);
+ goo_player_set_drive (self, drive);
return self;
}
@@ -766,10 +752,28 @@ goo_player_is_audio_cd (GooPlayer *self)
void
+goo_player_hibernate (GooPlayer *self,
+ gboolean hibernate)
+{
+ self->priv->hibernate = hibernate;
+}
+
+
+gboolean
+goo_player_is_hibernate (GooPlayer *self)
+{
+ return self->priv->hibernate;
+}
+
+
+void
goo_player_update (GooPlayer *self)
{
BraseroMedium *medium;
+ if (self->priv->hibernate)
+ return;
+
self->priv->audio_cd = FALSE;
medium = brasero_drive_get_medium (self->priv->drive);
@@ -916,31 +920,31 @@ goo_player_skip_to (GooPlayer *player,
}
-gboolean
-goo_player_set_device (GooPlayer *player,
- const char *device)
+void
+goo_player_set_drive (GooPlayer *self,
+ BraseroDrive *drive)
{
- /* FIXME
- if (goo_player_get_is_busy (player))
- return TRUE;
-
- debug (DEBUG_INFO, "DEVICE: %s\n", device);
-
- destroy_pipeline (player, FALSE);
- remove_state_polling (player);
-
- player->priv->drive = get_drive_from_device (device);
- if (player->priv->drive != NULL) {
- create_cdrom (player);
- goo_cdrom_set_device (player->priv->cdrom, player->priv->device);
+ g_return_if_fail (drive != NULL);
+
+ if (self->priv->drive != NULL) {
+ 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)
+ g_signal_handler_disconnect (self->priv->drive, self->priv->medium_removed_event);
+ g_object_unref (self->priv->drive);
}
- else
- goo_player_set_state (player, GOO_PLAYER_STATE_ERROR, FALSE);
-
- return TRUE;
- */
- return TRUE;
+ self->priv->drive = g_object_ref (drive);
+ self->priv->medium_added_event =
+ g_signal_connect (self->priv->drive,
+ "medium-added",
+ G_CALLBACK (drive_medium_added_cb),
+ self);
+ self->priv->medium_removed_event =
+ g_signal_connect (self->priv->drive,
+ "medium-removed",
+ G_CALLBACK (drive_medium_removed_cb),
+ self);
}
@@ -1047,7 +1051,7 @@ goo_player_eject (GooPlayer *self)
{
GDrive *gdrive;
- if (self->priv->drive == NULL)
+ if (self->priv->hibernate)
return;
g_signal_emit_by_name (G_OBJECT (self), "start", GOO_PLAYER_ACTION_EJECT);
@@ -1099,9 +1103,9 @@ goo_player_set_audio_volume (GooPlayer *player,
gboolean
-goo_player_get_is_busy (GooPlayer *player)
+goo_player_get_is_busy (GooPlayer *self)
{
- return player->priv->is_busy;
+ return self->priv->is_busy || self->priv->hibernate;
}
diff --git a/src/goo-player.h b/src/goo-player.h
index f6dff79..8ab84c8 100644
--- a/src/goo-player.h
+++ b/src/goo-player.h
@@ -92,9 +92,14 @@ struct _GooPlayerClass
GType goo_player_get_type (void);
GooPlayer * goo_player_new (BraseroDrive *drive);
+void goo_player_set_drive (GooPlayer *player,
+ BraseroDrive *drive);
BraseroDrive * goo_player_get_drive (GooPlayer *player);
const char * goo_player_get_device (GooPlayer *player);
gboolean goo_player_is_audio_cd (GooPlayer *player);
+void goo_player_hibernate (GooPlayer *player,
+ gboolean hibernate);
+gboolean goo_player_is_hibernate (GooPlayer *player);
void goo_player_update (GooPlayer *player);
void goo_player_list (GooPlayer *player);
void goo_player_seek_track (GooPlayer *player,
@@ -108,8 +113,6 @@ void goo_player_stop (GooPlayer *player);
void goo_player_eject (GooPlayer *player);
GooPlayerAction goo_player_get_action (GooPlayer *player);
GooPlayerState goo_player_get_state (GooPlayer *player);
-gboolean goo_player_set_device (GooPlayer *player,
- const char *device);
const char * goo_player_get_discid (GooPlayer *player);
void goo_player_set_album (GooPlayer *player,
AlbumInfo *album);
diff --git a/src/goo-window.c b/src/goo-window.c
index 6b1161a..bd53402 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -2762,12 +2762,10 @@ goo_window_eject (GooWindow *window)
void
-goo_window_set_device (GooWindow *window,
- const char *device)
+goo_window_set_drive (GooWindow *window,
+ BraseroDrive *drive)
{
- goo_player_set_device (window->priv->player, device);
- if (device == NULL)
- window_update_sensitivity (window);
+ goo_player_set_drive (window->priv->player, drive);
}
@@ -3135,17 +3133,7 @@ goo_window_set_hibernate (GooWindow *window,
gboolean hibernate)
{
window->priv->hibernate = hibernate;
-
- if (hibernate) {
- goo_window_set_device (window, NULL);
- }
- else {
- char *device;
-
- device = eel_gconf_get_string (PREF_GENERAL_DEVICE, NULL);
- goo_window_set_device (window, device);
- g_free (device);
-
+ goo_player_hibernate (window->priv->player, hibernate);
+ if (! hibernate)
goo_window_update (window);
- }
}
diff --git a/src/goo-window.h b/src/goo-window.h
index 335f719..80ad083 100644
--- a/src/goo-window.h
+++ b/src/goo-window.h
@@ -73,8 +73,8 @@ void goo_window_pause (GooWindow *window);
void goo_window_prev (GooWindow *window);
void goo_window_next (GooWindow *window);
void goo_window_eject (GooWindow *window);
-void goo_window_set_device (GooWindow *window,
- const char *device);
+void goo_window_set_drive (GooWindow *window,
+ BraseroDrive *drive);
AlbumInfo * goo_window_get_album (GooWindow *window);
GList * goo_window_get_tracks (GooWindow *window,
gboolean selection);
diff --git a/src/main.c b/src/main.c
index 79ecd60..a177694 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,7 +40,7 @@
static NotifyNotification *notification = NULL;
#endif /* ENABLE_NOTIFICATION */
-#define VOLUME_STEP 0.10 /* FIXME */
+#define VOLUME_STEP 0.10
enum {
COMMAND_UNUSED,
@@ -247,23 +247,17 @@ unique_app_message_received_cb (UniqueApp *unique_app,
device = unique_message_data_get_text (message);
if (*device == '\0')
device = NULL;
-
if (device != NULL) {
- /* FIXME
- GooPlayer *player;
- CDDrive *current_drive;
-
- player = goo_window_get_player (GOO_WINDOW (main_window));
- current_drive = goo_player_get_drive (player);
+ BraseroDrive *drive;
- if (current_drive == NULL) {
- main_window = get_window_from_device (device);
- if (main_window == NULL)
- main_window = goo_window_new (device);
- }
+ drive = main_get_drive_for_device (device);
+ main_window = main_get_window_from_device (device);
+ if (main_window == NULL)
+ main_window = goo_window_new (drive);
else
- goo_window_set_device (GOO_WINDOW (main_window), device);
- */
+ goo_window_set_drive (GOO_WINDOW (main_window), drive);
+
+ g_object_unref (drive);
}
}
break;
@@ -460,66 +454,23 @@ int main (int argc, char **argv)
}
-/*
-CDDrive *
-get_drive_from_device (const char *device)
+GtkWidget *
+main_get_window_from_device (const char *device)
{
- CDDrive *result = NULL;
- char *resolved_device = NULL;
- char *resolved_real_device = NULL;
- const char *real_device = NULL;
- GList *scan;
+ GList *scan;
if (device == NULL)
return NULL;
-
- if (resolve_all_symlinks (device, &resolved_device) != GNOME_VFS_OK)
- resolved_device = NULL;
-
- if (resolved_device == NULL)
- return NULL;
-
- device = get_path_from_uri (resolved_device);
- for (scan = Drives; scan; scan = scan->next) {
- CDDrive *drive = scan->data;
-
- if (drive->device == NULL)
- continue;
- if (resolve_all_symlinks (drive->device, &resolved_real_device) != GNOME_VFS_OK)
- continue;
- real_device = get_path_from_uri (resolved_real_device);
- if (strcmp (real_device, device) == 0) {
- result = drive;
- break;
- }
- }
-
- g_free (resolved_device);
-
- return result;
-}
-
-
-GtkWindow *
-get_window_from_device (const char *device)
-{
- CDDrive *device_drive;
- GList *scan;
-
- device_drive = get_drive_from_device (device);
- if (device_drive == NULL)
- return NULL;
for (scan = window_list; scan; scan = scan->next) {
GooWindow *window = scan->data;
- if (goo_player_get_drive (goo_window_get_player (window)) == device_drive)
- return (GtkWindow *) window;
+ if (g_strcmp0 (goo_player_get_device (goo_window_get_player (window)), device) == 0)
+ return (GtkWidget *) window;
}
return NULL;
}
-*/
BraseroDrive *
diff --git a/src/main.h b/src/main.h
index ad8d327..659315a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -31,14 +31,11 @@ extern GList *window_list;
extern int AutoPlay;
extern int HideShow;
-/*
-CDDrive * get_drive_from_device (const char *device);
-GtkWindow * get_window_from_device (const char *device);
-*/
-BraseroDrive * main_get_most_likely_drive (void);
-BraseroDrive * main_get_drive_for_device (const char *device);
-void system_notify (GooWindow *window,
- const char *title,
- const char *msg);
+GtkWidget * main_get_window_from_device (const char *device);
+BraseroDrive * main_get_most_likely_drive (void);
+BraseroDrive * main_get_drive_for_device (const char *device);
+void system_notify (GooWindow *window,
+ const char *title,
+ const char *msg);
#endif /* MAIN_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]