Пример #1
0
    def __init__(self, controls):
        self.controls = controls
        ChildTopWindow.__init__(self, _("Download Manager"))
        self.set_resizable(True)
        self.set_default_size(900, 700)

        vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        #paned = Gtk.HPaned()
        #paned.set_position(200)

        self.navigation = DMNavigationTreeControl()

        self.navigation.append(FDModel(_("All")).add_artist(_("All")).add_status(DOWNLOAD_STATUS_ALL))
        self.navigation.append(FDModel(_("Downloading")).add_artist(_("Downloading")).add_status(DOWNLOAD_STATUS_DOWNLOADING))
        self.navigation.append(FDModel(_("Completed")).add_artist(_("Completed")).add_status(DOWNLOAD_STATUS_COMPLETED))
        self.navigation.append(FDModel(_("Active")).add_artist(_("Active")).add_status(DOWNLOAD_STATUS_ACTIVE))
        self.navigation.append(FDModel(_("Inactive")).add_artist(_("Inactive")).add_status(DOWNLOAD_STATUS_INACTIVE))

        self.dm_list = DownloadManagerTreeControl(self.navigation)
        self.navigation.dm_list = self.dm_list
        #paned.pack1(self.navigation.scroll)
        #paned.pack2(self.dm_list.scroll)
        playback = DMControls(self.controls, self.dm_list)

        vbox.pack_start(playback, False, True, 0)
        #vbox.pack_start(paned, True, True, 0)
        vbox.pack_start(self.dm_list.scroll, True, True, 0)

        self.add(vbox)
        threading.Thread(target = self.dowloader, args = (self.dm_list,)).start()
Пример #2
0
def get_bean_from_file(f):
    if not os.path.exists(f):
        logging.debug("not exists" + str(f))
        return None
    bean = FDModel(text=os.path.basename(f), path=f)
    is_file = True if os.path.isfile(f) else False
    bean = bean.add_is_file(is_file)
    if not is_file:
        bean.add_font("bold")
    return bean
Пример #3
0
 def on_toggle_singletab(widget, data=None):
     self.tree_controller.clear_tree()
     for path in FCache().music_paths[0]:
         self.tree_controller.append(
             FDModel(os.path.basename(path), path).add_is_file(False))
     self.temp_music_paths = FCache().music_paths[0][:]
     self.frame.show()
Пример #4
0
    def safe_fill_treerows(self):
        try:
            self.filling_lock.acquire()

            rows = collections.OrderedDict()
            for treerow in self.model:
                rows[Gtk.TreeRowReference.new(
                    self.model, treerow.path)] = [col for col in treerow]
            for row_ref in rows.keys():
                row = rows[row_ref]
                if not row[self.time[0]] and row[
                        self.is_file[0]] and row_ref.valid():
                    bean = self.get_bean_from_row(row)
                    beans = update_id3_wind_filtering([bean])
                    if len(beans) == 1:
                        self.fill_row(row_ref, beans[:][0])
                    else:
                        bean = FDModel(text=_('Playlist: ') +
                                       os.path.basename(bean.path)).add_font(
                                           "bold").add_is_file(False)
                        self.fill_row(row_ref, bean)
                        beans.reverse()
                        for b in beans[:]:
                            self.insert_bean(row_ref, b)
        finally:
            #self.update_tracknumber()
            self.controls.notetabs.on_save_tabs()
            if self.filling_lock.locked():
                self.filling_lock.release()
Пример #5
0
    def __init__(self, controls):
        FControl.__init__(self, controls)

        controls = self.controls
        self.configs.append(MusicLibraryConfig(controls))
        self.configs.append(TabsConfig(controls))
        self.configs.append(LastFmConfig(controls))
        self.configs.append(TrayIconConfig(controls))
        self.configs.append(NetworkConfig(controls))

        try:
            """check keybinder installed, debian"""
            import gi
            gi.require_version('Keybinder', '3.0')
            from gi.repository import Keybinder  #@UnresolvedImport @UnusedImport
            from foobnix.preferences.configs.hotkey_conf import HotKeysConfig
            self.configs.append(HotKeysConfig(controls))
        except Exception as e:
            logging.warn("Keybinder not installed" + str(e))

        self.configs.append(OtherConfig(controls))

        self.label = None

        mainVBox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)

        ChildTopWindow.__init__(self, _("Preferences"), 900, 550)

        paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
        paned.set_position(250)

        def func():
            bean = self.navigation.get_selected_bean()
            if bean:
                self.populate_config_category(bean.text)

        self.navigation = SimpleListTreeControl(_("Categories"), controls,
                                                True)

        for plugin in self.configs:
            self.navigation.append(FDModel(plugin.name))

        self.navigation.set_left_click_func(func)

        paned.add1(self.navigation.scroll)

        cbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        for plugin in self.configs:
            cbox.pack_start(plugin.widget, False, True, 0)

        self._container = self.create_container(cbox)
        paned.add2(self._container)

        mainVBox.pack_start(paned, True, True, 0)
        mainVBox.pack_start(self.create_save_cancel_buttons(), False, False, 0)

        #self.add(mainVBox)
        GLib.idle_add(self.add, mainVBox)
Пример #6
0
 def on_add_file(self, *a):
     val = show_entry_dialog(_("Please add audio extension"),
                             _("Extension should be like '.mp3'"))
     if val and val.find(".") >= 0 and len(
             val
     ) <= 5 and val not in self.files_controller.get_all_beans_text():
         self.files_controller.append(FDModel(val))
     else:
         logging.info("Can't add your value" + val)
Пример #7
0
                def task(user):
                    logging.debug(user)
                    name = user['first_name'] + " " + user['last_name']

                    parent = FModel(name)
                    parent.user_id = user['uid']
                    bean = FDModel(
                        _("loading...")).parent(parent).add_is_file(True)
                    self.append(parent)
                    self.append(bean)
Пример #8
0
    def on_load(self):
        self.tree_controller.clear_tree()
        for path in FCache().music_paths[0]:
            self.tree_controller.append(
                FDModel(os.path.basename(path), path).add_is_file(False))

        self.files_controller.clear_tree()
        for ext in FC().all_support_formats:
            self.files_controller.append(FDModel(ext))

        self.adjustment.set_value(FC().gap_secs)

        if FC().tabs_mode == "Single":
            self.singletab_button.set_active(True)
            self.controls.perspectives.get_perspective(
                'fs').get_tabhelper().set_show_tabs(False)

        if FC().update_tree_on_start:
            self.update_on_start.set_active(True)

        self.temp_music_paths = FCache(
        ).music_paths[0][:]  #create copy of list
Пример #9
0
 def add_dir(self, *a):
     current_folder = FCache().last_music_path if FCache(
     ).last_music_path else None
     paths = directory_chooser_dialog(_("Choose directory with music"),
                                      current_folder)
     if not paths:
         return
     path = paths[0]
     FCache().last_music_path = path[:path.rfind("/")]
     for path in paths:
         if path not in self.temp_music_paths:
             self.tree_controller.append(
                 FDModel(os.path.basename(path), path).add_is_file(False))
             self.temp_music_paths.append(path)
Пример #10
0
 def get_user_tracks_as_beans(self, user_id):
     beans = []
     result = self.controls.vk_service.get_result('audio.get',
                                                  "uid=" + user_id)
     if not result:
         beans = [FDModel(_("No results found")).add_is_file(True)]
     else:
         for line in result:
             bean = FModel(line['artist'] + ' - ' + line['title'])
             bean.aritst = line['artist']
             bean.title = line['title']
             bean.time = convert_seconds_to_text(line['duration'])
             bean.path = line['url']
             bean.aid = line['aid']
             bean.oid = line['owner_id']
             bean.is_file = True
             bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
             beans.append(bean)
     return beans
Пример #11
0
    def __init__(self, controls):
        CommonTreeControl.__init__(self, controls)
        """column config"""
        column = Gtk.TreeViewColumn(_("Lasm.fm Integration ") +
                                    FCBase().lfm_login,
                                    self.ellipsize_render,
                                    text=self.text[0],
                                    font=self.font[0])
        column.set_resizable(True)
        self.set_headers_visible(True)
        self.append_column(column)

        self.tree_menu = Popup()

        self.configure_send_drag()
        self.configure_recive_drag()

        self.set_type_tree()

        self.services = {
            _("My recommendations"):
            self.controls.lastfm_service.get_recommended_artists,
            _("My loved tracks"):
            self.controls.lastfm_service.get_loved_tracks,
            _("My top tracks"): self.controls.lastfm_service.get_top_tracks,
            _("My recent tracks"):
            self.controls.lastfm_service.get_recent_tracks,
            _("My top artists"): self.controls.lastfm_service.get_top_artists,
            _("My events"): self.controls.lastfm_service.get_events,
            _("My friends"): self.controls.lastfm_service.get_friends,
            _("My neighbours"): self.controls.lastfm_service.get_neighbours
        }

        for name in self.services:
            parent = FModel(name)
            bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
            self.append(parent)
            self.append(bean)
Пример #12
0
class PreferencesWindow(ChildTopWindow, FControl, LoadSave):

    configs = []
    POS_NAME = 0

    def __init__(self, controls):
        FControl.__init__(self, controls)
        thread.start_new_thread(self.lazy_init, (True, ))

    def lazy_init(self, sleep=False):
        controls = self.controls
        self.configs.append(MusicLibraryConfig(controls))
        self.configs.append(TabsConfig(controls))
        self.configs.append(LastFmConfig(controls))
        self.configs.append(TrayIconConfig(controls))
        self.configs.append(NetworkConfig(controls))

        try:
            """check keybinder installed, debian"""
            from gi.repository import Keybinder  #@UnresolvedImport @UnusedImport
            from foobnix.preferences.configs.hotkey_conf import HotKeysConfig
            self.configs.append(HotKeysConfig(controls))
        except Exception, e:
            logging.warn("Keybinder not installed" + str(e))

        self.configs.append(OtherConfig(controls))

        self.label = None

        mainVBox = Gtk.VBox(False, 0)

        ChildTopWindow.__init__(self, _("Preferences"), 900, 550)

        paned = Gtk.HPaned()
        paned.set_position(250)

        def func():
            bean = self.navigation.get_selected_bean()
            if bean:
                self.populate_config_category(bean.text)

        self.navigation = SimpleListTreeControl(_("Categories"), controls,
                                                True)

        for plugin in self.configs:
            self.navigation.append(FDModel(plugin.name))

        self.navigation.set_left_click_func(func)

        paned.add1(self.navigation.scroll)

        cbox = Gtk.VBox(False, 0)
        for plugin in self.configs:
            cbox.pack_start(plugin.widget, False, True, 0)

        self._container = self.create_container(cbox)
        paned.add2(self._container)

        mainVBox.pack_start(paned, True, True, 0)
        mainVBox.pack_start(self.create_save_cancel_buttons(), False, False, 0)

        #self.add(mainVBox)
        GLib.idle_add(self.add, mainVBox)