-
Notifications
You must be signed in to change notification settings - Fork 41
/
sonata.py
7856 lines (7376 loc) · 376 KB
/
sonata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# coding=utf-8
# $HeadURL: http://svn.berlios.de/svnroot/repos/sonata/trunk/sonata.py $
# $Id: sonata.py 141 2006-09-11 04:51:07Z stonecrest $
__version__ = "1.3"
__license__ = """
Sonata, an elegant GTK+ client for the Music Player Daemon
Copyright 2006-2008 Scott Horowitz <stonecrest@gmail.com>
This file is part of Sonata.
Sonata is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Sonata is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import warnings, sys, os, gobject, ConfigParser, urllib, urllib2
import socket, gc, subprocess, gettext, locale, shutil, getopt
import threading, re, time
try:
import gtk, pango, mpdclient3
except ImportError, (strerror):
print >>sys.stderr, "%s. Please make sure you have this library installed into a directory in Python's path or in the same directory as Sonata.\n" % strerror
sys.exit(1)
# Prevent deprecation warning for egg:
warnings.simplefilter('ignore', DeprecationWarning)
try:
import egg.trayicon
HAVE_EGG = True
HAVE_STATUS_ICON = False
except ImportError:
HAVE_EGG = False
if gtk.pygtk_version >= (2, 10, 0):
# Revert to pygtk status icon:
HAVE_STATUS_ICON = True
else:
HAVE_STATUS_ICON = False
# Reset so that we can see any other deprecation warnings
warnings.simplefilter('default', DeprecationWarning)
try:
import dbus, dbus.service
if getattr(dbus, "version", (0,0,0)) >= (0,41,0):
import dbus.glib
if getattr(dbus, "version", (0,0,0)) >= (0,80,0):
import _dbus_bindings as dbus_bindings
NEW_DBUS = True
else:
import dbus.dbus_bindings as dbus_bindings
NEW_DBUS = False
HAVE_DBUS = True
except:
HAVE_DBUS = False
HAVE_GNOME_MMKEYS = False
if HAVE_DBUS:
try:
# mmkeys for gnome 2.18+
bus = dbus.SessionBus()
dbusObj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
dbusInterface = dbus.Interface(dbusObj, 'org.freedesktop.DBus')
if dbusInterface.NameHasOwner('org.gnome.SettingsDaemon'):
settingsDaemonObj = bus.get_object('org.gnome.SettingsDaemon', '/org/gnome/SettingsDaemon')
settingsDaemonInterface = dbus.Interface(settingsDaemonObj, 'org.gnome.SettingsDaemon')
settingsDaemonInterface.GrabMediaPlayerKeys('Sonata', 0)
HAVE_GNOME_MMKEYS = True
HAVE_MMKEYS = False
except:
pass
if not HAVE_GNOME_MMKEYS:
try:
# if not gnome 2.18+, mmkeys for everyone else
import mmkeys
HAVE_MMKEYS = True
except:
HAVE_MMKEYS = False
try:
import audioscrobbler
HAVE_AUDIOSCROBBLER = True
except:
HAVE_AUDIOSCROBBLER = False
try:
from sugar.activity import activity
HAVE_STATUS_ICON = False
HAVE_SUGAR = True
VOLUME_ICON_SIZE = 3
except:
HAVE_SUGAR = False
VOLUME_ICON_SIZE = 4
try:
import tagpy
HAVE_TAGPY = True
except:
HAVE_TAGPY = False
if HAVE_TAGPY:
try:
# Set default tag encoding to utf8.. fixes some reported bugs.
import tagpy.id3v2 as id3v2
id3v2.FrameFactory.instance().setDefaultTextEncoding(tagpy.StringType.UTF8)
except:
pass
try:
from ZSI import ServiceProxy
# Make sure we have the right version..
test = ServiceProxy.ServiceProxy
HAVE_WSDL = True
except:
HAVE_WSDL = False
try:
import gnome, gnome.ui
HAVE_GNOME_UI = True
except:
HAVE_GNOME_UI = False
# Test pygtk version
if gtk.pygtk_version < (2, 6, 0):
sys.stderr.write("Sonata requires PyGTK 2.6.0 or newer.\n")
sys.exit(1)
class Connection(mpdclient3.mpd_connection):
"""A connection to the daemon. Will use MPD_HOST/MPD_PORT in preference to the supplied config if available."""
def __init__(self, Base):
"""Open a connection using the host/port values from the provided config. If conf is None, an empty object will be returned, suitable for comparing != to any other connection."""
host, port, password = Base.mpd_env_vars()
if not host: host = Base.host[Base.profile_num]
if not port: port = Base.port[Base.profile_num]
if not password: password = Base.password[Base.profile_num]
mpdclient3.mpd_connection.__init__(self, host, port, password)
mpdclient3.connect(host=host, port=port, password=password)
class Base(mpdclient3.mpd_connection):
def __init__(self, window=None, sugar=False):
gtk.gdk.threads_init()
try:
gettext.install('sonata', os.path.join(__file__.split('/lib')[0], 'share', 'locale'), unicode=1)
except:
gettext.install('sonata', '/usr/share/locale', unicode=1)
gettext.textdomain('sonata')
self.traytips = TrayIconTips()
# Initialize vars (these can be needed if we have a cli argument, e.g., "sonata play")
socket.setdefaulttimeout(5)
self.profile_num = 0
self.profile_names = [_('Default Profile')]
self.musicdir = [self.sanitize_musicdir("~/music")]
self.host = ['localhost']
self.port = [6600]
self.password = ['']
self.trying_connection = False
toggle_arg = False
start_hidden = False
start_visible = False
arg_profile = False
# Read any passed options/arguments:
if not sugar:
try:
opts, args = getopt.getopt(sys.argv[1:], "tv", ["toggle", "version", "status", "info", "play", "pause", "stop", "next", "prev", "pp", "shuffle", "repeat", "hidden", "visible", "profile="])
except getopt.GetoptError:
# print help information and exit:
self.print_usage()
sys.exit()
# If options were passed, perform action on them.
if opts != []:
for o, a in opts:
if o in ("-t", "--toggle"):
toggle_arg = True
if not HAVE_DBUS:
print _("The toggle argument requires D-Bus. Aborting.")
self.print_usage()
sys.exit()
elif o in ("-v", "--version"):
self.print_version()
sys.exit()
elif o in ("--visible"):
start_visible = True
elif o in ("--hidden"):
start_hidden = True
elif o in ("--profile"):
arg_profile = True
else:
self.print_usage()
sys.exit()
if args != []:
for a in args:
if a in ("play", "pause", "stop", "next", "prev", "pp", "info", "status", "repeat", "shuffle"):
self.single_connect_for_passed_arg(a)
else:
self.print_usage()
sys.exit()
if not HAVE_TAGPY:
print _("Taglib and/or tagpy not found, tag editing support disabled.")
if not HAVE_WSDL:
print _("ZSI not found, fetching lyrics support disabled.")
if not HAVE_EGG and not HAVE_STATUS_ICON:
print _("PyGTK+ 2.10 or gnome-python-extras not found, system tray support disabled.")
if not HAVE_AUDIOSCROBBLER:
print _("Python 2.5 or python-elementtree not found, audioscrobbler support disabled.")
start_dbus_interface(toggle_arg)
self.gnome_session_management()
# Constants
self.TAB_CURRENT = _("Current")
self.TAB_LIBRARY = _("Library")
self.TAB_PLAYLISTS = _("Playlists")
self.TAB_STREAMS = _("Streams")
self.TAB_INFO = _("Info")
self.ART_LOCAL = 0
self.ART_LOCAL_REMOTE = 1
self.VIEW_FILESYSTEM = 0
self.VIEW_ARTIST = 1
self.VIEW_ALBUM = 2
self.LYRIC_TIMEOUT = 10
self.NOTIFICATION_WIDTH_MAX = 500
self.NOTIFICATION_WIDTH_MIN = 350
self.ART_LOCATION_HOMECOVERS = 0 # ~/.covers/[artist]-[album].jpg
self.ART_LOCATION_COVER = 1 # file_dir/cover.jpg
self.ART_LOCATION_ALBUM = 2 # file_dir/album.jpg
self.ART_LOCATION_FOLDER = 3 # file_dir/folder.jpg
self.ART_LOCATION_CUSTOM = 4 # file_dir/[custom]
self.ART_LOCATION_NONE = 5 # Use default Sonata icons
self.ART_LOCATION_NONE_FLAG = "USE_DEFAULT"
self.ART_LOCATIONS_MISC = ['front.jpg', '.folder.jpg', '.folder.png', 'AlbumArt.jpg', 'AlbumArtSmall.jpg']
self.LYRICS_LOCATION_HOME = 0 # ~/.lyrics/[artist]-[song].txt
self.LYRICS_LOCATION_PATH = 1 # file_dir/[artist]-[song].txt
# Initialize vars for GUI
self.current_tab = self.TAB_CURRENT
self.x = 0
self.y = 0
self.w = 400
self.h = 300
self.expanded = True
self.withdrawn = False
self.sticky = False
self.ontop = False
self.screen = 0
self.prevconn = []
self.prevstatus = None
self.prevsonginfo = None
self.lastalbumart = None
self.xfade = 0
self.xfade_enabled = False
self.show_covers = True
self.covers_pref = self.ART_LOCAL_REMOTE
self.lyricServer = None
self.show_notification = False
self.show_playback = True
self.show_progress = True
self.show_statusbar = False
self.show_trayicon = True
self.show_lyrics = True
self.stop_on_exit = False
self.update_on_start = False
self.minimize_to_systray = False
self.popuptimes = ['2', '3', '5', '10', '15', '30', _('Entire song')]
self.popuplocations = [_('System tray'), _('Top Left'), _('Top Right'), _('Bottom Left'), _('Bottom Right'), _('Screen Center')]
self.popup_option = 2
self.exit_now = False
self.ignore_toggle_signal = False
self.initial_run = True
self.show_header = True
self.currentformat = "%A - %T"
self.libraryformat = "%A - %T"
self.titleformat = "[Sonata] %A - %T"
self.currsongformat1 = "%T"
self.currsongformat2 = _("by") + " %A " + _("from") + " %B"
self.columnwidths = []
self.autoconnect = True
self.user_connect = False
self.stream_names = []
self.stream_uris = []
self.downloading_image = False
self.search_terms = [_('Artist'), _('Title'), _('Album'), _('Genre'), _('Filename'), _('Everything')]
self.search_terms_mpd = ['artist', 'title', 'album', 'genre', 'filename', 'any']
self.last_search_num = 0
self.sonata_loaded = False
self.call_gc_collect = False
self.single_img_in_dir = None
self.misc_img_in_dir = None
self.total_time = 0
self.prev_boldrow = -1
self.use_infofile = False
self.infofile_path = '/tmp/xmms-info'
self.play_on_activate = False
self.view = self.VIEW_FILESYSTEM
self.view_artist_artist = ''
self.view_artist_album = ''
self.view_artist_level = 1
self.view_artist_level_prev = 0
self.songs = None
self.tagpy_is_91 = None
self.art_location = self.ART_LOCATION_HOMECOVERS
self.art_location_custom_filename = ""
self.lyrics_location = self.LYRICS_LOCATION_HOME
self.filterbox_visible = False
self.edit_style_orig = None
self.reset_artist_for_album_name()
self.use_scrobbler = False
self.as_username = ""
self.as_password = ""
show_prefs = False
self.enc = locale.getpreferredencoding()
self.updating_nameentry = False
self.merge_id = None
self.mergepl_id = None
self.actionGroupProfiles = None
self.actionGroupPlaylists = None
self.skip_on_profiles_click = False
self.last_repeat = None
self.last_random = None
self.last_title = None
self.last_progress_frac = None
self.last_progress_text = None
self.last_info_bitrate = None
self.column_sorted = (None, gtk.SORT_DESCENDING) # TreeViewColumn, order
self.url_browser = ""
self.wd = '/'
self.filter_row_mapping = [] # Mapping between filter rows and self.currentdata rows
self.plpos = None
self.info_song_expanded = True
self.info_lyrics_expanded = True
self.info_song_more = False
self.current_tab_visible = True
self.library_tab_visible = True
self.playlists_tab_visible = True
self.streams_tab_visible = True
self.info_tab_visible = True
self.last_status_text = ""
self.info_art_enlarged = False
self.eggtrayfile = None
self.eggtrayheight = None
self.scrob = None
self.scrob_post = None
self.scrob_start_time = ""
self.scrob_playing_duration = 0
self.scrob_last_prepared = ""
self.scrob_time_now = None
# For increased responsiveness after the initial load, we cache the root artist and
# album view results and simply refresh on any mpd update
self.albums_root = None
self.artists_root = None
# If the connection to MPD times out, this will cause the interface to freeze while
# the socket.connect() calls are repeatedly executed. Therefore, if we were not
# able to make a connection, slow down the iteration check to once every 15 seconds.
# Eventually we'd like to ues non-blocking sockets in mpdclient3.py
self.iterate_time_when_connected = 500
self.iterate_time_when_disconnected_or_stopped = 1000 # Slow down polling when disconnected stopped
self.all_tab_names = [self.TAB_CURRENT, self.TAB_LIBRARY, self.TAB_PLAYLISTS, self.TAB_STREAMS, self.TAB_INFO]
tab_positions = self.settings_load()
if start_hidden:
self.withdrawn = True
if start_visible:
self.withdrawn = False
if self.autoconnect:
self.user_connect = True
if arg_profile:
try:
if int(a) > 0 and int(a) <= len(self.profile_names):
self.profile_num = int(a)-1
print _("Starting Sonata with profile"), self.profile_names[self.profile_num]
else:
print _("Not a valid profile number. Profile number must be between 1 and"), str(len(self.profile_names)) + "."
except:
print _("Not a valid profile number. Profile number must be between 1 and"), str(len(self.profile_names)) + "."
pass
# Add some icons:
self.iconfactory = gtk.IconFactory()
self.new_icon('sonata', file='sonata.png')
self.new_icon('artist', file='sonata-artist.png')
self.new_icon('album', file='sonata-album.png')
icon_theme = gtk.icon_theme_get_default()
if HAVE_SUGAR:
activity_root = activity.get_bundle_path()
icon_theme.append_search_path(os.path.join(activity_root, 'share'))
(img_width, img_height) = gtk.icon_size_lookup(VOLUME_ICON_SIZE)
for iconname in ('stock_volume-mute', 'stock_volume-min', 'stock_volume-med', 'stock_volume-max'):
try:
self.new_icon(iconname, fullpath=icon_theme.lookup_icon(iconname, img_width, gtk.ICON_LOOKUP_USE_BUILTIN).get_filename())
except:
# Fallback to Sonata-included icons:
self.new_icon(iconname, file='sonata-'+iconname+'.png')
# Popup menus:
actions = (
('sortmenu', None, _('_Sort List')),
('playlistmenu', None, _('Sa_ve List to')),
('profilesmenu', None, _('_Connection')),
('filesystemview', gtk.STOCK_HARDDISK, _('Filesystem'), None, None, self.on_libraryview_chosen),
('artistview', 'artist', _('Artist'), None, None, self.on_libraryview_chosen),
('albumview', 'album', _('Album'), None, None, self.on_libraryview_chosen),
('chooseimage_menu', gtk.STOCK_CONVERT, _('Use _Remote Image...'), None, None, self.on_choose_image),
('localimage_menu', gtk.STOCK_OPEN, _('Use _Local Image...'), None, None, self.on_choose_image_local),
('resetimage_menu', gtk.STOCK_CLEAR, _('Reset to Default'), None, None, self.on_reset_image),
('playmenu', gtk.STOCK_MEDIA_PLAY, _('_Play'), None, None, self.pp),
('queuemenu', None, _('Add to _Queue'), '<Ctrl>e', None, self.queue),
('dequeuemenu', None, _('Remove from _Queue'), '<Ctrl><Shift>e', None, self.dequeue),
('pausemenu', gtk.STOCK_MEDIA_PAUSE, _('_Pause'), None, None, self.pp),
('stopmenu', gtk.STOCK_MEDIA_STOP, _('_Stop'), None, None, self.stop),
('prevmenu', gtk.STOCK_MEDIA_PREVIOUS, _('_Previous'), None, None, self.prev),
('nextmenu', gtk.STOCK_MEDIA_NEXT, _('_Next'), None, None, self.next),
('quitmenu', gtk.STOCK_QUIT, _('_Quit'), None, None, self.on_delete_event_yes),
('removemenu', gtk.STOCK_REMOVE, _('_Remove'), None, None, self.remove),
('clearmenu', gtk.STOCK_CLEAR, _('_Clear'), '<Ctrl>Delete', None, self.clear),
('savemenu', None, _('_New Playlist...'), '<Ctrl><Shift>s', None, self.on_playlist_save),
('updatemenu', None, _('_Update Library'), None, None, self.updatedb),
('preferencemenu', gtk.STOCK_PREFERENCES, _('_Preferences...'), 'F5', None, self.prefs),
('aboutmenu', None, _('_About...'), 'F1', None, self.about),
('newmenu', None, _('_New...'), '<Ctrl>n', None, self.streams_new),
('editmenu', None, _('_Edit...'), None, None, self.streams_edit),
('renamemenu', None, _('_Rename...'), None, None, self.on_playlist_rename),
('edittagmenu', None, _('_Edit Tags...'), '<Ctrl>t', None, self.edit_tags),
('addmenu', gtk.STOCK_ADD, _('_Add'), '<Ctrl>d', None, self.add_item),
('replacemenu', gtk.STOCK_REDO, _('_Replace'), '<Ctrl>r', None, self.replace_item),
('rmmenu', None, _('_Delete...'), None, None, self.remove),
('sortbyartist', None, _('By Artist'), None, None, self.on_sort_by_artist),
('sortbyalbum', None, _('By Album'), None, None, self.on_sort_by_album),
('sortbytitle', None, _('By Song Title'), None, None, self.on_sort_by_title),
('sortbyfile', None, _('By File Name'), None, None, self.on_sort_by_file),
('sortbydirfile', None, _('By Dir & File Name'), None, None, self.on_sort_by_dirfile),
('sortreverse', None, _('Reverse List'), None, None, self.on_sort_reverse),
('sortrandom', None, _('Random'), '<Alt>r', None, self.on_sort_random),
('tab1key', None, 'Tab1 Key', '<Alt>1', None, self.switch_to_tab1),
('tab2key', None, 'Tab2 Key', '<Alt>2', None, self.switch_to_tab2),
('tab3key', None, 'Tab3 Key', '<Alt>3', None, self.switch_to_tab3),
('tab4key', None, 'Tab4 Key', '<Alt>4', None, self.switch_to_tab4),
('tab5key', None, 'Tab5 Key', '<Alt>5', None, self.switch_to_tab5),
('expandkey', None, 'Expand Key', '<Alt>Down', None, self.expand),
('collapsekey', None, 'Collapse Key', '<Alt>Up', None, self.collapse),
('ppkey', None, 'Play/Pause Key', '<Ctrl>p', None, self.pp),
('stopkey', None, 'Stop Key', '<Ctrl>s', None, self.stop),
('prevkey', None, 'Previous Key', '<Ctrl>Left', None, self.prev),
('nextkey', None, 'Next Key', '<Ctrl>Right', None, self.next),
('lowerkey', None, 'Lower Volume Key', '<Ctrl>minus', None, self.volume_lower),
('raisekey', None, 'Raise Volume Key', '<Ctrl>plus', None, self.volume_raise),
('raisekey2', None, 'Raise Volume Key 2', '<Ctrl>equal', None, self.volume_raise),
('quitkey', None, 'Quit Key', '<Ctrl>q', None, self.on_delete_event_yes),
('quitkey2', None, 'Quit Key 2', '<Ctrl>w', None, self.on_delete_event_yes),
('updatekey', None, 'Update Key', '<Ctrl>u', None, self.updatedb),
('updatekey2', None, 'Update Key 2', '<Ctrl><Shift>u', None, self.updatedb_path),
('connectkey', None, 'Connect Key', '<Alt>c', None, self.connectkey_pressed),
('disconnectkey', None, 'Disconnect Key', '<Alt>d', None, self.disconnectkey_pressed),
('centerplaylistkey', None, 'Center Playlist Key', '<Ctrl>i', None, self.center_playlist),
('searchkey', None, 'Search Key', '<Ctrl>h', None, self.searchkey_pressed),
)
toggle_actions = (
('showmenu', None, _('_Show Sonata'), None, None, self.withdraw_app_toggle, not self.withdrawn),
('repeatmenu', None, _('_Repeat'), None, None, self.on_repeat_clicked, False),
('shufflemenu', None, _('_Shuffle'), None, None, self.on_shuffle_clicked, False),
(self.TAB_CURRENT, None, self.TAB_CURRENT, None, None, self.tab_toggle, self.current_tab_visible),
(self.TAB_LIBRARY, None, self.TAB_LIBRARY, None, None, self.tab_toggle, self.library_tab_visible),
(self.TAB_PLAYLISTS, None, self.TAB_PLAYLISTS, None, None, self.tab_toggle, self.playlists_tab_visible),
(self.TAB_STREAMS, None, self.TAB_STREAMS, None, None, self.tab_toggle, self.streams_tab_visible),
(self.TAB_INFO, None, self.TAB_INFO, None, None, self.tab_toggle, self.info_tab_visible),
)
uiDescription = """
<ui>
<popup name="imagemenu">
<menuitem action="chooseimage_menu"/>
<menuitem action="localimage_menu"/>
<separator name="FM1"/>
<menuitem action="resetimage_menu"/>
</popup>
<popup name="traymenu">
<menuitem action="showmenu"/>
<separator name="FM1"/>
<menuitem action="playmenu"/>
<menuitem action="pausemenu"/>
<menuitem action="stopmenu"/>
<menuitem action="prevmenu"/>
<menuitem action="nextmenu"/>
<separator name="FM2"/>
<menuitem action="quitmenu"/>
</popup>
<popup name="mainmenu">
<menuitem action="addmenu"/>
<menuitem action="replacemenu"/>
<menuitem action="newmenu"/>
<menuitem action="editmenu"/>
<menuitem action="removemenu"/>
<menuitem action="clearmenu"/>
<menuitem action="edittagmenu"/>
<menuitem action="renamemenu"/>
<menuitem action="rmmenu"/>
<menuitem action="queuemenu"/>
<menuitem action="dequeuemenu"/>
<menu action="sortmenu">
<menuitem action="sortbytitle"/>
<menuitem action="sortbyartist"/>
<menuitem action="sortbyalbum"/>
<menuitem action="sortbyfile"/>
<menuitem action="sortbydirfile"/>
<separator name="FM3"/>
<menuitem action="sortrandom"/>
<menuitem action="sortreverse"/>
</menu>
<menu action="playlistmenu">
<menuitem action="savemenu"/>
<separator name="FM4"/>
</menu>
<separator name="FM1"/>
<menuitem action="updatemenu"/>
<menuitem action="repeatmenu"/>
<menuitem action="shufflemenu"/>
<separator name="FM2"/>
<menu action="profilesmenu">
</menu>
<menuitem action="preferencemenu"/>
<menuitem action="aboutmenu"/>
<menuitem action="quitmenu"/>
</popup>
<popup name="librarymenu">
<menuitem action="filesystemview"/>
<menuitem action="artistview"/>
<menuitem action="albumview"/>
</popup>
<popup name="hidden">
<menuitem action="quitkey"/>
<menuitem action="quitkey2"/>
<menuitem action="tab1key"/>
<menuitem action="tab2key"/>
<menuitem action="tab3key"/>
<menuitem action="tab4key"/>
<menuitem action="tab5key"/>
<menuitem action="expandkey"/>
<menuitem action="collapsekey"/>
<menuitem action="ppkey"/>
<menuitem action="stopkey"/>
<menuitem action="nextkey"/>
<menuitem action="prevkey"/>
<menuitem action="lowerkey"/>
<menuitem action="raisekey"/>
<menuitem action="raisekey2"/>
<menuitem action="updatekey"/>
<menuitem action="updatekey2"/>
<menuitem action="connectkey"/>
<menuitem action="disconnectkey"/>
<menuitem action="centerplaylistkey"/>
<menuitem action="searchkey"/>
</popup>
<popup name="notebookmenu">
"""
for tab in self.all_tab_names:
uiDescription = uiDescription + "<menuitem action=\"" + tab + "\"/>"
uiDescription = uiDescription + "</popup></ui>"
# Try to connect to MPD:
self.connect(blocking=True)
if self.conn:
self.status = self.conn.do.status()
self.iterate_time = self.iterate_time_when_connected
try:
test = self.status.state
except:
self.status = None
try:
self.songinfo = self.conn.do.currentsong()
except:
self.songinfo = None
else:
if self.initial_run:
show_prefs = True
self.iterate_time = self.iterate_time_when_disconnected_or_stopped
self.status = None
self.songinfo = None
# Audioscrobbler
self.scrobbler_init()
# Remove the old sonata covers dir (cleanup)
if os.path.exists(os.path.expanduser('~/.config/sonata/covers/')):
removeall(os.path.expanduser('~/.config/sonata/covers/'))
os.rmdir(os.path.expanduser('~/.config/sonata/covers/'))
# Images...
self.sonatacd = self.find_path('sonatacd.png')
self.sonatacd_large = self.find_path('sonatacd_large.png')
# Main app:
if window is None:
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window_owner = True
else:
self.window = window
self.window_owner = False
if self.window_owner:
self.window.set_title('Sonata')
self.window.set_role('mainWindow')
self.window.set_resizable(True)
if self.ontop:
self.window.set_keep_above(True)
if self.sticky:
self.window.stick()
self.tooltips = gtk.Tooltips()
self.UIManager = gtk.UIManager()
actionGroup = gtk.ActionGroup('Actions')
actionGroup.add_actions(actions)
actionGroup.add_toggle_actions(toggle_actions)
self.UIManager.insert_action_group(actionGroup, 0)
self.UIManager.add_ui_from_string(uiDescription)
self.populate_profiles_for_menu()
self.window.add_accel_group(self.UIManager.get_accel_group())
self.mainmenu = self.UIManager.get_widget('/mainmenu')
self.shufflemenu = self.UIManager.get_widget('/mainmenu/shufflemenu')
self.repeatmenu = self.UIManager.get_widget('/mainmenu/repeatmenu')
self.imagemenu = self.UIManager.get_widget('/imagemenu')
self.traymenu = self.UIManager.get_widget('/traymenu')
self.librarymenu = self.UIManager.get_widget('/librarymenu')
self.notebookmenu = self.UIManager.get_widget('/notebookmenu')
mainhbox = gtk.HBox()
mainvbox = gtk.VBox()
tophbox = gtk.HBox()
self.imageeventbox = gtk.EventBox()
self.imageeventbox.drag_dest_set(gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [("text/uri-list", 0, 80)], gtk.gdk.ACTION_DEFAULT)
self.albumimage = gtk.Image()
self.imageeventbox.add(self.albumimage)
if not self.show_covers:
self.imageeventbox.set_no_show_all(True)
self.imageeventbox.hide()
tophbox.pack_start(self.imageeventbox, False, False, 5)
topvbox = gtk.VBox()
toptophbox = gtk.HBox()
self.prevbutton = gtk.Button("", gtk.STOCK_MEDIA_PREVIOUS, True)
self.ppbutton = gtk.Button("", gtk.STOCK_MEDIA_PLAY, True)
self.stopbutton = gtk.Button("", gtk.STOCK_MEDIA_STOP, True)
self.nextbutton = gtk.Button("", gtk.STOCK_MEDIA_NEXT, True)
for mediabutton in (self.prevbutton, self.ppbutton, self.stopbutton, self.nextbutton):
mediabutton.set_relief(gtk.RELIEF_NONE)
mediabutton.set_property('can-focus', False)
mediabutton.get_child().get_child().get_children()[1].set_text('')
toptophbox.pack_start(mediabutton, False, False, 0)
if not self.show_playback:
mediabutton.set_no_show_all(True)
mediabutton.hide()
self.progressbox = gtk.VBox()
self.progresslabel = gtk.Label()
self.progresslabel.set_size_request(-1, 6)
self.progressbox.pack_start(self.progresslabel)
self.progresseventbox = gtk.EventBox()
self.progressbar = gtk.ProgressBar()
self.progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
self.progressbar.set_fraction(0)
self.progressbar.set_pulse_step(0.05)
self.progressbar.set_ellipsize(pango.ELLIPSIZE_END)
self.progresseventbox.add(self.progressbar)
self.progressbox.pack_start(self.progresseventbox, False, False, 0)
self.progresslabel2 = gtk.Label()
self.progresslabel2.set_size_request(-1, 6)
self.progressbox.pack_start(self.progresslabel2)
toptophbox.pack_start(self.progressbox, True, True, 0)
if not self.show_progress:
self.progressbox.set_no_show_all(True)
self.progressbox.hide()
self.volumebutton = gtk.ToggleButton("", True)
self.volumebutton.set_relief(gtk.RELIEF_NONE)
self.volumebutton.set_property('can-focus', False)
self.set_volumebutton("stock_volume-med")
if not self.show_playback:
self.volumebutton.set_no_show_all(True)
self.volumebutton.hide()
toptophbox.pack_start(self.volumebutton, False, False, 0)
topvbox.pack_start(toptophbox, False, False, 2)
self.expander = gtk.Expander(_("Playlist"))
self.expander.set_expanded(self.expanded)
self.expander.set_property('can-focus', False)
expanderbox = gtk.VBox()
self.cursonglabel1 = gtk.Label()
self.cursonglabel2 = gtk.Label()
self.cursonglabel1.set_alignment(0, 0)
self.cursonglabel2.set_alignment(0, 0)
expanderbox.pack_start(self.cursonglabel1, True, True, 0)
expanderbox.pack_start(self.cursonglabel2, True, True, 0)
self.expander.set_label_widget(expanderbox)
topvbox.pack_start(self.expander, False, False, 2)
tophbox.pack_start(topvbox, True, True, 3)
mainvbox.pack_start(tophbox, False, False, 5)
self.notebook = gtk.Notebook()
self.notebook.set_tab_pos(gtk.POS_TOP)
self.notebook.set_property('can-focus', False)
# Current tab
self.expanderwindow = gtk.ScrolledWindow()
self.expanderwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.expanderwindow.set_shadow_type(gtk.SHADOW_IN)
self.current = gtk.TreeView()
self.current.set_rules_hint(True)
self.current.set_reorderable(True)
self.current.set_enable_search(False)
self.current_selection = self.current.get_selection()
self.expanderwindow.add(self.current)
self.filterpattern = gtk.Entry()
self.filterbox = gtk.HBox()
self.filterbox.pack_start(gtk.Label(_("Filter") + ":"), False, False, 5)
self.filterbox.pack_start(self.filterpattern, True, True, 5)
filterclosebutton = gtk.Button()
filterclosebutton.set_image(gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU))
filterclosebutton.set_relief(gtk.RELIEF_NONE)
self.filterbox.pack_start(filterclosebutton, False, False, 0)
self.filterbox.set_no_show_all(True)
vbox_current = gtk.VBox()
vbox_current.pack_start(self.expanderwindow, True, True)
vbox_current.pack_start(self.filterbox, False, False, 5)
playlistevbox = gtk.EventBox()
playlisthbox = gtk.HBox()
playlisthbox.pack_start(gtk.image_new_from_stock(gtk.STOCK_CDROM, gtk.ICON_SIZE_MENU), False, False, 2)
playlisthbox.pack_start(gtk.Label(str=self.TAB_CURRENT), False, False, 2)
playlistevbox.add(playlisthbox)
playlistevbox.show_all()
playlistevbox.connect("button_press_event", self.on_tab_click)
self.notebook.append_page(vbox_current, playlistevbox)
if not self.current_tab_visible:
self.notebook.get_children()[0].set_no_show_all(True)
self.notebook.get_children()[0].hide_all()
# Library tab
browservbox = gtk.VBox()
expanderwindow2 = gtk.ScrolledWindow()
expanderwindow2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
expanderwindow2.set_shadow_type(gtk.SHADOW_IN)
self.browser = gtk.TreeView()
self.browser.set_headers_visible(False)
self.browser.set_rules_hint(True)
self.browser.set_reorderable(False)
self.browser.set_enable_search(True)
self.browser_selection = self.browser.get_selection()
expanderwindow2.add(self.browser)
self.searchbox = gtk.HBox()
self.searchcombo = gtk.combo_box_new_text()
for item in self.search_terms:
self.searchcombo.append_text(item)
self.searchtext = gtk.Entry()
self.searchbutton = gtk.Button(_('_End Search'))
self.searchbutton.set_image(gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU))
self.searchbutton.set_size_request(-1, self.searchcombo.size_request()[1])
self.searchbutton.set_no_show_all(True)
self.searchbutton.hide()
self.libraryview = gtk.Button()
self.tooltips.set_tip(self.libraryview, _("Library browsing view"))
self.libraryview_assign_image()
self.libraryview.set_relief(gtk.RELIEF_NONE)
self.librarymenu.attach_to_widget(self.libraryview, None)
self.searchbox.pack_start(self.libraryview, False, False, 1)
self.searchbox.pack_start(gtk.VSeparator(), False, False, 0)
self.searchbox.pack_start(self.searchcombo, False, False, 2)
self.searchbox.pack_start(self.searchtext, True, True, 2)
self.searchbox.pack_start(self.searchbutton, False, False, 2)
browservbox.pack_start(expanderwindow2, True, True, 2)
browservbox.pack_start(self.searchbox, False, False, 2)
libraryevbox = gtk.EventBox()
libraryhbox = gtk.HBox()
libraryhbox.pack_start(gtk.image_new_from_stock(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_MENU), False, False, 2)
libraryhbox.pack_start(gtk.Label(str=self.TAB_LIBRARY), False, False, 2)
libraryevbox.add(libraryhbox)
libraryevbox.show_all()
libraryevbox.connect("button_press_event", self.on_tab_click)
self.notebook.append_page(browservbox, libraryevbox)
if not self.library_tab_visible:
self.notebook.get_children()[1].set_no_show_all(True)
self.notebook.get_children()[1].hide_all()
# Playlists tab
expanderwindow3 = gtk.ScrolledWindow()
expanderwindow3.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
expanderwindow3.set_shadow_type(gtk.SHADOW_IN)
self.playlists = gtk.TreeView()
self.playlists.set_headers_visible(False)
self.playlists.set_rules_hint(True)
self.playlists.set_reorderable(False)
self.playlists.set_enable_search(True)
self.playlists_selection = self.playlists.get_selection()
expanderwindow3.add(self.playlists)
playlistsevbox = gtk.EventBox()
playlistshbox = gtk.HBox()
playlistshbox.pack_start(gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_CENTER, gtk.ICON_SIZE_MENU), False, False, 2)
playlistshbox.pack_start(gtk.Label(str=self.TAB_PLAYLISTS), False, False, 2)
playlistsevbox.add(playlistshbox)
playlistsevbox.show_all()
playlistsevbox.connect("button_press_event", self.on_tab_click)
self.notebook.append_page(expanderwindow3, playlistsevbox)
if not self.playlists_tab_visible:
self.notebook.get_children()[2].set_no_show_all(True)
self.notebook.get_children()[2].hide_all()
# Streams tab
expanderwindow4 = gtk.ScrolledWindow()
expanderwindow4.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
expanderwindow4.set_shadow_type(gtk.SHADOW_IN)
self.streams = gtk.TreeView()
self.streams.set_headers_visible(False)
self.streams.set_rules_hint(True)
self.streams.set_reorderable(False)
self.streams.set_enable_search(True)
self.streams_selection = self.streams.get_selection()
expanderwindow4.add(self.streams)
streamsevbox = gtk.EventBox()
streamshbox = gtk.HBox()
streamshbox.pack_start(gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU), False, False, 2)
streamshbox.pack_start(gtk.Label(str=self.TAB_STREAMS), False, False, 2)
streamsevbox.add(streamshbox)
streamsevbox.show_all()
streamsevbox.connect("button_press_event", self.on_tab_click)
self.notebook.append_page(expanderwindow4, streamsevbox)
if not self.streams_tab_visible:
self.notebook.get_children()[3].set_no_show_all(True)
self.notebook.get_children()[3].hide_all()
# Info tab
info = gtk.ScrolledWindow()
info.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
info.set_shadow_type(gtk.SHADOW_IN)
infoevbox = gtk.EventBox()
infohbox = gtk.HBox()
infohbox.pack_start(gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_MENU), False, False, 2)
infohbox.pack_start(gtk.Label(str=self.TAB_INFO), False, False, 2)
infoevbox.add(infohbox)
infoevbox.show_all()
infoevbox.connect("button_press_event", self.on_tab_click)
self.info_widgets_initialize(info)
self.notebook.append_page(info, infoevbox)
mainvbox.pack_start(self.notebook, True, True, 5)
if not self.info_tab_visible:
self.notebook.get_children()[4].set_no_show_all(True)
self.notebook.get_children()[4].hide_all()
self.statusbar = gtk.Statusbar()
self.statusbar.set_has_resize_grip(True)
if not self.show_statusbar or not self.expanded:
self.statusbar.hide()
self.statusbar.set_no_show_all(True)
mainvbox.pack_start(self.statusbar, False, False, 0)
mainhbox.pack_start(mainvbox, True, True, 3)
if self.window_owner:
self.window.add(mainhbox)
self.window.move(self.x, self.y)
self.window.set_size_request(270, -1)
elif HAVE_SUGAR:
self.window.set_canvas(mainhbox)
if not self.expanded:
self.notebook.set_no_show_all(True)
self.notebook.hide()
self.cursonglabel1.set_markup('<big><b>' + _('Stopped') + '</b></big>')
self.cursonglabel2.set_markup('<small>' + _('Click to expand') + '</small>')
if self.window_owner:
self.window.set_default_size(self.w, 1)
else:
self.cursonglabel1.set_markup('<big><b>' + _('Stopped') + '</b></big>')
self.cursonglabel2.set_markup('<small>' + _('Click to collapse') + '</small>')
if self.window_owner:
self.window.set_default_size(self.w, self.h)
self.tooltips.set_tip(self.expander, self.cursonglabel1.get_text())
if not self.conn:
self.progressbar.set_text(_('Not Connected'))
self.tooltips.set_tip(self.libraryview, _("Library browsing view"))
if gtk.pygtk_version >= (2, 10, 0):
for child in self.notebook.get_children():
self.notebook.set_tab_reorderable(child, True)
# Update tab positions and hide tabs as per the user's settings:
if tab_positions:
for tabnum in range(len(tab_positions)):
for tabnum2 in range(len(self.notebook.get_children())):
tabname = self.notebook_get_tab_text(self.notebook, tabnum2)
if tabname == tab_positions[tabnum]:
self.notebook.reorder_child(self.notebook.get_children()[tabnum2], tabnum)
break
# Systray:
outtertipbox = gtk.VBox()
tipbox = gtk.HBox()
self.trayalbumeventbox = gtk.EventBox()
self.trayalbumeventbox.set_size_request(59, 90)
self.trayalbumimage1 = gtk.Image()
self.trayalbumimage1.set_size_request(51, 77)
self.trayalbumimage1.set_alignment(1, 0.5)
self.trayalbumeventbox.add(self.trayalbumimage1)
self.trayalbumeventbox.set_state(gtk.STATE_SELECTED)
hiddenlbl = gtk.Label()
hiddenlbl.set_size_request(2, -1)
tipbox.pack_start(hiddenlbl, False, False, 0)
tipbox.pack_start(self.trayalbumeventbox, False, False, 0)
self.trayalbumimage2 = gtk.Image()
self.trayalbumimage2.set_size_request(26, 77)
tipbox.pack_start(self.trayalbumimage2, False, False, 0)
if not self.show_covers:
self.trayalbumeventbox.set_no_show_all(True)
self.trayalbumeventbox.hide()
self.trayalbumimage2.set_no_show_all(True)
self.trayalbumimage2.hide()
innerbox = gtk.VBox()
self.traycursonglabel1 = gtk.Label()
self.traycursonglabel1.set_markup(_("Playlist"))
self.traycursonglabel1.set_alignment(0, 1)
self.traycursonglabel2 = gtk.Label()
self.traycursonglabel2.set_markup(_("Playlist"))
self.traycursonglabel2.set_alignment(0, 0)
label1 = gtk.Label()
label1.set_markup('<span size="10"> </span>')
innerbox.pack_start(label1)
innerbox.pack_start(self.traycursonglabel1, True, True, 0)
innerbox.pack_start(self.traycursonglabel2, True, True, 0)
self.trayprogressbar = gtk.ProgressBar()
self.trayprogressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
self.trayprogressbar.set_fraction(0)
self.trayprogressbar.set_pulse_step(0.05)
self.trayprogressbar.set_ellipsize(pango.ELLIPSIZE_NONE)
label2 = gtk.Label()
label2.set_markup('<span size="10"> </span>')
innerbox.pack_start(label2)
innerbox.pack_start(self.trayprogressbar, False, False, 0)
if not self.show_progress:
self.trayprogressbar.set_no_show_all(True)
self.trayprogressbar.hide()
label3 = gtk.Label()
label3.set_markup('<span size="10"> </span>')
innerbox.pack_start(label3)
tipbox.pack_start(innerbox, True, True, 6)
outtertipbox.pack_start(tipbox, False, False, 2)
outtertipbox.show_all()
self.traytips.add_widget(outtertipbox)
self.set_notification_window_width()
# Volumescale window
self.volumewindow = gtk.Window(gtk.WINDOW_POPUP)
self.volumewindow.set_skip_taskbar_hint(True)
self.volumewindow.set_skip_pager_hint(True)
self.volumewindow.set_decorated(False)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self.volumewindow.add(frame)
volbox = gtk.VBox()
volbox.pack_start(gtk.Label("+"), False, False, 0)
self.volumescale = gtk.VScale()
self.volumescale.set_draw_value(True)
self.volumescale.set_value_pos(gtk.POS_TOP)
self.volumescale.set_digits(0)
self.volumescale.set_update_policy(gtk.UPDATE_CONTINUOUS)
self.volumescale.set_inverted(True)
self.volumescale.set_adjustment(gtk.Adjustment(0, 0, 100, 0, 0, 0))
if HAVE_SUGAR:
self.volumescale.set_size_request(-1, 203)
else:
self.volumescale.set_size_request(-1, 103)
volbox.pack_start(self.volumescale, True, True, 0)
volbox.pack_start(gtk.Label("-"), False, False, 0)
frame.add(volbox)
frame.show_all()
# Connect to signals
self.window.add_events(gtk.gdk.BUTTON_PRESS_MASK)
self.traytips.add_events(gtk.gdk.BUTTON_PRESS_MASK)
self.traytips.connect('button_press_event', self.on_traytips_press)
self.window.connect('delete_event', self.on_delete_event)
self.window.connect('window_state_event', self.on_window_state_change)
self.window.connect('configure_event', self.on_window_configure)
self.window.connect('key-press-event', self.on_topwindow_keypress)
self.window.connect('focus-out-event', self.on_window_lost_focus)
self.imageeventbox.connect('button_press_event', self.on_image_activate)
self.imageeventbox.connect('drag_motion', self.on_image_motion_cb)
self.imageeventbox.connect('drag_data_received', self.on_image_drop_cb)
self.ppbutton.connect('clicked', self.pp)
self.stopbutton.connect('clicked', self.stop)
self.prevbutton.connect('clicked', self.prev)
self.nextbutton.connect('clicked', self.next)
self.progresseventbox.connect('button_press_event', self.on_progressbar_button_press_event)
self.progresseventbox.connect('scroll_event', self.on_progressbar_scroll_event)
self.volumebutton.connect('clicked', self.on_volumebutton_clicked)
self.volumebutton.connect('scroll-event', self.on_volumebutton_scroll)
self.expander.connect('activate', self.on_expander_activate)
self.current.connect('drag_data_received', self.on_drag_drop)
self.current.connect('row_activated', self.on_current_click)
self.current.connect('button_press_event', self.on_current_button_press)
self.current_selection.connect('changed', self.on_treeview_selection_changed)