Beispiel #1
0
    def __init__(self):
        gtk.VBox.__init__(self)

        # Init data.
        self.source_data = OrderedDict()
        self.source_data["internal"] = "国内广播"
        self.source_data["foreign"] = "国外广播"
        self.source_data["network"] = "网络广播"
        self.source_data["genres"] = "流派广播"
        self.source_data["music"] = "音乐广播"
        self.source_data["finance"] = "财经广播"
        self.source_data["sports"] = "体育广播"

        # Init sourcebar
        self.__init_sourcebar()

        # Init webcasts view.
        self.source_view, self.source_sw = self.get_webcasts_view()
        self.collect_view, self.collect_sw = self.get_webcasts_view()
        # self.custom_view, custom_view_sw = self.get_webcasts_view()

        self.source_view.connect("single-click-item",
                                 self.on_source_view_single_click_item)

        if WebcastsDB.isloaded():
            self.on_webcastsdb_loaded()
        else:
            self.connect_to_webcastsdb()

        # Dispatcher
        Dispatcher.connect("webcast-info", self.on_dispatcher_webcast_info)
        Dispatcher.connect("clear-sourcebar-status",
                           lambda obj: self.clear_sourcebar_status())

        # Used to switch categroy view.
        self.switch_view_box = gtk.VBox()
        self.switch_view_box.add(self.source_sw)

        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"),
                            enable_drag=True)
        body_paned.add1(self.sourcebar)
        body_paned.add2(self.switch_view_box)

        self.add(body_paned)
        self.show_all()
 def __init__(self):
     gtk.VBox.__init__(self)
     
     # Init data.
     self.source_data = OrderedDict()
     self.source_data["internal"] = "国内广播"
     self.source_data["foreign"]  = "国外广播"
     self.source_data["network"] = "网络广播"
     self.source_data["genres"] = "流派广播"
     self.source_data["music"]  = "音乐广播"
     self.source_data["finance"] = "财经广播"
     self.source_data["sports"] = "体育广播"
     
     # Init sourcebar
     self.__init_sourcebar()
     
     # Init webcasts view.
     self.source_view, self.source_sw = self.get_webcasts_view()
     self.collect_view, self.collect_sw = self.get_webcasts_view()
     # self.custom_view, custom_view_sw = self.get_webcasts_view()
     
     self.source_view.connect("single-click-item", self.on_source_view_single_click_item)
     
     if WebcastsDB.isloaded():
         self.on_webcastsdb_loaded()
     else:    
         self.connect_to_webcastsdb()
         
     # Dispatcher
     Dispatcher.connect("webcast-info", self.on_dispatcher_webcast_info)    
     Dispatcher.connect("clear-sourcebar-status", lambda obj: self.clear_sourcebar_status())
     
     # Used to switch categroy view.
     self.switch_view_box = gtk.VBox()
     self.switch_view_box.add(self.source_sw)
     
     body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True)
     body_paned.add1(self.sourcebar)
     body_paned.add2(self.switch_view_box)
     
     self.add(body_paned)
     self.show_all()
    def __init__(self):
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)

        # Init categorys.
        self.get_categorys()
        
        # load data.
        self.__load_webcast_query()
        
        # Init webcastbar.
        self.__init_webcastbar()
        
        # Init iconview.
        self.metro_view = self.get_icon_view()
        self.metro_view_sw = self.metro_view.get_scrolled_window()
        
        self.page_box = gtk.VBox()
        self.page_box.add(self.metro_view_sw)
        
        
        # webcasts view
        self.webcast_view = self.get_webcast_view()
        self.webcast_view_sw = self.webcast_view.get_scrolled_window()
        
        # collect view
        self.collected_db_file = get_config_file("favorite_webcasts.db")
        self.collected_view = self.get_webcast_view()
        self.collected_view_sw = self.collected_view.get_scrolled_window()
        
        # Init collect view.
        
        # init listview page.
        self.init_listview_page()
        Dispatcher.connect("change-webcast", self.on_dispatcher_change_webcast)
        WebcastDB.connect("changed", self.on_db_update_songs)
        
        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True)
        body_paned.add1(self.webcastbar)
        body_paned.add2(self.page_box)
        self.add(body_paned)
    def __init__(self):
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)

        # Init categorys.
        self.get_categorys()

        # load data.
        self.__load_webcast_query()

        # Init webcastbar.
        self.__init_webcastbar()

        # Init iconview.
        self.metro_view = self.get_icon_view()
        self.metro_view_sw = self.metro_view.get_scrolled_window()

        self.page_box = gtk.VBox()
        self.page_box.add(self.metro_view_sw)

        # webcasts view
        self.webcast_view = self.get_webcast_view()
        self.webcast_view_sw = self.webcast_view.get_scrolled_window()

        # collect view
        self.collected_db_file = get_config_file("favorite_webcasts.db")
        self.collected_view = self.get_webcast_view()
        self.collected_view_sw = self.collected_view.get_scrolled_window()

        # Init collect view.

        # init listview page.
        self.init_listview_page()
        Dispatcher.connect("change-webcast", self.on_dispatcher_change_webcast)
        WebcastDB.connect("changed", self.on_db_update_songs)

        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"),
                            enable_drag=True)
        body_paned.add1(self.webcastbar)
        body_paned.add2(self.page_box)
        self.add(body_paned)
    def __init__(self, db_query):
        
        # Init.
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)
        
        self.__db_query = db_query
        self.update_interval = 3000 # 3000 millisecond.
        self.reload_flag = False
        self.search_flag = False
        self.cache_search_list = []
        self.cache_search_view = []
        self.__selected_tag = {"album": [], "artist": [], "genre": []}
        Dispatcher.connect("reload-browser", self.on_dispatcher_reload_browser)
        gobject.timeout_add(self.update_interval, self.on_interval_loaded_view)
        
        # The saving song Classification presented to the user.
        self.artists_view, self.artists_sw  = self.get_icon_view(14)
        self.albums_view,  self.albums_sw   = self.get_icon_view(14)
        self.genres_view,  self.genres_sw   = self.get_icon_view(14)
        self.folders_view, self.folders_sw  = self.get_icon_view(20)
        self.folders_view.connect("motion-notify-item", self.on_folders_view_motion_notify)
        
        # Song list for temporarily storing
        # self.songs_view, self.songs_view_sw = self.get_song_view()
        self.songs_view = self.get_song_view()
        
        # Classification navigation bar.
        self.filterbar = OptionBar(
            [(app_theme.get_pixbuf("filter/artist_normal.png"), app_theme.get_pixbuf("filter/artist_press.png"),
              _("Artist"), lambda : self.switch_filter_view("artist")),
             (app_theme.get_pixbuf("filter/album_normal.png"), app_theme.get_pixbuf("filter/album_press.png"),
              _("Album"), lambda : self.switch_filter_view("album")),
             (app_theme.get_pixbuf("filter/genre_normal.png"), app_theme.get_pixbuf("filter/genre_press.png"),
              _("Genre"), lambda : self.switch_filter_view("genre")),
             (app_theme.get_pixbuf("filter/local_normal.png"), app_theme.get_pixbuf("filter/local_press.png"),
              _("Folder"), lambda : self.switch_filter_view("folder"))
             ])
        
        # Manage the media library (import, refresh)
        self.importbar = SongImportBar()
        self.importbar.reload_items(
            [
             (_("Quick Scan"), lambda : ImportFolderJob([os.path.expanduser("~")])),                
             (_("Scan"), lambda : ImportFolderJob()),
             (_("Refresh"), lambda : ReloadDBJob())
             ])
        
        # Left box
        invailed_box = gtk.VBox()
        invailed_box.set_size_request(-1, 10)
        left_vbox = gtk.VBox(spacing=10)
        left_vbox.set_size_request(121, -1)
        # left_vbox.pack_start(invailed_box, False, True)
        left_vbox.pack_start(self.filterbar, False, False)
        left_vbox.pack_start(create_separator_box(), False, False)
        left_vbox.pack_start(self.importbar, False, False)
        
        # Used to switch songs category view, in the right side of the layout.
        self.switch_view_box = gtk.VBox()
        self.switch_view_box.add(self.artists_sw)
        # self.switch_view_box.add(TaskView())

        
        # Control back on a view.
        self.back_hbox = gtk.HBox()
        self.back_hbox.set_size_request(-1, 26)
        self.back_hbox.set_no_show_all(True)
        self.back_button = BackButton()
        self.back_button.connect("clicked", self.on_back_button_clicked)
        self.prompt_button = PromptButton()
        self.back_hbox.pack_start(self.back_button, False, False, 5)
        self.back_hbox.pack_start(self.prompt_button, False, False)
        
        # searchbar 
        self.search_entry, search_align = self.get_search_entry()
        search_hbox = gtk.HBox()
        search_hbox.pack_start(self.back_hbox, False, False)
        search_hbox.pack_start(create_right_align(), True, True)
        # search_hbox.pack_start(search_align, False, False)
        search_hbox_align = gtk.Alignment()
        search_hbox_align.set_padding(5, 0, 0, 0)
        search_hbox_align.set(0, 0, 1, 1)
        search_hbox_align.add(search_hbox)
        
        # Layout on the right.
        content_box = gtk.VBox(spacing=5)
        content_box.pack_start(search_hbox_align, False, False)
        content_box.pack_start(self.switch_view_box, True, True)
        
        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True)
        body_paned.add1(left_vbox)
        body_paned.add2(content_box)
        
        self.pack_start(body_paned, True, True)
Beispiel #6
0
    def __init__(self, db_query):

        # Init.
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)

        self.__db_query = db_query
        self.update_interval = 3000  # 3000 millisecond.
        self.reload_flag = False
        self.search_flag = False
        self.cache_search_list = []
        self.cache_search_view = []
        self.__selected_tag = {"album": [], "artist": [], "genre": []}
        Dispatcher.connect("reload-browser", self.on_dispatcher_reload_browser)
        gobject.timeout_add(self.update_interval, self.on_interval_loaded_view)

        # The saving song Classification presented to the user.
        self.artists_view, self.artists_sw = self.get_icon_view(14)
        self.albums_view, self.albums_sw = self.get_icon_view(14)
        self.genres_view, self.genres_sw = self.get_icon_view(14)
        self.folders_view, self.folders_sw = self.get_icon_view(20)
        self.folders_view.connect("motion-notify-item",
                                  self.on_folders_view_motion_notify)

        # Song list for temporarily storing
        # self.songs_view, self.songs_view_sw = self.get_song_view()
        self.songs_view = self.get_song_view()

        # Classification navigation bar.
        self.filterbar = OptionBar([
            (app_theme.get_pixbuf("filter/artist_normal.png"),
             app_theme.get_pixbuf("filter/artist_press.png"), _("Artist"),
             lambda: self.switch_filter_view("artist")),
            (app_theme.get_pixbuf("filter/album_normal.png"),
             app_theme.get_pixbuf("filter/album_press.png"), _("Album"),
             lambda: self.switch_filter_view("album")),
            (app_theme.get_pixbuf("filter/genre_normal.png"),
             app_theme.get_pixbuf("filter/genre_press.png"), _("Genre"),
             lambda: self.switch_filter_view("genre")),
            (app_theme.get_pixbuf("filter/local_normal.png"),
             app_theme.get_pixbuf("filter/local_press.png"), _("Folder"),
             lambda: self.switch_filter_view("folder"))
        ])

        # Manage the media library (import, refresh)
        self.importbar = SongImportBar()
        self.importbar.reload_items([
            (_("Quick Scan"),
             lambda: ImportFolderJob([os.path.expanduser("~")])),
            (_("Scan"), lambda: ImportFolderJob()),
            (_("Refresh"), lambda: ReloadDBJob())
        ])

        # Left box
        invailed_box = gtk.VBox()
        invailed_box.set_size_request(-1, 10)
        left_vbox = gtk.VBox(spacing=10)
        left_vbox.set_size_request(121, -1)
        # left_vbox.pack_start(invailed_box, False, True)
        left_vbox.pack_start(self.filterbar, False, False)
        left_vbox.pack_start(create_separator_box(), False, False)
        left_vbox.pack_start(self.importbar, False, False)

        # Used to switch songs category view, in the right side of the layout.
        self.switch_view_box = gtk.VBox()
        self.switch_view_box.add(self.artists_sw)
        # self.switch_view_box.add(TaskView())

        # Control back on a view.
        self.back_hbox = gtk.HBox()
        self.back_hbox.set_size_request(-1, 26)
        self.back_hbox.set_no_show_all(True)
        self.back_button = BackButton()
        self.back_button.connect("clicked", self.on_back_button_clicked)
        self.prompt_button = PromptButton()
        self.back_hbox.pack_start(self.back_button, False, False, 5)
        self.back_hbox.pack_start(self.prompt_button, False, False)

        # searchbar
        self.search_entry, search_align = self.get_search_entry()
        search_hbox = gtk.HBox()
        search_hbox.pack_start(self.back_hbox, False, False)
        search_hbox.pack_start(create_right_align(), True, True)
        # search_hbox.pack_start(search_align, False, False)
        search_hbox_align = gtk.Alignment()
        search_hbox_align.set_padding(5, 0, 0, 0)
        search_hbox_align.set(0, 0, 1, 1)
        search_hbox_align.add(search_hbox)

        # Layout on the right.
        content_box = gtk.VBox(spacing=5)
        content_box.pack_start(search_hbox_align, False, False)
        content_box.pack_start(self.switch_view_box, True, True)

        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"),
                            enable_drag=True)
        body_paned.add1(left_vbox)
        body_paned.add2(content_box)

        self.pack_start(body_paned, True, True)
class RadioBrowser(gtk.VBox):
    
    def __init__(self):
        gtk.VBox.__init__(self)
        
        # Init radiobar.
        self.__init_radiobar()
        
        # is loaded.
        self.homepage_load_flag = False
        self.home_page = HomePage()
        
        self.hot_page_view, self.hot_page_sw = self.get_radio_icon_view(TAG_HOT, 20)
        self.fast_page_view, self.fast_page_sw = self.get_radio_icon_view(TAG_FAST, 20)
        
        # Genres page
        self.genre_page = GenrePage()
        
        self.page_box = gtk.VBox()
        self.page_box.add(self.home_page)
        
        self.body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"))
        self.body_paned.add1(self.radiobar)
        self.body_paned.add2(self.page_box)
        self.network_failed_box = NetworkConnectFailed(self.check_network_connection)
        self.check_network_connection(auto=True)
        
        
    def check_network_connection(self, auto=False):    
        if is_network_connected():
            switch_tab(self, self.body_paned)
            if not auto:
                self.start_fetch_channels()
        else:    
            switch_tab(self, self.network_failed_box)
            
    def __init_radiobar(self):    
        self.radiobar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
        items = []
        items.append(CategroyTreeItem(_("Home"), "home",  lambda : switch_tab(self.page_box, self.home_page)))
        items.append(CategroyTreeItem(_("Hot MHz"), "hot", lambda : switch_tab(self.page_box, self.hot_page_sw)))
        items.append(CategroyTreeItem(_("Genres MHz"), "genre",  lambda : switch_tab(self.page_box, self.genre_page)))
        items.append(CategroyTreeItem(_("Pop MHz"), "up", lambda : switch_tab(self.page_box, self.fast_page_sw)))        
        self.radiobar.add_items(items)
        self.radiobar.select_items([self.radiobar.visible_items[0]])
        self.radiobar.set_size_request(121, -1)
        self.radiobar.draw_mask = self.on_radiobar_draw_mask        
        
    def on_radiobar_draw_mask(self, cr, x, y, w, h):    
        draw_alpha_mask(cr, x, y, w, h ,"layoutRight")
    
    def get_radio_icon_view(self, tag, limit=10, padding_x=0, padding_y=10):
        icon_view = RadioIconView(tag=tag, limit=limit, padding_x=padding_x, padding_y=padding_y)
        scrolled_window = icon_view.get_scrolled_window()
        return icon_view, scrolled_window
    
    def start_fetch_channels(self):
        self.fast_page_view.clear_items()
        self.hot_page_view.clear_items()
        self.home_page.start_fetch_channels()
        self.hot_page_view.start_fetch_channels()
        self.fast_page_view.start_fetch_channels()
        self.genre_page.start_fetch_channels()
Beispiel #8
0
class RadioBrowser(gtk.VBox):
    def __init__(self):
        gtk.VBox.__init__(self)

        # Init radiobar.
        self.__init_radiobar()

        # is loaded.
        self.homepage_load_flag = False
        self.home_page = HomePage()

        self.hot_page_view, self.hot_page_sw = self.get_radio_icon_view(
            TAG_HOT, 20)
        self.fast_page_view, self.fast_page_sw = self.get_radio_icon_view(
            TAG_FAST, 20)

        # Genres page
        self.genre_page = GenrePage()

        self.page_box = gtk.VBox()
        self.page_box.add(self.home_page)

        self.body_paned = HPaned(
            handle_color=app_theme.get_color("panedHandler"))
        self.body_paned.add1(self.radiobar)
        self.body_paned.add2(self.page_box)
        self.network_failed_box = NetworkConnectFailed(
            self.check_network_connection)
        self.check_network_connection(auto=True)

    def check_network_connection(self, auto=False):
        if is_network_connected():
            switch_tab(self, self.body_paned)
            if not auto:
                self.start_fetch_channels()
        else:
            switch_tab(self, self.network_failed_box)

    def __init_radiobar(self):
        self.radiobar = TreeView(enable_drag_drop=False,
                                 enable_multiple_select=False)
        items = []
        items.append(
            CategroyTreeItem(
                _("Home"), "home",
                lambda: switch_tab(self.page_box, self.home_page)))
        items.append(
            CategroyTreeItem(
                _("Hot MHz"), "hot",
                lambda: switch_tab(self.page_box, self.hot_page_sw)))
        items.append(
            CategroyTreeItem(
                _("Genres"), "genre",
                lambda: switch_tab(self.page_box, self.genre_page)))
        items.append(
            CategroyTreeItem(
                _("Pop MHz"), "up",
                lambda: switch_tab(self.page_box, self.fast_page_sw)))
        self.radiobar.add_items(items)
        self.radiobar.select_items([self.radiobar.visible_items[0]])
        self.radiobar.set_size_request(121, -1)
        self.radiobar.draw_mask = self.on_radiobar_draw_mask

    def on_radiobar_draw_mask(self, cr, x, y, w, h):
        draw_alpha_mask(cr, x, y, w, h, "layoutRight")

    def get_radio_icon_view(self, tag, limit=10, padding_x=0, padding_y=10):
        icon_view = RadioIconView(tag=tag,
                                  limit=limit,
                                  padding_x=padding_x,
                                  padding_y=padding_y)
        scrolled_window = icon_view.get_scrolled_window()
        return icon_view, scrolled_window

    def start_fetch_channels(self):
        self.fast_page_view.clear_items()
        self.hot_page_view.clear_items()
        self.home_page.start_fetch_channels()
        self.hot_page_view.start_fetch_channels()
        self.fast_page_view.start_fetch_channels()
        self.genre_page.start_fetch_channels()
Beispiel #9
0
    categorybar = Categorybar([
            (app_theme.get_pixbuf("categorybar/word.png"), "测试分类", lambda : osd_tooltip.show("OSD tooltip lonoooooooo")),
            (app_theme.get_pixbuf("categorybar/win.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/web.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/professional.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/other.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/multimedia.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/graphics.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/game.png"), "测试分类", None),
            (app_theme.get_pixbuf("categorybar/driver.png"), "测试分类", None),
            ])
    category_box.add1(categorybar)
    
    # Add scrolled window.
    scrolled_window = ScrolledWindow()
    category_box.add2(scrolled_window)
    
    items_length = 1000

    items = map(lambda index: ListItem(
            "豆浆油条 测试标题 %04d" % index,
            "林俊杰 %04d" % index,
            "10:%02d" % index,
            ), range(0, items_length))
    
    list_view = ListView(
        [(lambda item: item.title, cmp),
         (lambda item: item.artist, cmp),
         (lambda item: item.length, cmp)])
    list_view.set_expand_column(0)
    list_view.add_titles(["歌名", "歌手", "时间"])