def setup_explorer(self, widget=None): self.hCombo.add_entry(None, 1, "<b>Folders</b>", None, -1) explorer = IconoTreeFile('/', sopranoGlobals.FILE_FORMATS) self.setup_explorer_page( self.notebook, explorer.get_sw(), self.hCombo, [self.notebook.get_n_pages(), 0, "Root", sopranoGlobals.FOLDERPB]) audioFolderlist = settings.IconoPrefs(sopranoGlobals.EXPLORER_DATA) for key, value in audioFolderlist.get_radioStations().items(): explorer = IconoTreeFile(value, sopranoGlobals.FILE_FORMATS) self.setup_explorer_page( self.notebook, explorer.get_sw(), self.hCombo, [self.notebook.get_n_pages(), 0, key, sopranoGlobals.FOLDERPB]) #aCdTree = IconoAudioCD() #self.setup_explorer_page(self.notebook, aCdTree.get_sw(), self.hCombo, [self.notebook.get_n_pages(), 0, "<b>Audio CD</b>", sopranoGlobals.TRACKPB]) self.setup_explorer_page(self.notebook, self.aRadio.get_sw(), self.hCombo, [ self.notebook.get_n_pages(), 0, "<b>Radio</b>", sopranoGlobals.RADIOPB ]) self.medialib = IconoMediaLibrary(self.SopranoDB) self.setup_explorer_page(self.notebook, self.medialib.get_sw(), self.hCombo, [ self.notebook.get_n_pages(), 0, "<b>Library</b>", sopranoGlobals.USERSPB ]) self.notebook.set_current_page(self.defaultexplorer) self.hCombo.set_active(self.defaultexplorer)
def addFolderExplorer(self, station): explorer = IconoTreeFile(station[1], sopranoGlobals.FILE_FORMATS) audioFolderlist = settings.IconoPrefs(sopranoGlobals.EXPLORER_DATA) audioFolderlist.add_radio(station) self.setup_explorer_page(self.notebook, explorer.get_sw(), self.hCombo, [len(audioFolderlist.get_radioStations()), 0, station[0], sopranoGlobals.FOLDERPB], self.notebook.get_n_pages()-2) #Update the audioCD and Radio Indexes model = self.hCombo.get_model() length = len(model) for i in range(1,3): iter = model.get_iter(length-i) model.set_value(iter, 0, length-(1+i))
def __init__(self): self.sw = Gtk.ScrolledWindow() self.editPref = settings.IconoPrefs(sopranoGlobals.RADIO_DATA) stations = self.editPref.get_radioStations() parents = {} self.treeview = Gtk.TreeView() treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, int, str) col = Gtk.TreeViewColumn() render_text = Gtk.CellRendererText() col.pack_end(render_text, True) col.add_attribute(render_text, 'text', 1) render_pb = Gtk.CellRendererPixbuf() col.pack_start(render_pb, False) col.add_attribute(render_pb, 'pixbuf', 0) self.treeview.append_column(col) self.treeview.set_headers_visible(False) self.emptybtn = Gtk.Button(label="Add a Station") self.emptybtn.connect('clicked', self.addStationDialog) vbox = Gtk.VBox() vbox.pack_start(self.emptybtn, True, False, 0) vbox.add(self.treeview) if stations == []: self.treeview.set_no_show_all(True) else: self.emptybtn.set_no_show_all(True) self.sw.add_with_viewport(vbox) self.treeview.set_model(treestore) self.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) self.treeview.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY) self.treeview.drag_source_add_text_targets() self.treeview.connect('button-press-event', self.on_right_click) self.treeview.connect("drag_data_get", self.drag_data_get_cb) self.treeview.connect("drag_begin", self.drag_begin_cb) GObject.idle_add(self.setupStations, stations) self.playlisturl = None
def radioInfo(self, filepath): self.editPref = settings.IconoPrefs(sopranoGlobals.RADIO_DATA) stations = self.editPref.get_radioStations() for key, value in self.editPref.get_radioStations().items(): if filepath == value: songtitle = key break else: songtitle = "Unknown Title" tracknum = 0 artist = "Radio Station" album = "Radio Station" genre = "None" tracklength = "N/A" return [ None, tracknum, songtitle, artist, album, tracklength, genre, filepath ]
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')
def delFolderExplorer(self, station): self.clear_notebook() audioFolderlist = settings.IconoPrefs(sopranoGlobals.EXPLORER_DATA) audioFolderlist.delete_radio(station) self.setup_explorer()