Ejemplo n.º 1
0
    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 __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)
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()
Ejemplo n.º 4
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()