~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to shell/rb-shell.c

Tags: upstream-0.9.2cvs20060102
ImportĀ upstreamĀ versionĀ 0.9.2cvs20060102

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
 
/*
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 
2
 *
3
3
 *  arch-tag: Implementation of main Rhythmbox shell
4
4
 *
5
5
 *  Copyright (C) 2002, 2003 Jorn Baayen
21
21
 *
22
22
 */
23
23
 
24
 
#include <gtk/gtk.h>
 
24
#include <config.h>
 
25
 
 
26
#include <string.h>
 
27
#include <ctype.h>
 
28
#include <stdio.h>
 
29
#include <sys/stat.h>
 
30
 
 
31
#include <glib/gi18n.h>
25
32
#include <gdk/gdk.h>
26
33
#include <gdk/gdkx.h>
 
34
#include <gtk/gtk.h>
 
35
 
27
36
#include <X11/Xatom.h>
28
 
#include <config.h>
 
37
 
29
38
#include <libgnome/libgnome.h>
30
39
#include <libgnomeui/gnome-stock-icons.h>
31
 
#include <libgnome/gnome-i18n.h>
32
40
#include <libgnome/gnome-init.h>
33
41
#include <libgnome/gnome-program.h>
34
42
#include <libgnomeui/gnome-window-icon.h>
35
43
#include <libgnomeui/gnome-client.h>
 
44
 
36
45
#include <libgnomevfs/gnome-vfs.h>
37
46
#include <libgnomevfs/gnome-vfs-mime-utils.h>
38
 
#include <string.h>
39
 
#include <ctype.h>
40
 
#include <stdio.h>
41
 
#include <sys/stat.h>
42
47
 
43
48
#include "rb-shell.h"
44
49
#include "rb-debug.h"
73
78
#include "rb-daap-sharing.h"
74
79
#endif /* WITH_DAAP_SUPPORT */
75
80
#include "rb-load-failure-dialog.h"
76
 
#include "rb-station-properties-dialog.h"
77
81
#include "rb-iradio-source.h"
 
82
#include "rb-new-station-dialog.h"
78
83
#include "rb-new-podcast-dialog.h"
79
84
#include "rb-shell-preferences.h"
80
85
#include "rb-playlist-source.h"
 
86
#include "rb-play-queue-source.h"
81
87
#include "eel-gconf-extensions.h"
 
88
#include "bacon-volume.h"
82
89
 
83
90
#ifdef WITH_AUDIOSCROBBLER
84
91
#include "rb-audioscrobbler.h"
87
94
static void rb_shell_class_init (RBShellClass *klass);
88
95
static void rb_shell_remote_proxy_init (RBRemoteProxyIface *iface);
89
96
static void rb_shell_init (RBShell *shell);
90
 
static GObject *rb_shell_constructor (GType type, guint n_construct_properties,
 
97
static GObject *rb_shell_constructor (GType type,
 
98
                                      guint n_construct_properties,
91
99
                                      GObjectConstructParam *construct_properties);
92
100
static void rb_shell_finalize (GObject *object);
93
101
static void rb_shell_set_property (GObject *object,
109
117
                                           RBShell *shell);
110
118
static void rb_shell_sync_window_state (RBShell *shell, gboolean dont_maximise);
111
119
static void rb_shell_sync_paned (RBShell *shell);
 
120
static void rb_shell_sync_fullscreen (RBShell *shell);
112
121
static void rb_shell_select_source (RBShell *shell, RBSource *source);
113
122
static RBSource *rb_shell_get_source_by_entry_type (RBShell *shell, 
114
123
                                                    RhythmDBEntryType type);
121
130
static void rb_shell_playing_entry_changed_cb (RBShellPlayer *player,
122
131
                                               RhythmDBEntry *entry,
123
132
                                               RBShell *shell);
 
133
static void rb_shell_playing_from_queue_cb (RBShellPlayer *player,
 
134
                                            gboolean from_queue,
 
135
                                            RBShell *shell);
124
136
static void source_activated_cb (RBSourceList *sourcelist,
125
137
                                 RBSource *source,
126
138
                                 RBShell *shell);
127
 
static void rb_shell_db_error_cb (RhythmDB *db,
128
 
                                  const char *uri, const char *msg,
129
 
                                  RBShell *shell); 
 
139
static void rb_shell_db_load_error_cb (RhythmDB *db,
 
140
                                       const char *uri, const char *msg,
 
141
                                       RBShell *shell); 
 
142
static void rb_shell_db_save_error_cb (RhythmDB *db,
 
143
                                       const char *uri, const GError *error,
 
144
                                       RBShell *shell); 
130
145
static void rb_shell_db_entry_added_cb (RhythmDB *db,
131
146
                                        RhythmDBEntry *entry,
132
147
                                        RBShell *shell);
183
198
                                   RBShell *shell);
184
199
static void rb_shell_view_sourcelist_changed_cb (GtkAction *action,
185
200
                                                 RBShell *shell);
 
201
static void rb_shell_view_toolbar_changed_cb (GtkAction *action,
 
202
                                              RBShell *shell);
 
203
static void rb_shell_view_fullscreen_changed_cb (GtkAction *action,
 
204
                                                 RBShell *shell);
186
205
static void rb_shell_view_smalldisplay_changed_cb (GtkAction *action,
187
206
                                                 RBShell *shell);
 
207
static void rb_shell_view_queue_as_sidebar_changed_cb (GtkAction *action,
 
208
                                                       RBShell *shell);
188
209
static void rb_shell_load_complete_cb (RhythmDB *db, RBShell *shell);
189
210
static void rb_shell_sync_sourcelist_visibility (RBShell *shell);
 
211
static void rb_shell_sync_toolbar_visibility (RBShell *shell);
190
212
static void rb_shell_sync_smalldisplay (RBShell *shell);
 
213
static void rb_shell_sync_pane_visibility (RBShell *shell);
191
214
static void sourcelist_visibility_changed_cb (GConfClient *client,
192
215
                                              guint cnxn_id,
193
216
                                              GConfEntry *entry,
194
217
                                              RBShell *shell);
 
218
static void toolbar_visibility_changed_cb (GConfClient *client,
 
219
                                           guint cnxn_id,
 
220
                                           GConfEntry *entry,
 
221
                                           RBShell *shell);
195
222
static void smalldisplay_changed_cb (GConfClient *client,
196
223
                                     guint cnxn_id,
197
224
                                     GConfEntry *entry,
198
225
                                     RBShell *shell);
 
226
static void fullscreen_changed_cb (GConfClient *client,
 
227
                                   guint cnxn_id,
 
228
                                   GConfEntry *entry,
 
229
                                   RBShell *shell);
199
230
static void sourcelist_drag_received_cb (RBSourceList *sourcelist,
200
231
                                         RBSource *source,
201
232
                                         GtkSelectionData *data,
253
284
static void paned_size_allocate_cb (GtkWidget *widget,
254
285
                                    GtkAllocation *allocation,
255
286
                                    RBShell *shell);
 
287
static void sidebar_paned_size_allocate_cb (GtkWidget *widget,
 
288
                                            GtkAllocation *allocation,
 
289
                                            RBShell *shell);
 
290
static void rb_shell_volume_widget_changed_cb (BaconVolumeButton *vol,
 
291
                                               RBShell *shell);
256
292
 
257
293
static void session_die_cb (GnomeClient *client, RBShell *shell);
258
294
static void rb_shell_session_init (RBShell *shell);
269
305
        PROP_SELECTED_SOURCE,
270
306
        PROP_DB,
271
307
        PROP_UI_MANAGER,
 
308
        PROP_CLIPBOARD,
272
309
        PROP_PLAYLIST_MANAGER,
273
 
        PROP_WINDOW
 
310
        PROP_WINDOW,
 
311
        PROP_PREFS,
274
312
};
275
313
 
276
314
/* prefs */
282
320
#define CONF_STATE_ADD_DIR          CONF_PREFIX "/state/add_dir"
283
321
#define CONF_STATE_WINDOW_X_POSITION CONF_PREFIX "/state/window_x_position"
284
322
#define CONF_STATE_WINDOW_Y_POSITION CONF_PREFIX "/state/window_y_position"
 
323
#define CONF_STATE_SOURCELIST_HEIGHT CONF_PREFIX "/state/sourcelist_height"
285
324
 
286
325
 
287
326
G_DEFINE_TYPE_EXTENDED (RBShell, 
304
343
        GtkWidget *paned;
305
344
        GtkWidget *sourcelist;
306
345
        GtkWidget *notebook;
307
 
        GtkWidget *hsep;
 
346
        GtkWidget *queue_paned;
 
347
        GtkWidget *queue_sidebar;
308
348
 
309
349
        GList *sources;
310
350
        GHashTable *sources_hash;
311
351
 
312
352
        guint async_state_save_id;
 
353
        guint save_playlist_id;
 
354
        guint save_db_id;
313
355
 
314
356
        gboolean shutting_down;
315
357
        gboolean load_complete;
338
380
        RBLibrarySource *library_source;
339
381
        RBIRadioSource *iradio_source;
340
382
        RBPodcastSource *podcast_source;
 
383
        RBPlaylistSource *queue_source;
341
384
 
342
385
#ifdef WITH_AUDIOSCROBBLER
343
386
        RBAudioscrobbler *audioscrobbler;
348
391
        GtkWidget *prefs;
349
392
 
350
393
        RBTrayIcon *tray_icon;
 
394
        GtkTooltips *tooltips;
 
395
        GtkWidget *volume_button;
351
396
 
352
397
        char *cached_title;
353
398
        char *cached_duration;
 
399
        gboolean cached_playing;
354
400
 
355
401
        guint sourcelist_visibility_notify_id;
 
402
        guint toolbar_visibility_notify_id;
356
403
        guint smalldisplay_notify_id;
 
404
        guint fullscreen_notify_id;
357
405
 
358
406
        glong last_small_time; /* when we last changed small mode */
359
407
        
361
409
         *
362
410
         * To avoid race conditions, the only time the keys are actually read is at startup
363
411
         */
364
 
        guint window_width, window_height, small_width;
365
 
        gboolean window_maximised, window_small;
366
 
        gint window_x, window_y;
 
412
        guint window_width;
 
413
        guint window_height;
 
414
        guint small_width;
 
415
        gboolean window_maximised;
 
416
        gboolean window_small;
 
417
        gboolean window_fullscreen;
 
418
        gboolean queue_as_sidebar;
 
419
        gint window_x;
 
420
        gint window_y;
367
421
        gint paned_position;
 
422
        gint sourcelist_height;
368
423
};
369
424
 
 
425
#define RB_SHELL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_SHELL, RBShellPrivate))
 
426
 
370
427
static GtkActionEntry rb_shell_actions [] =
371
428
{
372
429
        { "Music", NULL, N_("_Music") },
423
480
        { "ViewSourceList", NULL, N_("Source _List"), "<control>L",
424
481
          N_("Change the visibility of the source list"),
425
482
          G_CALLBACK (rb_shell_view_sourcelist_changed_cb), TRUE },
 
483
        { "ViewToolbar", NULL, N_("_Toolbar"), "<control>T",
 
484
          N_("Change the visibility of the toolbar"),
 
485
          G_CALLBACK (rb_shell_view_toolbar_changed_cb), TRUE },
426
486
        { "ViewSmallDisplay", NULL, N_("_Small Display"), "<control>D",
427
487
          N_("Make the main window smaller"),
428
 
          G_CALLBACK (rb_shell_view_smalldisplay_changed_cb),
429
 
        }
 
488
          G_CALLBACK (rb_shell_view_smalldisplay_changed_cb), },
 
489
        { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
 
490
          N_("Expand the window to fill the screen"),
 
491
          G_CALLBACK (rb_shell_view_fullscreen_changed_cb), FALSE },
 
492
        { "ViewQueueAsSidebar", NULL, N_("_Queue as Sidebar"), "<control>K",
 
493
          N_("Change whether the queue is visible as a source or a sidebar"),
 
494
          G_CALLBACK (rb_shell_view_queue_as_sidebar_changed_cb) },
430
495
};
431
496
static guint rb_shell_n_toggle_entries = G_N_ELEMENTS (rb_shell_toggle_entries);
432
497
 
514
579
                                                              "GtkUIManager object", 
515
580
                                                              GTK_TYPE_UI_MANAGER,
516
581
                                                               G_PARAM_READABLE));
 
582
 
 
583
        g_object_class_install_property (object_class,
 
584
                                         PROP_CLIPBOARD,
 
585
                                         g_param_spec_object ("clipboard",
 
586
                                                              "RBShellClipboard",
 
587
                                                              "RBShellClipboard object",
 
588
                                                              RB_TYPE_SHELL_CLIPBOARD,
 
589
                                                              G_PARAM_READABLE));
517
590
        g_object_class_install_property (object_class,
518
591
                                         PROP_PLAYLIST_MANAGER,
519
592
                                         g_param_spec_object ("playlist-manager",
528
601
                                                              "GtkWindow object", 
529
602
                                                              GTK_TYPE_WINDOW,
530
603
                                                              G_PARAM_READABLE));
531
 
 
 
604
        g_object_class_install_property (object_class,
 
605
                                         PROP_PREFS,
 
606
                                         g_param_spec_object ("prefs", 
 
607
                                                              "RBShellPreferences", 
 
608
                                                              "RBShellPreferences object", 
 
609
                                                              RB_TYPE_SHELL_PREFERENCES,
 
610
                                                              G_PARAM_READABLE));
 
611
 
 
612
 
 
613
        g_type_class_add_private (klass, sizeof (RBShellPrivate));
532
614
}
533
615
 
534
616
static void
578
660
{
579
661
        char *file;
580
662
        
581
 
        shell->priv = g_new0 (RBShellPrivate, 1);
 
663
        shell->priv = RB_SHELL_GET_PRIVATE (shell);
582
664
 
583
665
        rb_dot_dir ();
584
666
 
664
746
        case PROP_UI_MANAGER:
665
747
                g_value_set_object (value, shell->priv->ui_manager);
666
748
                break;
 
749
        case PROP_CLIPBOARD:
 
750
                g_value_set_object (value, shell->priv->clipboard_shell);
 
751
                break;
667
752
        case PROP_PLAYLIST_MANAGER:
668
753
                g_value_set_object (value, shell->priv->playlist_manager);
669
754
                break;
673
758
        case PROP_WINDOW:
674
759
                g_value_set_object (value, shell->priv->window);
675
760
                break;  
 
761
        case PROP_PREFS:
 
762
                g_value_set_object (value, shell->priv->prefs);
 
763
                break;  
676
764
        default:
677
765
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
678
766
                break;
701
789
}
702
790
 
703
791
static gboolean
704
 
idle_save_rhythmdb (RhythmDB *db)
 
792
idle_save_rhythmdb (RBShell *shell)
705
793
{
706
 
        rhythmdb_save (db);
 
794
        rhythmdb_save (shell->priv->db);
707
795
        
 
796
        shell->priv->save_db_id = 0;
 
797
 
708
798
        return FALSE;
709
799
}
710
800
 
711
801
static gboolean
712
802
idle_save_playlist_manager (RBPlaylistManager *mgr)
713
803
{
714
 
        rb_playlist_manager_save_playlists (mgr, FALSE);
 
804
        rb_playlist_manager_save_playlists_async (mgr, FALSE);
715
805
 
716
806
        return TRUE;
717
807
}
737
827
{
738
828
        RBShell *shell = RB_SHELL (object);
739
829
 
740
 
        gtk_widget_hide (shell->priv->window);
741
 
        gtk_widget_hide (GTK_WIDGET (shell->priv->tray_icon));
 
830
        rb_debug ("Finalizing shell");
 
831
 
742
832
        rb_shell_player_stop (shell->priv->player_shell);
743
833
 
744
834
        eel_gconf_monitor_remove (CONF_PREFIX);
 
835
        eel_gconf_notification_remove (shell->priv->sourcelist_visibility_notify_id);
 
836
        eel_gconf_notification_remove (shell->priv->toolbar_visibility_notify_id);
 
837
        eel_gconf_notification_remove (shell->priv->smalldisplay_notify_id);
 
838
        eel_gconf_notification_remove (shell->priv->fullscreen_notify_id);
745
839
 
746
840
        gtk_widget_destroy (GTK_WIDGET (shell->priv->load_error_dialog));
747
841
        g_list_free (shell->priv->supported_media_extensions);
748
842
 
749
843
        gtk_widget_destroy (GTK_WIDGET (shell->priv->tray_icon));
750
844
 
751
 
        g_list_free (shell->priv->sources);
752
 
 
753
 
        g_hash_table_destroy (shell->priv->sources_hash);
754
 
 
 
845
        if (shell->priv->save_playlist_id > 0) {
 
846
                g_source_remove (shell->priv->save_playlist_id);
 
847
                shell->priv->save_playlist_id = 0;
 
848
        }
 
849
 
 
850
        if (shell->priv->save_db_id > 0) {
 
851
                g_source_remove (shell->priv->save_db_id);
 
852
                shell->priv->save_db_id = 0;
 
853
        }
 
854
 
 
855
        rb_debug ("shutting down playlist manager");
 
856
        rb_playlist_manager_shutdown (shell->priv->playlist_manager);
 
857
 
 
858
        rb_debug ("unreffing playlist manager");
755
859
        g_object_unref (G_OBJECT (shell->priv->playlist_manager));
 
860
 
 
861
        rb_debug ("unreffing removable media manager");
756
862
        g_object_unref (G_OBJECT (shell->priv->removable_media_manager));
757
863
 
758
864
#ifdef WITH_AUDIOSCROBBLER
 
865
        rb_debug ("unreffing audioscrobbler");
759
866
        g_object_unref (G_OBJECT (shell->priv->audioscrobbler));
760
867
#endif
761
868
        
 
869
        rb_debug ("unreffing clipboard shell");
762
870
        g_object_unref (G_OBJECT (shell->priv->clipboard_shell));
763
871
 
764
 
        gtk_widget_destroy (shell->priv->window);
765
 
 
766
 
        
767
 
        eel_gconf_notification_remove (shell->priv->sourcelist_visibility_notify_id);
768
 
        eel_gconf_notification_remove (shell->priv->smalldisplay_notify_id);
769
 
 
770
872
        rb_debug ("shutting down DB");
771
873
        rhythmdb_shutdown (shell->priv->db);
772
874
 
773
875
        rb_debug ("unreffing DB");
774
876
        g_object_unref (G_OBJECT (shell->priv->db));
775
877
 
 
878
        rb_debug ("destroying prefs");
776
879
        if (shell->priv->prefs != NULL)
777
880
                gtk_widget_destroy (shell->priv->prefs);
 
881
 
 
882
        rb_debug ("destroying tooltips");
 
883
        gtk_object_destroy (GTK_OBJECT (shell->priv->tooltips));
778
884
        
779
885
        g_free (shell->priv->rhythmdb_file);
780
 
        g_free (shell->priv);
 
886
 
 
887
        rb_debug ("destroying window");
 
888
        gtk_widget_destroy (shell->priv->window);
 
889
 
 
890
        g_list_free (shell->priv->sources);
 
891
        shell->priv->sources = NULL;
 
892
 
 
893
        g_hash_table_destroy (shell->priv->sources_hash);
781
894
 
782
895
        ((GObjectClass*)rb_shell_parent_class)->finalize (G_OBJECT (shell));
783
896
 
807
920
        GtkWindow *win;
808
921
        GtkWidget *menubar;
809
922
        GtkWidget *vbox;
810
 
        gboolean rhythmdb_exists;
811
923
        GError *error = NULL;
 
924
        GtkWidget *toolbar;
 
925
        GtkWidget *hbox;
 
926
        GtkToolItem *tool_item;
812
927
 
813
928
        shell = RB_SHELL (((GObjectClass*)rb_shell_parent_class)
814
929
                ->constructor (type, n_construct_properties, construct_properties));
855
970
                else
856
971
                        pathname = g_build_filename (rb_dot_dir (), "rhythmdb.xml", NULL);
857
972
 
858
 
                rhythmdb_exists = g_file_test (pathname, G_FILE_TEST_EXISTS);
859
 
                
860
973
#ifdef WITH_RHYTHMDB_TREE
861
974
                shell->priv->db = rhythmdb_tree_new (pathname);
862
975
#elif defined(WITH_RHYTHMDB_GDA)
869
982
                if (shell->priv->no_update)
870
983
                        g_object_set (G_OBJECT (shell->priv->db), "no-update", TRUE, NULL);
871
984
 
872
 
                if (rhythmdb_exists) {
873
 
                        g_signal_connect_object (G_OBJECT (shell->priv->db), "load-complete",
874
 
                                                 G_CALLBACK (rb_shell_load_complete_cb), shell,
875
 
                                                 0);
876
 
                } else {
877
 
                        shell->priv->load_complete = TRUE;
878
 
                }
 
985
                g_signal_connect_object (G_OBJECT (shell->priv->db), "load-complete",
 
986
                                         G_CALLBACK (rb_shell_load_complete_cb), shell,
 
987
                                         0);
879
988
        }
880
989
 
881
990
        rb_debug ("shell: setting up tray icon");
896
1005
                                 G_CALLBACK (rb_shell_playing_entry_changed_cb),
897
1006
                                 shell, 0);
898
1007
        g_signal_connect_object (G_OBJECT (shell->priv->player_shell),
 
1008
                                 "playing-from-queue",
 
1009
                                 G_CALLBACK (rb_shell_playing_from_queue_cb),
 
1010
                                 shell, 0);
 
1011
        g_signal_connect_object (G_OBJECT (shell->priv->player_shell),
899
1012
                                 "window_title_changed",
900
1013
                                 G_CALLBACK (rb_shell_player_window_title_changed_cb),
901
1014
                                 shell, 0);
906
1019
        shell->priv->clipboard_shell = rb_shell_clipboard_new (shell->priv->actiongroup,
907
1020
                                                               shell->priv->db);
908
1021
        shell->priv->source_header = rb_source_header_new (shell->priv->actiongroup);
 
1022
        gtk_widget_show_all (GTK_WIDGET (shell->priv->source_header));
909
1023
 
910
1024
        shell->priv->paned = gtk_hpaned_new ();
911
1025
 
912
1026
        shell->priv->sourcelist = rb_sourcelist_new (shell);
 
1027
        gtk_widget_show_all (shell->priv->sourcelist);
913
1028
        g_signal_connect_object (G_OBJECT (shell->priv->sourcelist), "drop_received",
914
1029
                                 G_CALLBACK (sourcelist_drag_received_cb), shell, 0);
915
1030
        g_signal_connect_object (G_OBJECT (shell->priv->sourcelist), "source_activated",
921
1036
                                                   shell->priv->actiongroup,
922
1037
                                                   shell->priv->player_shell);
923
1038
        g_object_set (shell->priv->player_shell, "statusbar", shell->priv->statusbar, NULL);
 
1039
        gtk_widget_show (GTK_WIDGET (shell->priv->statusbar));
924
1040
 
925
1041
        g_signal_connect_object (G_OBJECT (shell->priv->sourcelist), "selected",
926
1042
                                 G_CALLBACK (source_selected_cb), shell, 0);
927
1043
 
928
1044
        vbox = gtk_vbox_new (FALSE, 4);
929
1045
        shell->priv->notebook = gtk_notebook_new ();
 
1046
        gtk_widget_show (vbox);
 
1047
        gtk_widget_show (shell->priv->notebook);
930
1048
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (shell->priv->notebook), FALSE);
931
1049
        gtk_notebook_set_show_border (GTK_NOTEBOOK (shell->priv->notebook), FALSE);
932
1050
        g_signal_connect_object (G_OBJECT (shell->priv->sourcelist),
933
1051
                                 "size-allocate",
934
1052
                                 G_CALLBACK (paned_size_allocate_cb),
935
1053
                                 shell, 0);
936
 
 
937
 
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (shell->priv->source_header), FALSE, TRUE, 0);
938
 
        gtk_box_pack_start_defaults (GTK_BOX (vbox), shell->priv->notebook);
939
 
 
940
 
        gtk_paned_pack1 (GTK_PANED (shell->priv->paned), 
941
 
                         shell->priv->sourcelist, FALSE, TRUE);
942
 
        gtk_paned_pack2 (GTK_PANED (shell->priv->paned), vbox, TRUE, TRUE);
 
1054
        
 
1055
        shell->priv->queue_source = RB_PLAYLIST_SOURCE (rb_play_queue_source_new (shell));
 
1056
        g_object_set (G_OBJECT(shell->priv->player_shell), "queue-source", shell->priv->queue_source, NULL);
 
1057
        g_object_set (G_OBJECT(shell->priv->clipboard_shell), "queue-source", shell->priv->queue_source, NULL);
 
1058
        rb_shell_append_source (shell, RB_SOURCE (shell->priv->queue_source), NULL);
 
1059
        g_object_get (G_OBJECT (shell->priv->queue_source), "sidebar", &shell->priv->queue_sidebar, NULL);
 
1060
        gtk_widget_show_all (shell->priv->queue_sidebar);
 
1061
 
 
1062
        /* set up sidebars */
 
1063
        shell->priv->paned = gtk_hpaned_new ();
 
1064
        {
 
1065
                shell->priv->queue_paned = gtk_vpaned_new ();
 
1066
                {
 
1067
                        gtk_paned_pack1 (GTK_PANED (shell->priv->queue_paned),
 
1068
                                         shell->priv->sourcelist, 
 
1069
                                         FALSE, TRUE);
 
1070
                        gtk_paned_pack2 (GTK_PANED (shell->priv->queue_paned), 
 
1071
                                         shell->priv->queue_sidebar,
 
1072
                                         TRUE, TRUE);
 
1073
                }
 
1074
                GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
 
1075
                {
 
1076
                        gtk_box_pack_start (GTK_BOX (vbox),
 
1077
                                            GTK_WIDGET (shell->priv->source_header),
 
1078
                                            FALSE, FALSE, 0);
 
1079
                        gtk_box_pack_start (GTK_BOX (vbox),
 
1080
                                            shell->priv->notebook,
 
1081
                                            TRUE, TRUE, 0);
 
1082
                }
 
1083
 
 
1084
                gtk_paned_pack1 (GTK_PANED (shell->priv->paned),
 
1085
                                 shell->priv->queue_paned,
 
1086
                                 FALSE, TRUE);
 
1087
                gtk_paned_pack2 (GTK_PANED (shell->priv->paned),
 
1088
                                 vbox,
 
1089
                                 TRUE, TRUE);
 
1090
                gtk_widget_show (vbox);
 
1091
        }
 
1092
        g_signal_connect_object (G_OBJECT (shell->priv->queue_paned),
 
1093
                                 "size-allocate",
 
1094
                                 G_CALLBACK (sidebar_paned_size_allocate_cb),
 
1095
                                 shell, 0);
 
1096
        gtk_widget_show (shell->priv->paned);
943
1097
 
944
1098
        vbox = gtk_vbox_new (FALSE, 0);
945
1099
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
946
 
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (shell->priv->player_shell), FALSE, TRUE, 0);    
947
 
        shell->priv->hsep = gtk_hseparator_new ();
948
 
        gtk_box_pack_start (GTK_BOX (vbox), shell->priv->hsep, FALSE, FALSE, 5);
 
1100
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (shell->priv->player_shell), FALSE, TRUE, 6);    
 
1101
        gtk_widget_show (GTK_WIDGET (shell->priv->player_shell));
 
1102
 
949
1103
        gtk_box_pack_start (GTK_BOX (vbox), shell->priv->paned, TRUE, TRUE, 0);
950
1104
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (shell->priv->statusbar), FALSE, TRUE, 0);
 
1105
        gtk_widget_show (vbox);
951
1106
 
952
1107
        gtk_container_add (GTK_CONTAINER (win), vbox);
953
 
        gtk_widget_show_all (vbox);
954
1108
 
955
1109
#ifdef WITH_AUDIOSCROBBLER
956
1110
        rb_debug ("Audioscrobbler support enabled.");
961
1115
        /* sync state */
962
1116
        shell->priv->sourcelist_visibility_notify_id =
963
1117
                eel_gconf_notification_add (CONF_UI_SOURCELIST_HIDDEN,
964
 
                                    (GConfClientNotifyFunc) sourcelist_visibility_changed_cb,
965
 
                                    shell);
 
1118
                                            (GConfClientNotifyFunc) sourcelist_visibility_changed_cb,
 
1119
                                            shell);
 
1120
        shell->priv->toolbar_visibility_notify_id =
 
1121
                eel_gconf_notification_add (CONF_UI_TOOLBAR_HIDDEN,
 
1122
                                            (GConfClientNotifyFunc) toolbar_visibility_changed_cb,
 
1123
                                            shell);
966
1124
        shell->priv->smalldisplay_notify_id =
967
1125
                eel_gconf_notification_add (CONF_UI_SMALL_DISPLAY,
968
 
                                    (GConfClientNotifyFunc) smalldisplay_changed_cb,
969
 
                                    shell);
 
1126
                                            (GConfClientNotifyFunc) smalldisplay_changed_cb,
 
1127
                                            shell);
 
1128
        shell->priv->smalldisplay_notify_id =
 
1129
                eel_gconf_notification_add (CONF_UI_FULLSCREEN,
 
1130
                                            (GConfClientNotifyFunc) fullscreen_changed_cb,
 
1131
                                            shell);
970
1132
 
971
1133
        /* read the cached copies of the gconf keys */
972
1134
        shell->priv->window_width = eel_gconf_get_integer (CONF_STATE_WINDOW_WIDTH);
974
1136
        shell->priv->small_width = eel_gconf_get_integer (CONF_STATE_SMALL_WIDTH);
975
1137
        shell->priv->window_maximised = eel_gconf_get_boolean (CONF_STATE_WINDOW_MAXIMIZED);
976
1138
        shell->priv->window_small = eel_gconf_get_boolean (CONF_UI_SMALL_DISPLAY);
 
1139
        shell->priv->window_fullscreen = eel_gconf_get_boolean (CONF_UI_FULLSCREEN);
 
1140
        shell->priv->queue_as_sidebar = eel_gconf_get_boolean (CONF_UI_QUEUE_AS_SIDEBAR); 
977
1141
        shell->priv->window_x = eel_gconf_get_integer (CONF_STATE_WINDOW_X_POSITION);
978
1142
        shell->priv->window_y = eel_gconf_get_integer (CONF_STATE_WINDOW_Y_POSITION);
979
1143
        shell->priv->paned_position = eel_gconf_get_integer (CONF_STATE_PANED_POSITION);
 
1144
        shell->priv->sourcelist_height = eel_gconf_get_integer (CONF_STATE_SOURCELIST_HEIGHT);
980
1145
 
981
1146
        
982
1147
        rb_debug ("shell: syncing with gconf");
983
1148
        rb_shell_sync_sourcelist_visibility (shell);
 
1149
        rb_shell_sync_pane_visibility (shell);
984
1150
 
985
1151
        shell->priv->load_error_dialog = rb_load_failure_dialog_new ();
986
1152
        shell->priv->show_db_errors = FALSE;
987
1153
        gtk_widget_hide (shell->priv->load_error_dialog);
988
1154
 
989
 
        g_signal_connect_object (G_OBJECT (shell->priv->db), "error",
990
 
                                 G_CALLBACK (rb_shell_db_error_cb), shell, 0);
 
1155
        g_signal_connect_object (G_OBJECT (shell->priv->db), "load-error",
 
1156
                                 G_CALLBACK (rb_shell_db_load_error_cb), shell, 0);
 
1157
        g_signal_connect_object (G_OBJECT (shell->priv->db), "save-error",
 
1158
                                 G_CALLBACK (rb_shell_db_save_error_cb), shell, 0);
991
1159
        g_signal_connect_object (G_OBJECT (shell->priv->db), "entry-added",
992
1160
                                 G_CALLBACK (rb_shell_db_entry_added_cb), shell, 0);
993
1161
 
1045
1213
        gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
1046
1214
        gtk_box_reorder_child (GTK_BOX (vbox), menubar, 0);
1047
1215
 
 
1216
        hbox = gtk_hbox_new (FALSE, 0);
 
1217
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
1218
        gtk_box_reorder_child (GTK_BOX (vbox), hbox, 1);
 
1219
 
 
1220
        toolbar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar");
 
1221
        gtk_box_pack_start_defaults (GTK_BOX (hbox), toolbar);
 
1222
        rb_shell_sync_toolbar_visibility (shell);
 
1223
 
 
1224
        shell->priv->volume_button = bacon_volume_button_new (GTK_ICON_SIZE_LARGE_TOOLBAR,
 
1225
                                                               0.0, 1.0, 0.02);
 
1226
        g_signal_connect (shell->priv->volume_button, "value-changed",
 
1227
                          G_CALLBACK (rb_shell_volume_widget_changed_cb),
 
1228
                          shell);
 
1229
        bacon_volume_button_set_value (BACON_VOLUME_BUTTON (shell->priv->volume_button),
 
1230
                                       eel_gconf_get_float (CONF_STATE_VOLUME));
 
1231
 
 
1232
 
 
1233
        tool_item = gtk_tool_item_new ();
 
1234
        gtk_tool_item_set_expand (tool_item, TRUE);
 
1235
        gtk_widget_show (GTK_WIDGET (tool_item));
 
1236
        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, -1);
 
1237
        
 
1238
        tool_item = gtk_tool_item_new ();
 
1239
        gtk_container_add (GTK_CONTAINER (tool_item), shell->priv->volume_button);
 
1240
        gtk_widget_show_all (GTK_WIDGET (tool_item));
 
1241
        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, -1);
 
1242
 
 
1243
        gtk_widget_show (hbox);
 
1244
 
 
1245
        shell->priv->tooltips = gtk_tooltips_new ();
 
1246
        gtk_tooltips_enable (shell->priv->tooltips);
 
1247
 
 
1248
        gtk_tooltips_set_tip (GTK_TOOLTIPS (shell->priv->tooltips), 
 
1249
                              GTK_WIDGET (shell->priv->volume_button), 
 
1250
                              _("Change the music volume"), NULL);
 
1251
 
1048
1252
        if (error != NULL) {
1049
1253
                g_warning ("Couldn't merge %s: %s",
1050
1254
                           rb_file ("rhythmbox-ui.xml"), error->message);
1051
1255
                g_clear_error (&error);
1052
1256
        }
1053
1257
 
1054
 
        g_timeout_add (10000, (GSourceFunc) idle_save_playlist_manager, shell->priv->playlist_manager);
 
1258
        shell->priv->save_playlist_id = g_timeout_add (10000, (GSourceFunc) idle_save_playlist_manager, shell->priv->playlist_manager);
1055
1259
        
1056
1260
        rb_shell_sync_window_state (shell, FALSE);
 
1261
        rb_shell_sync_fullscreen (shell);
1057
1262
 
1058
1263
        rb_shell_select_source (shell, RB_SOURCE (shell->priv->library_source));
1059
1264
 
1060
1265
        
1061
1266
        /* GO GO GO! */
1062
 
        if (rhythmdb_exists) {
1063
 
                rb_debug ("loading database");
1064
 
                rhythmdb_load (shell->priv->db);
1065
 
/* Disabled for now */
1066
 
#if 0
1067
 
                rb_debug ("adding db save-when-needed thread");
1068
 
                g_timeout_add (10000, (GSourceFunc) idle_save_rhythmdb, shell->priv->db);
1069
 
#endif
1070
 
        }
 
1267
        rb_debug ("loading database");
 
1268
        rhythmdb_load (shell->priv->db);
1071
1269
        
1072
1270
        rb_debug ("shell: syncing window state");
1073
1271
        rb_shell_sync_paned (shell);
1275
1473
{
1276
1474
        GdkGeometry hints;
1277
1475
 
1278
 
        if (shell->priv->window_small)
1279
 
        {
 
1476
        if (shell->priv->window_small) {
1280
1477
                hints.min_height = -1;
1281
1478
                hints.min_width = -1;
1282
1479
                hints.max_height = -1;
1342
1539
}
1343
1540
 
1344
1541
static void
1345
 
rb_shell_db_error_cb (RhythmDB *db,
1346
 
                      const char *uri, const char *msg,
1347
 
                      RBShell *shell)
 
1542
rb_shell_db_load_error_cb (RhythmDB *db,
 
1543
                           const char *uri, const char *msg,
 
1544
                           RBShell *shell)
1348
1545
{
1349
1546
        rb_debug ("got db error, showing: %s",
1350
1547
                  shell->priv->show_db_errors ? "TRUE" : "FALSE");
1364
1561
}
1365
1562
 
1366
1563
static void
 
1564
rb_shell_db_save_error_cb (RhythmDB *db,
 
1565
                           const char *uri, const GError *error,
 
1566
                           RBShell *shell)
 
1567
{
 
1568
        rb_error_dialog (GTK_WINDOW (shell->priv->window),
 
1569
                         _("Error while saving song information"),
 
1570
                         "%s", error->message);
 
1571
}
 
1572
 
 
1573
static void
1367
1574
rb_shell_db_entry_added_cb (RhythmDB *db,
1368
1575
                            RhythmDBEntry *entry,
1369
1576
                            RBShell *shell)
1469
1676
rb_shell_source_deleted_cb (RBSource *source,
1470
1677
                            RBShell *shell)
1471
1678
{
 
1679
        rb_debug ("source deleted");
 
1680
 
1472
1681
        if (source == rb_shell_player_get_playing_source (shell->priv->player_shell)) {
1473
1682
                rb_shell_player_set_playing_source (shell->priv->player_shell, NULL);
1474
1683
        }
1491
1700
                                    RBShell *shell)
1492
1701
{
1493
1702
        rb_debug ("playing source changed");
1494
 
        rb_sourcelist_set_playing_source (RB_SOURCELIST (shell->priv->sourcelist),
1495
 
                                          source);
 
1703
        if (source != RB_SOURCE (shell->priv->queue_source))
 
1704
                rb_sourcelist_set_playing_source (RB_SOURCELIST (shell->priv->sourcelist),
 
1705
                                                  source);
 
1706
}
 
1707
 
 
1708
static void
 
1709
rb_shell_playing_from_queue_cb (RBShellPlayer *player,
 
1710
                                gboolean from_queue,
 
1711
                                RBShell *shell)
 
1712
{
 
1713
        rb_debug ("playing from queue changed");
 
1714
        /* show queue as playing source, selected source as 'paused' */
 
1715
        rb_sourcelist_preempt_playing_source (RB_SOURCELIST (shell->priv->sourcelist),
 
1716
                                              from_queue ? RB_SOURCE (shell->priv->queue_source) : NULL);
1496
1717
}
1497
1718
 
1498
1719
static void
1572
1793
                                 RB_SOURCE (source));
1573
1794
        rb_playlist_manager_set_source (shell->priv->playlist_manager,
1574
1795
                                        RB_SOURCE (source));
1575
 
#ifdef WITH_AUDIOSCROBBLER
1576
 
        g_object_set (G_OBJECT (shell->priv->audioscrobbler), "shell_player",  RB_SHELL_PLAYER (shell->priv->player_shell), NULL);
1577
 
#endif
1578
1796
        g_object_set (G_OBJECT (shell->priv->removable_media_manager), "source", RB_SOURCE (source), NULL);
1579
1797
}
1580
1798
 
1640
1858
                rb_shell_player_get_playing (shell->priv->player_shell, &playing, NULL);
1641
1859
 
1642
1860
                if (shell->priv->cached_title &&
1643
 
                    !strcmp (shell->priv->cached_title, window_title)) {
 
1861
                    !strcmp (shell->priv->cached_title, window_title) &&
 
1862
                    playing == shell->priv->cached_playing) {
1644
1863
                        return;
1645
1864
                }
1646
1865
                g_free (shell->priv->cached_title);
1647
1866
                shell->priv->cached_title = g_strdup (window_title);
 
1867
                shell->priv->cached_playing = playing;
1648
1868
 
1649
1869
                rb_debug ("setting title to \"%s\"", window_title);
1650
1870
                if (!playing) {
1669
1889
}
1670
1890
 
1671
1891
static void
 
1892
rb_shell_view_toolbar_changed_cb (GtkAction *action,
 
1893
                                  RBShell *shell)
 
1894
{
 
1895
        eel_gconf_set_boolean (CONF_UI_TOOLBAR_HIDDEN,
 
1896
                               !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 
1897
}
 
1898
 
 
1899
static void
1672
1900
rb_shell_view_smalldisplay_changed_cb (GtkAction *action,
1673
1901
                                       RBShell *shell)
1674
1902
{
1686
1914
}
1687
1915
 
1688
1916
static void
 
1917
rb_shell_view_queue_as_sidebar_changed_cb (GtkAction *action,
 
1918
                                           RBShell *shell)
 
1919
{
 
1920
        shell->priv->queue_as_sidebar = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
1921
        eel_gconf_set_boolean (CONF_UI_QUEUE_AS_SIDEBAR, shell->priv->queue_as_sidebar);
 
1922
 
 
1923
        if (shell->priv->queue_as_sidebar && 
 
1924
            shell->priv->selected_source == RB_SOURCE (shell->priv->queue_source)) {
 
1925
                /* queue no longer exists as a source, so change to the library */
 
1926
                rb_shell_select_source (shell, RB_SOURCE (shell->priv->library_source));
 
1927
        }
 
1928
        
 
1929
        rb_shell_sync_pane_visibility (shell);
 
1930
}
 
1931
 
 
1932
static void
 
1933
rb_shell_view_fullscreen_changed_cb (GtkAction *action,
 
1934
                                     RBShell *shell)
 
1935
{
 
1936
        eel_gconf_set_boolean (CONF_UI_FULLSCREEN,
 
1937
                               gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 
1938
}
 
1939
 
 
1940
static void
1689
1941
rb_shell_cmd_about (GtkAction *action,
1690
1942
                    RBShell *shell)
1691
1943
{
1712
1964
 
1713
1965
        const char *translator_credits = _("translator_credits");
1714
1966
 
 
1967
        const char *license[] = {
 
1968
                N_("Rhythmbox is free software; you can redistribute it and/or modify\n"
 
1969
                   "it under the terms of the GNU General Public License as published by\n"
 
1970
                   "the Free Software Foundation; either version 2 of the License, or\n"
 
1971
                   "(at your option) any later version.\n"),
 
1972
                N_("Rhythmbox is distributed in the hope that it will be useful,\n"
 
1973
                   "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
 
1974
                   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 
1975
                   "GNU General Public License for more details.\n"),
 
1976
                N_("You should have received a copy of the GNU General Public License\n"
 
1977
                   "along with Rhythmbox; if not, write to the Free Software Foundation, Inc.,\n"
 
1978
                   "59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n")
 
1979
        };
 
1980
 
 
1981
        char *license_trans;
 
1982
 
1715
1983
        pixbuf = gdk_pixbuf_new_from_file (rb_file ("about-logo.png"), NULL);
1716
1984
 
1717
1985
        authors[0] = _("Maintainers:");
1724
1992
 
1725
1993
        comment = g_string_new (_("Music management and playback software for GNOME."));
1726
1994
 
 
1995
        license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
 
1996
                                     _(license[2]), "\n", NULL);
 
1997
 
1727
1998
        gtk_show_about_dialog (GTK_WINDOW (shell->priv->window),
1728
1999
                               "name", "Rhythmbox",
1729
2000
                               "version", VERSION,
1730
 
                               "copyright", "Copyright \xc2\xa9 2003, 2004 Colin Walters\nCopyright \xc2\xa9 2002, 2003 Jorn Baayen",
 
2001
                               "copyright", "Copyright \xc2\xa9 2005 The Rhythmbox authors\nCopyright \xc2\xa9 2003 - 2005 Colin Walters\nCopyright \xc2\xa9 2002, 2003 Jorn Baayen",
 
2002
                               "license", license_trans,
 
2003
                               "website", "http://www.gnome.org/projects/rhythmbox",
1731
2004
                               "comments", comment->str,
1732
2005
                               "authors", (const char **) authors,
1733
2006
                               "documenters", (const char **) documenters,
1734
2007
                               "translator-credits", strcmp (translator_credits, "translator_credits") != 0 ? translator_credits : NULL,
1735
2008
                               "logo", pixbuf,
1736
2009
                               NULL);
 
2010
 
1737
2011
        g_string_free (comment, TRUE);
 
2012
        g_free (license_trans);
1738
2013
}
1739
2014
 
1740
2015
void
1781
2056
                          RBShell *shell)
1782
2057
{
1783
2058
        if (shell->priv->prefs == NULL) {
1784
 
#ifdef WITH_AUDIOSCROBBLER
1785
 
                shell->priv->prefs = rb_shell_preferences_new (shell->priv->sources,
1786
 
                                                               shell->priv->audioscrobbler);
1787
 
#else
1788
2059
                shell->priv->prefs = rb_shell_preferences_new (shell->priv->sources);
 
2060
#ifdef WITH_AUDIOSCROBBLER
 
2061
                g_object_set (G_OBJECT (shell->priv->audioscrobbler),
 
2062
                              "shell_preferences", shell->priv->prefs,
 
2063
                              NULL);
1789
2064
#endif
1790
2065
 
1791
2066
                gtk_window_set_transient_for (GTK_WINDOW (shell->priv->prefs),
1826
2101
        g_slist_free (uri_list);
1827
2102
        g_free (current_dir);
1828
2103
        gtk_widget_destroy (GTK_WIDGET (dialog));
1829
 
        g_timeout_add (10000, (GSourceFunc) idle_save_rhythmdb, shell->priv->db);
 
2104
 
 
2105
        if (shell->priv->save_db_id > 0) {
 
2106
                g_source_remove (shell->priv->save_db_id);
 
2107
        }
 
2108
        shell->priv->save_db_id = g_timeout_add (10000, (GSourceFunc) idle_save_rhythmdb, shell);
1830
2109
}
1831
2110
 
1832
2111
static void
1839
2118
        dialog = rb_file_chooser_new (_("Import Folder into Library"),
1840
2119
                                      GTK_WINDOW (shell->priv->window),
1841
2120
                                      GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1842
 
                                      TRUE);
 
2121
                                      FALSE);
1843
2122
        if (dir)
1844
2123
                gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
1845
2124
                                                         dir);
1861
2140
        dialog = rb_file_chooser_new (_("Import File into Library"),
1862
2141
                                      GTK_WINDOW (shell->priv->window),
1863
2142
                                      GTK_FILE_CHOOSER_ACTION_OPEN,
1864
 
                                      TRUE);
 
2143
                                      FALSE);
1865
2144
        if (dir)
1866
2145
                gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
1867
2146
                                                         dir);
1874
2153
}
1875
2154
 
1876
2155
static void
 
2156
new_station_location_added (RBNewStationDialog *dialog,
 
2157
                            const char         *uri,
 
2158
                            RBShell            *shell)
 
2159
{
 
2160
        rb_iradio_source_add_from_playlist (shell->priv->iradio_source, uri);
 
2161
}
 
2162
 
 
2163
static void
1877
2164
rb_shell_cmd_new_station (GtkAction *action,
1878
2165
                          RBShell *shell)
1879
2166
{
1880
2167
        GtkWidget *dialog;
1881
2168
        RBEntryView *entry_view = rb_source_get_entry_view (RB_SOURCE (shell->priv->iradio_source));
 
2169
 
1882
2170
        rb_debug ("Got new station command");
1883
 
        dialog = rb_station_properties_dialog_new (entry_view, TRUE);
1884
 
        gtk_widget_show_all (dialog);
 
2171
 
 
2172
        dialog = rb_new_station_dialog_new (entry_view);
 
2173
        g_signal_connect_object (dialog, "location-added",
 
2174
                                 G_CALLBACK (new_station_location_added),
 
2175
                                 shell, 0);
 
2176
 
1885
2177
        gtk_dialog_run (GTK_DIALOG (dialog));
 
2178
 
 
2179
        gtk_widget_destroy (dialog);
1886
2180
}
1887
2181
 
1888
2182
static void
1894
2188
        
1895
2189
        rb_debug ("Got new podcast command");
1896
2190
        g_object_get (G_OBJECT (shell->priv->podcast_source), "podcast-manager", &object, NULL);
1897
 
        dialog = rb_new_podcast_dialog_new ( RB_PODCAST_MANAGER(object));
 
2191
        dialog = rb_new_podcast_dialog_new (RB_PODCAST_MANAGER (object));
1898
2192
        gtk_dialog_run (GTK_DIALOG (dialog));
1899
2193
        gtk_widget_destroy (dialog);
1900
2194
}
1981
2275
}
1982
2276
 
1983
2277
static void
 
2278
rb_shell_sync_pane_visibility (RBShell *shell)
 
2279
{
 
2280
        gboolean sourcelist_visible;
 
2281
        GtkAction *action;
 
2282
 
 
2283
        g_object_get (G_OBJECT (shell->priv->sourcelist), "visible", &sourcelist_visible, NULL);
 
2284
        if (shell->priv->queue_source)
 
2285
                g_object_set (G_OBJECT (shell->priv->queue_source), "visibility", !shell->priv->queue_as_sidebar, NULL);
 
2286
 
 
2287
        if (shell->priv->queue_as_sidebar)
 
2288
                gtk_widget_show (shell->priv->queue_sidebar);
 
2289
        else
 
2290
                gtk_widget_hide (shell->priv->queue_sidebar);
 
2291
 
 
2292
        if (sourcelist_visible == FALSE && shell->priv->queue_as_sidebar == FALSE)
 
2293
                gtk_widget_hide (GTK_WIDGET (shell->priv->queue_paned));
 
2294
        else
 
2295
                gtk_widget_show (GTK_WIDGET (shell->priv->queue_paned));
 
2296
 
 
2297
        action = gtk_action_group_get_action (shell->priv->actiongroup,
 
2298
                                              "ViewQueueAsSidebar");
 
2299
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), 
 
2300
                                      shell->priv->queue_as_sidebar);
 
2301
}
 
2302
 
 
2303
 
 
2304
static void
 
2305
rb_shell_sync_toolbar_visibility (RBShell *shell)
 
2306
{
 
2307
        GtkWidget *toolbar;
 
2308
        gboolean visible;
 
2309
        GtkAction *action;
 
2310
 
 
2311
        visible = !eel_gconf_get_boolean (CONF_UI_TOOLBAR_HIDDEN);
 
2312
 
 
2313
        toolbar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar");
 
2314
        if (visible)
 
2315
                gtk_widget_show (toolbar);
 
2316
        else
 
2317
                gtk_widget_hide (toolbar);
 
2318
 
 
2319
        action = gtk_action_group_get_action (shell->priv->actiongroup,
 
2320
                                              "ViewToolbar");
 
2321
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
 
2322
                                      visible);
 
2323
}
 
2324
 
 
2325
static void
 
2326
rb_shell_sync_fullscreen (RBShell *shell)
 
2327
{
 
2328
        gboolean fullscreen;
 
2329
        GtkAction *action;
 
2330
 
 
2331
        fullscreen = eel_gconf_get_boolean (CONF_UI_FULLSCREEN);
 
2332
 
 
2333
        if (fullscreen) {
 
2334
                gtk_window_fullscreen (GTK_WINDOW (shell->priv->window));
 
2335
        } else {
 
2336
                gtk_window_unfullscreen (GTK_WINDOW (shell->priv->window));
 
2337
        }
 
2338
 
 
2339
        action = gtk_action_group_get_action (shell->priv->actiongroup,
 
2340
                                              "ViewFullscreen");
 
2341
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
 
2342
                                      fullscreen);
 
2343
}
 
2344
 
 
2345
static void
1984
2346
rb_shell_sync_smalldisplay (RBShell *shell)
1985
2347
{
1986
2348
        GtkAction *action;
 
2349
        GtkAction *queue_action;
 
2350
        GtkWidget *toolbar;
1987
2351
 
1988
2352
        rb_shell_sync_window_state (shell, FALSE);
1989
2353
 
1990
2354
        action = gtk_action_group_get_action (shell->priv->actiongroup,
1991
2355
                                              "ViewSourceList");
 
2356
        queue_action = gtk_action_group_get_action (shell->priv->actiongroup,
 
2357
                                                    "ViewQueueAsSidebar");
 
2358
 
 
2359
        toolbar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar");
1992
2360
 
1993
2361
        if (shell->priv->window_small) {
1994
2362
                g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
 
2363
                g_object_set (G_OBJECT (queue_action), "sensitive", FALSE, NULL);
1995
2364
  
1996
2365
                gtk_widget_hide (GTK_WIDGET (shell->priv->paned));
1997
2366
                gtk_widget_hide (GTK_WIDGET (shell->priv->statusbar));
1998
 
                gtk_widget_hide (GTK_WIDGET (shell->priv->hsep));               
 
2367
                gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
1999
2368
        } else {
2000
2369
                g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
 
2370
                g_object_set (G_OBJECT (queue_action), "sensitive", TRUE, NULL);
2001
2371
  
2002
2372
                gtk_widget_show (GTK_WIDGET (shell->priv->paned));
2003
2373
                rb_statusbar_sync_state (shell->priv->statusbar);
2004
 
                gtk_widget_show (GTK_WIDGET (shell->priv->hsep));       
 
2374
                gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
2005
2375
        }
2006
2376
 
2007
2377
        rb_source_header_sync_control_state (shell->priv->source_header);
2021
2391
{
2022
2392
        rb_debug ("sourcelist visibility changed"); 
2023
2393
        rb_shell_sync_sourcelist_visibility (shell);
 
2394
        rb_shell_sync_pane_visibility (shell);
 
2395
}
 
2396
 
 
2397
static void
 
2398
toolbar_visibility_changed_cb (GConfClient *client,
 
2399
                               guint cnxn_id,
 
2400
                               GConfEntry *entry,
 
2401
                               RBShell *shell)
 
2402
{
 
2403
        rb_debug ("toolbar visibility changed"); 
 
2404
        rb_shell_sync_toolbar_visibility (shell);
2024
2405
}
2025
2406
 
2026
2407
static void
2027
2408
smalldisplay_changed_cb (GConfClient *client,
2028
 
                                  guint cnxn_id,
2029
 
                                  GConfEntry *entry,
2030
 
                                  RBShell *shell)
 
2409
                         guint cnxn_id,
 
2410
                         GConfEntry *entry,
 
2411
                         RBShell *shell)
2031
2412
{
2032
2413
        rb_debug ("small display mode changed");
2033
2414
        shell->priv->window_small = eel_gconf_get_boolean (CONF_UI_SMALL_DISPLAY);
2035
2416
}
2036
2417
 
2037
2418
static void
 
2419
fullscreen_changed_cb (GConfClient *client,
 
2420
                       guint cnxn_id,
 
2421
                       GConfEntry *entry,
 
2422
                       RBShell *shell)
 
2423
{
 
2424
        rb_debug ("fullscreen mode changed");
 
2425
        shell->priv->window_fullscreen = eel_gconf_get_boolean (CONF_UI_FULLSCREEN);
 
2426
        rb_shell_sync_fullscreen (shell);
 
2427
}
 
2428
 
 
2429
static void
2038
2430
rb_shell_sync_paned (RBShell *shell)
2039
2431
{
2040
2432
        gtk_paned_set_position (GTK_PANED (shell->priv->paned),
2041
2433
                                shell->priv->paned_position);
 
2434
        gtk_paned_set_position (GTK_PANED (shell->priv->queue_paned),
 
2435
                                shell->priv->sourcelist_height);
2042
2436
}
2043
2437
 
2044
2438
static void
2052
2446
}
2053
2447
 
2054
2448
static void
 
2449
sidebar_paned_size_allocate_cb (GtkWidget *widget,
 
2450
                                GtkAllocation *allocation,
 
2451
                                RBShell *shell)
 
2452
{
 
2453
        shell->priv->sourcelist_height = gtk_paned_get_position (GTK_PANED (shell->priv->queue_paned));
 
2454
        rb_debug ("sidebar paned position %d", shell->priv->sourcelist_height);
 
2455
        eel_gconf_set_integer (CONF_STATE_SOURCELIST_HEIGHT, shell->priv->sourcelist_height);
 
2456
}
 
2457
 
 
2458
static void
2055
2459
sourcelist_drag_received_cb (RBSourceList *sourcelist,
2056
2460
                             RBSource *source,
2057
2461
                             GtkSelectionData *data,
2122
2526
        if (source == NULL)
2123
2527
                return;
2124
2528
 
2125
 
        songs = rb_source_get_entry_view (source);
2126
 
        rb_shell_select_source (shell, source);
 
2529
        if (source == RB_SOURCE (shell->priv->queue_source) && shell->priv->queue_as_sidebar) {
 
2530
                songs = RB_ENTRY_VIEW (shell->priv->queue_sidebar);
 
2531
        } else {
 
2532
                songs = rb_source_get_entry_view (source);
 
2533
                rb_shell_select_source (shell, source);
 
2534
        }
2127
2535
 
2128
2536
        rb_entry_view_scroll_to_entry (songs, entry);
2129
2537
        rb_entry_view_select_entry (songs, entry);
2147
2555
rb_shell_jump_to_current (RBShell *shell)
2148
2556
{
2149
2557
        RBSource *source = rb_shell_player_get_playing_source (shell->priv->player_shell);
2150
 
        RBEntryView *songs;
2151
2558
        RhythmDBEntry *playing;
2152
2559
 
2153
2560
        g_return_if_fail (source != NULL);
2154
2561
 
2155
 
        songs = rb_source_get_entry_view (source);
2156
 
        playing = rb_entry_view_get_playing_entry (songs);
 
2562
        playing = rb_shell_player_get_playing_entry (shell->priv->player_shell);
2157
2563
 
2158
2564
        rb_shell_jump_to_entry_with_source (shell, source, playing);
2159
2565
}
2806
3212
{
2807
3213
        RBShell *shell = RB_SHELL (proxy);
2808
3214
        RhythmDBEntry *entry;
2809
 
        RBEntryView *view;
2810
 
        RBSource *playing_source;
2811
3215
 
2812
3216
        rb_debug ("setting rating of playing entry to %f", rating);
2813
3217
 
2814
 
        playing_source = rb_shell_player_get_playing_source (shell->priv->player_shell);
2815
 
        if (playing_source != NULL) {
2816
 
                view = rb_source_get_entry_view (playing_source);
2817
 
                entry = rb_entry_view_get_playing_entry (view);
2818
 
                if (entry != NULL) {
2819
 
                        GValue value = {0, };
2820
 
                        g_value_init (&value, G_TYPE_DOUBLE);
2821
 
                        g_value_set_double (&value, rating);
2822
 
 
2823
 
                        rhythmdb_entry_set (shell->priv->db, entry, RHYTHMDB_PROP_RATING, &value);
2824
 
 
2825
 
                        g_value_unset (&value);
2826
 
                        rhythmdb_commit (shell->priv->db);
2827
 
                }
 
3218
        entry = rb_shell_player_get_playing_entry (shell->priv->player_shell);
 
3219
        if (entry != NULL) {
 
3220
                GValue value = {0, };
 
3221
                g_value_init (&value, G_TYPE_DOUBLE);
 
3222
                g_value_set_double (&value, rating);
 
3223
 
 
3224
                rhythmdb_entry_set (shell->priv->db, entry, RHYTHMDB_PROP_RATING, &value);
 
3225
 
 
3226
                g_value_unset (&value);
 
3227
                rhythmdb_commit (shell->priv->db);
2828
3228
        }
2829
3229
}
2830
3230
 
2835
3235
        player = RB_SHELL (proxy)->priv->player_shell;
2836
3236
        rb_shell_player_toggle_mute (player);
2837
3237
}
 
3238
 
 
3239
static void
 
3240
rb_shell_volume_widget_changed_cb (BaconVolumeButton *vol,
 
3241
                                   RBShell *shell)
 
3242
{
 
3243
        eel_gconf_set_float (CONF_STATE_VOLUME,
 
3244
                             bacon_volume_button_get_value (vol));
 
3245
}
 
3246