Beispiel #1
0
	def __init__(self):
		#Global Variables (keep to a minimum)
		self.settings = settings.IconoSettings(sopranoGlobals.SETTINGS_DATA)
		self.taglookup = TrackMetaData()
		self.seekingnow = False	
		#load settings
		self.currentview, self.winwidth, self.winheight, self.defaultexplorer, self.shuffle, self.repeat, self.showtrayicon, self.closetotray = self.settings.get_settings()

		libraryFolderlist = settings.IconoPrefs(sopranoGlobals.LIBRARY_DATA)
		self.SopranoDB = MusicDB(os.path.join(sopranoGlobals.CONFIGDIR, 'sopranoDB.db'))
		libraryFolderlist.add_radio(('/media/Media/Music','/media/Media/Music'))
		for key,value in libraryFolderlist.get_radioStations().items():
			self.SopranoDB.add_folder(value)

		#turn on the dbus mainloop for sound menu
		from dbus.mainloop.glib import DBusGMainLoop
		DBusGMainLoop(set_as_default=True)
		#Start Sound Menu Support
		self.sopranompris = SoundMenuControls("soprano-player")
		self.sopranompris.signal_next = self.play_next
		self.sopranompris.signal_prev = self.play_prev
		self.sopranompris.signal_play_pause = self.play_pause
		self.sopranompris.signal_raise = self.toggle_window

		#Enable Notifications
		Notify.init ("Soprano")
		self.notification = Notify.Notification.new("","","")

		#Window Creation
		self.builder = Gtk.Builder()
		filename = os.path.join('data', 'MainWindow.glade')
		self.builder.add_from_file(filename)
		self.builder.connect_signals(self)

		self.window = self.builder.get_object('win-main')
		self.window.set_default_size(self.winwidth,self.winheight)
		self.window.connect('delete-event', self.pre_exit)
		
		#radiowindow
		self.aRadio = IconoRadio()

		#Gstreamer sink
		self.player = MusicPlayer()
		self.player.on_eos(self.on_message)
		#media keys setup
		self.mediakeys = mediakeys(self.play_prev, self.play_pause, self.play_next)

		timer = GObject.timeout_add(500, self.update_time_items)

		#trayicon
		self.tray = IconoTray("soprano-player-tray") 
		self.trayshowhide = self.tray.add_menu_item(self.toggle_window, "Hide/Show")
		self.tray.add_seperator()
		self.trayplaypause = self.tray.add_menu_item(self.play_pause, "Play/Pause")
		self.tray.add_menu_item(self.play_next, "Next")
		self.tray.add_menu_item(self.play_prev, "Previous")
		self.tray.add_seperator()
		self.tray.add_menu_item(self.on_exit, "Quit")
		self.update_tray_icon(self.showtrayicon)


		#View Menu#
		menuvfull = self.builder.get_object('menu-mode-full')
		menuvfull.connect('activate', self.to_full_mode)
		menuvmini = self.builder.get_object('menu-mode-mini')
		menuvmini.connect('activate', self.to_mini_mode)
		menuvplist = self.builder.get_object('menu-mode-playlist')
		menuvplist.connect('activate', self.to_playlist_mode)

		#Quit, About Menus
		menuaqt = self.builder.get_object('menu-quit')
		menuaqt.connect('activate',self.on_exit)
		menuabt = self.builder.get_object('menu-about')
		menuabt.connect('activate', aboutBoxShow, self.window)

		#Edit Menu#
		menuaddfolder = self.builder.get_object('menu-folderadd')
		#menuaddfolder.connect('activate', lambda x: self.addFolderExplorer(('Video','/media/Media/Videos')))
		menuaddfolder.connect('activate', self.show_pref_win)

		menuaddradio = self.builder.get_object('menu-radioadd')
		#menuaddradio.connect('activate', lambda x: self.delFolderExplorer(('Video','/media/Media/Videos')))
		menuaddradio.connect('activate', self.aRadio.addStationDialog)

		self.menuautopop = self.builder.get_object('menu-autopop')

		#playing Toolbar
		self.toolnext = self.builder.get_object('btn-next')
		self.toolnext.connect('clicked', self.play_next)

		self.toolprev = self.builder.get_object('btn-previous')
		self.toolprev.connect('clicked', self.play_prev)

		self.toolstop = self.builder.get_object('btn-stop')
		self.toolstop.connect('clicked', self.stop_play)

		self.toolplay = self.builder.get_object('btn-play')
		self.toolplay.connect('clicked', self.play_pause)

		self.toolSeekBar = self.builder.get_object('scl-position')
		self.toolSeekBar.connect('button-release-event', self.seek)
		self.toolSeekBar.connect('button-press-event', self.seekevent)

		self.toolVolume = self.builder.get_object('btn-volume')
		self.toolVolume.connect('value-changed', self.change_volume)

		#Text Displays
		self.titleText = self.builder.get_object('lbl-trkTitle')
		self.infoText = self.builder.get_object('lbl-trkMisc')
		self.lengthLabel = self.builder.get_object('lbl-length')
		self.elapsedLabel = self.builder.get_object('lbl-elapsed')

		#bottom toolbar
		barclr = self.builder.get_object('btn-tracklistClear')
		barclr.connect('clicked', self.clear_liststore)

		barshfl = self.builder.get_object('btn-tracklistShuffle')
		if self.shuffle == True:
			barshfl.set_active(True)
		barshfl.connect('clicked', self.shuffleliststore)

		barrpt = self.builder.get_object('btn-tracklistRepeat')
		if self.repeat == True:
			barrpt.set_active(True)
		barrpt.connect('toggled', self.setrepeat)

		#listview
		self.iconoListView = IconoListView()
		self.iconoListView.get_sw().get_child().connect('row-activated', self.on_activated)
		#self.iconoListView.get_sw().get_child().connect('button-press-event', self.on_right_click)
		vbox2 = self.builder.get_object('vbox2')
		vbox2.add(self.iconoListView.get_sw())
		vbox2.reorder_child(self.iconoListView.get_sw(), 1)
		if os.path.exists(sopranoGlobals.TREE_DATA):
			GObject.idle_add(self.iconoListView.load_shelf, sopranoGlobals.TREE_DATA)

		#combobox
		self.hCombo = HeaderedComboBox()
		self.hCombo.connect("changed", self.on_name_combo_changed)

		self.builder.get_object('box-combo-explorer').add(self.hCombo)
		
		GObject.idle_add(self.setup_explorer)
		GObject.idle_add(self.cover_update)
		self.window.show_all()
		if self.currentview == 'playlist':
			menuvplist.set_active(True)
			self.to_playlist_mode()
		elif self.currentview == 'mini':
			menuvmini.set_active(True)
			self.to_mini_mode()
		#Notebook
		self.notebook = self.builder.get_object('notebook-explorer')