Ejemplo n.º 1
0
    def __init__(self, util, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        m = self.factory.create_language_menu_button
        self.util = util
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      None,
                      None,
                      create_item_method=m)
        self.config = self.util.config
        language = self.config[CURRENT][LANGUAGE]

        languages = self.config[KEY_LANGUAGES]
        layout = self.get_layout(languages)
        button_rect = layout.constraints[0]
        self.languages = self.util.load_languages_menu(button_rect)
        self.set_items(self.languages, 0, self.change_language, False)
        self.current_language = self.languages[language]
        self.item_selected(self.current_language)
Ejemplo n.º 2
0
    def __init__(self, util, bgr=None, bounding_box=None, font_size=None):
        """ Initializer

        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.util = util
        self.factory = Factory(util)
        self.config = util.config
        self.cdutil = CdUtil(util)

        self.bb = bounding_box
        self.horizontal_layout = True
        self.rows = None
        self.cols = None
        items = self.get_menu_items()
        cell_bb = items[2]

        m = self.create_home_menu_button
        label_area = (cell_bb.h / 100) * (100 - ICON_AREA)
        font_size = int((label_area / 100) * FONT_HEIGHT)
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      None,
                      None,
                      create_item_method=m,
                      font_size=font_size)
        self.set_modes(*items)
Ejemplo n.º 3
0
 def __init__(self, playlist, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param playlist: playlist object
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """ 
     self.factory = Factory(util)
     self.util = util
     self.config = self.util.config
     m = self.factory.create_station_menu_button
     n = playlist.items_per_line
     bb = bounding_box
     bb.height += 0
     Menu.__init__(self, util, bgr, bb, n, n, create_item_method=m)
     self.bounding_box = bb
     self.playlist = playlist
     self.current_mode = self.STATION_MODE        
     s = self.util.load_icon(IMAGE_SHADOW, False)
     screen_height = self.config[SCREEN_INFO][HEIGHT]
     shadow_height = int((228 * screen_height)/320)
     self.shadow = (s[0], self.util.scale_image(s[1], (shadow_height, shadow_height)))
     self.selection = self.util.load_icon(IMAGE_SELECTION, False)
     self.station_button = None        
     self.init_station(self.config[CURRENT][STATION])
     self.menu_click_listeners = []
     self.mode_listeners = []
     self.keyboard_navigation = False
     self.page_turned = False
Ejemplo n.º 4
0
 def __init__(self, util, next_page, previous_page, set_title, reset_title, go_to_page, create_item, rows, columns, mbl, bgr=None, bounding_box=None, align=ALIGN_LEFT):
     """ Initializer
     
     :param util: utility object
     :param next_page: next page callback
     :param previous_page: previous page callback
     :param set_title: set title callback
     :param reset_title: reset title callback
     :param go_to_page: go to page callback
     :param create_item: create menu item method
     :param rows: menu rows
     :param columns: menu columns
     :param mbl: multi-line button layout
     :param bgr: menu background
     :param bounding_box: bounding box
     """ 
     self.next_page = next_page
     self.previous_page = previous_page
     self.set_title = set_title
     self.reset_title = reset_title
     self.go_to_page = go_to_page
     self.start_page_num = False
     self.current_page_num = ""
     self.current_page = 1
     Menu.__init__(self, util, bgr, bounding_box, rows, columns, create_item_method=create_item, menu_button_layout=mbl, align=align)        
Ejemplo n.º 5
0
 def __init__(self, util, bounding_box, listener):
     """ Initializer
     
     :param util: utility object
     :param bounding_box: bounding box
     :param listeners: buttons listeners
     """
     self.factory = Factory(util)
     m = self.create_cd_drive_menu_button
     label_area = (bounding_box.h / 100) * (100 - ICON_AREA)
     font_size = int((label_area / 100) * FONT_HEIGHT)
     r = Rect(bounding_box.x, bounding_box.y, bounding_box.w,
              bounding_box.h + 1)
     Menu.__init__(self,
                   util,
                   None,
                   r,
                   None,
                   None,
                   create_item_method=m,
                   font_size=font_size)
     self.name = "cd.drives.menu"
     self.content = bounding_box
     self.content_x = bounding_box.x
     self.content_y = bounding_box.y
     self.menu_buttons = []
     id = str(util.config[CD_PLAYBACK][CD_DRIVE_ID])
     if len(id) == 0:
         id = "0"
     self.select_by_index(int(id))
Ejemplo n.º 6
0
    def __init__(self, util, callback, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param callback: callback method
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        self.util = util
        self.config = util.config
        self.current_ch = ABC[0]

        m = self.create_latin_abc_menu_button
        font_size = int(((bounding_box.h / ROWS) / 100) * FONT_HEIGHT)
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      ROWS,
                      COLUMNS,
                      create_item_method=m,
                      font_size=font_size)
        self.config = util.config
        self.callback = callback
        self.chars = self.load_menu()
        self.set_items(self.chars, 0, self.abc_action, False)
        self.make_blank("foo")
        self.make_blank("bar")

        self.select_by_index(0)
Ejemplo n.º 7
0
 def __init__(self, items, util, bgr, bounding_box, listener):
     """ Initializer
     
     :param util: utility object
     :param bounding_box: bounding box
     :param listeners: buttons listeners
     :param bgr: menu background        
     """
     self.factory = Factory(util)
     m = self.factory.create_cd_drive_menu_button
     Menu.__init__(self,
                   util,
                   bgr,
                   bounding_box,
                   None,
                   None,
                   create_item_method=m)
     self.name = "cd.drives.menu"
     self.content = bounding_box
     self.content_x = bounding_box.x
     self.content_y = bounding_box.y
     self.menu_buttons = []
     id = str(util.config[CD_PLAYBACK][CD_DRIVE_ID])
     if len(id) == 0:
         id = "0"
     self.select_by_index(int(id))
Ejemplo n.º 8
0
    def __init__(self, util, show_authors, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param show_authors: callback method
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        self.util = util
        self.config = util.config
        self.current_ch = INITIAL_CHAR

        m = self.factory.create_cyrillic_menu_button
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      CHAR_ROWS,
                      CHAR_COLUMNS,
                      create_item_method=m)
        self.config = util.config
        self.show_authors = show_authors
        self.chars = self.load_menu()
        self.set_items(self.chars, 0, self.abc_action, False)
        i = self.get_index_by_name(self.current_ch)
        self.select_by_index(i)
Ejemplo n.º 9
0
    def __init__(self, util, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.util = util
        self.factory = Factory(util)

        m = self.create_language_menu_button
        Menu.__init__(self, util, bgr, bounding_box, None, None, create_item_method=m)
        self.config = self.util.config
        language = self.config[CURRENT][LANGUAGE] 
        
        languages = self.config[KEY_LANGUAGES]
        layout = self.get_layout(languages)        
        button_rect = layout.constraints[0]
        image_box = self.factory.get_icon_bounding_box(button_rect, ICON_LOCATION, ICON_AREA, ICON_SIZE, BUTTON_PADDING)
        self.languages = self.util.load_languages_menu(image_box)

        label_area = (button_rect.h / 100) * (100 - ICON_AREA)
        self.font_size = int((label_area / 100) * FONT_HEIGHT)

        self.set_items(self.languages, 0, self.change_language, False)
        self.current_language = self.languages[language]
        self.item_selected(self.current_language)
Ejemplo n.º 10
0
    def __init__(self,
                 playlist,
                 util,
                 mode=STATION,
                 bgr=None,
                 bounding_box=None):
        """ Initializer
        
        :param playlist: playlist object
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        self.util = util
        self.config = self.util.config
        self.image_util = util.image_util
        self.favorites_util = FavoritesUtil(self.util)
        m = self.create_station_menu_button
        bb = bounding_box
        self.menu_mode = mode
        Menu.__init__(self,
                      util,
                      bgr,
                      bb,
                      playlist.rows,
                      playlist.columns,
                      create_item_method=m)
        self.bounding_box = bb
        self.playlist = playlist
        self.current_mode = self.STATION_MODE

        path = os.path.join(FOLDER_ICONS, IMAGE_SHADOW + EXT_PNG)
        self.original_shadow = self.image_util.load_image(path,
                                                          bounding_box=(bb.w,
                                                                        bb.h))
        h = self.bounding_box.h
        self.shadow = (self.original_shadow[0],
                       self.image_util.scale_image(self.original_shadow[1],
                                                   (h, h)))
        self.shadow_component = None

        path = os.path.join(FOLDER_ICONS, IMAGE_SELECTION + EXT_PNG)
        self.selection = self.image_util.load_image(path)
        self.station_button = None
        self.menu_click_listeners = []
        self.mode_listeners = []
        self.change_logo_listeners = []
        self.page_turned = False
        self.genre = None
        self.current_logo_image = None
        self.current_logo_filename = None
        self.current_album_image = None
Ejemplo n.º 11
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """        
     self.factory = Factory(util)
     m = self.factory.create_genre_menu_button
     Menu.__init__(self, util, bgr, bounding_box, 3, 3, create_item_method=m)
     self.config = util.config
     current_genre_name = self.config[CURRENT][PLAYLIST]
     self.genres = util.load_menu(GENRE_ITEMS, GENRE)       
     self.set_items(self.genres, 0, self.change_genre, False, self.config[ORDER_GENRE_MENU])
     self.current_genre = self.genres[current_genre_name]
     self.item_selected(self.current_genre)
Ejemplo n.º 12
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """
     self.factory = Factory(util)
     m = self.factory.create_saver_menu_button
     Menu.__init__(self, util, bgr, bounding_box, 1, 4, create_item_method=m)
     self.config = util.config
     current_saver_name = self.config[CURRENT][KEY_SCREENSAVER]
     self.savers = util.load_menu(SCREENSAVER_ITEMS, GENRE)
     self.set_items(self.savers, 0, self.change_saver, False, self.config[ORDER_SCREENSAVER_MENU])
     self.current_saver = self.savers[current_saver_name]
     self.item_selected(self.current_saver)
Ejemplo n.º 13
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """
     self.factory = Factory(util)
     m = self.factory.create_saver_delay_menu_button
     Menu.__init__(self, util, bgr, bounding_box, 1, 3, create_item_method=m)
     self.config = util.config
     current_delay_name = self.config[CURRENT][KEY_SCREENSAVER_DELAY]
     delays = util.get_screensaver_delays()
     self.set_items(delays, 0, self.change_delay, False, self.config[ORDER_SCREENSAVER_DELAY_MENU])
     current_delay = delays[current_delay_name]
     self.item_selected(current_delay)
Ejemplo n.º 14
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """    
     self.factory = Factory(util)
     m = self.factory.create_language_menu_button
     Menu.__init__(self, util, bgr, bounding_box, 2, 2, create_item_method=m)
     config = util.config
     language = config[CURRENT][LANGUAGE]
     self.languages = util.load_menu(LANGUAGE_ITEMS, NAME)
     self.set_items(self.languages, 0, self.change_language, False, config[ORDER_LANGUAGE_MENU])
     self.current_language = self.languages[language]
     self.item_selected(self.current_language) 
Ejemplo n.º 15
0
    def __init__(self, util, bgr=None, bounding_box=None, font_size=None):
        """ Initializer

        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.util = util
        self.factory = Factory(util)
        self.config = util.config
        m = self.factory.create_home_menu_button
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      None,
                      None,
                      create_item_method=m,
                      font_size=font_size)
        self.cdutil = CdUtil(util)
        self.set_modes()
Ejemplo n.º 16
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """
     self.factory = Factory(util)
     m = self.factory.create_saver_delay_menu_button
     Menu.__init__(self, util, bgr, bounding_box, 1, 3, create_item_method=m)
     self.config = util.config
     current_delay_name = self.config[SCREENSAVER][DELAY]
     self.delays = util.get_screensaver_delays()
     
     if self.config[USAGE][USE_VOICE_ASSISTANT]:
         voice_commands = util.get_voice_commands()
         self.delays[KEY_SCREENSAVER_DELAY_1].voice_commands = [voice_commands["VA_ONE_MINUTE"].strip()]
         self.delays[KEY_SCREENSAVER_DELAY_3].voice_commands = [voice_commands["VA_THREE_MINUTES"].strip()]
         self.delays[KEY_SCREENSAVER_DELAY_OFF].voice_commands = [voice_commands["VA_OFF"].strip()]
     
     self.set_items(self.delays, 0, self.change_delay, False)
     current_delay = self.delays[current_delay_name]
     self.item_selected(current_delay)
Ejemplo n.º 17
0
    def __init__(self, util, bgr=None, bounding_box=None, font_size=None):
        """ Initializer

        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        :param font_size: labels font size
        """
        self.util = util
        self.factory = Factory(util)
        self.config = util.config
        dbutil = util.get_db_util()
        self.stats = dbutil.get_collection_summary()
        suffix = []
        items = []
        item_list = [
            GENRE, ARTIST, COMPOSER, ALBUM, TITLE, DATE, FOLDER, FILENAME, TYPE
        ]
        if self.config[USAGE][USE_VOICE_ASSISTANT]:
            command_list = [
                "VA_GENRE", "VA_ARTIST", "VA_COMPOSER", "VA_ALBUM", "VA_TITLE",
                "VA_DATE", "VA_FOLDER", "VA_FILENAME", "VA_TYPE"
            ]
            va_commands = self.util.get_voice_commands()

        for n, i in enumerate(item_list):
            if self.stats and self.config[COLLECTION][SHOW_NUMBERS]:
                suffix.append(self.stats[i])

            if i == FOLDER and self.config[COLLECTION_MENU][FOLDER]:
                items.append(KEY_AUDIO_FOLDER)
            elif i == FILENAME and self.config[COLLECTION_MENU][FILENAME]:
                items.append(KEY_FILE)
            elif self.config[COLLECTION_MENU][i]:
                items.append(i)

            if self.config[USAGE][USE_VOICE_ASSISTANT] and i in items:
                self.add_voice_command(i, command_list[n], va_commands)

        m = self.factory.create_home_menu_button
        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      None,
                      None,
                      create_item_method=m,
                      font_size=font_size)

        if not items:
            return

        l = self.get_layout(items)
        bounding_box = l.get_next_constraints()
        self.topics = self.util.load_menu(items,
                                          NAME, [],
                                          V_ALIGN_TOP,
                                          bb=bounding_box,
                                          scale=0.4,
                                          suffix=suffix)
        self.set_items(self.topics, 0, self.change_topic, False)

        topic = self.config[COLLECTION_PLAYBACK][COLLECTION_TOPIC]
        if topic:
            for k in self.topics.keys():
                if k == topic:
                    self.current_topic = self.topics[k]
                    break
        else:
            self.current_topic = self.topics[items[0]]

        self.item_selected(self.current_topic)
Ejemplo n.º 18
0
    def __init__(self, filelist, util, playlist_provider, bounding_box=None, align=ALIGN_CENTER, icon_box=None, icon_box_without_label=None):
        """ Initializer
        
        :param filelist: file list
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        self.util = util
        self.cdutil = CdUtil(self.util)
        self.playlist_provider = playlist_provider
        self.config = self.util.config
        self.filelist = filelist
        self.icon_box = icon_box
        self.icon_box_without_label = icon_box_without_label

        m = self.create_file_menu_button
        self.bounding_box = bounding_box
        bgr = util.config[BACKGROUND][MENU_BGR_COLOR]
        
        r = c = 3
        if filelist:
            r = filelist.rows
            c = filelist.columns

        h = self.config[HORIZONTAL_LAYOUT]
        button_height = (self.bounding_box.h / r) - (self.config[PADDING] * 2)

        if self.config[ALIGN_BUTTON_CONTENT_X] == 'center':
            font_size = int(((100 - self.config[IMAGE_AREA]) / 100) * self.config[FONT_HEIGHT_PERCENT])
        else:
            font_size = int((button_height / 100) * self.config[FONT_HEIGHT_PERCENT])

        Menu.__init__(self, util, bgr, self.bounding_box, r, c, create_item_method=m, align=align, horizontal_layout=h, font_size=font_size)

        self.browsing_history = {}        
        self.left_number_listeners = []
        self.right_number_listeners = []
        self.change_folder_listeners = []
        self.play_file_listeners = []
        self.playlist_size_listeners = []
        self.menu_navigation_listeners = []
        self.page_turned = False
        self.separator = os.sep
        self.empty_state = State()
        url = selection = None
        self.current_folder = self.config[FILE_PLAYBACK][CURRENT_FOLDER]
        folder = self.current_folder

        playback_mode = self.config[FILE_PLAYBACK][CURRENT_FILE_PLAYBACK_MODE]
        if playback_mode == FILE_AUDIO or playback_mode == FILE_RECURSIVE:
            if not self.current_folder.endswith(os.sep):
                self.current_folder += os.sep                
                        
            if self.config[CURRENT][MODE] == CD_PLAYER:
                cd_drive_name = self.config[CD_PLAYBACK][CD_DRIVE_NAME]
                track = self.config[CD_PLAYBACK][CD_TRACK]
                url = self.cdutil.get_cd_track_url(cd_drive_name, track)
            else:
                url = self.current_folder + self.config[FILE_PLAYBACK][CURRENT_FILE]                            
        elif playback_mode == FILE_PLAYLIST:
            url = self.config[FILE_PLAYBACK][CURRENT_FILE]
            self.browsing_history[self.current_folder] = 0
            p = self.current_folder + self.separator + self.config[FILE_PLAYBACK][CURRENT_FILE_PLAYLIST]
            self.browsing_history[p] = 0
            folder = p
            self.current_folder = folder
        selection = url
        
        if url and self.filelist:        
            self.filelist.set_current_item_by_url(url)
        
        p_index = self.filelist.current_page_index
        pl = self.filelist.items
        self.change_folder(folder, page_index=p_index, playlist=pl, selected=selection)            
Ejemplo n.º 19
0
 def __init__(self, util, bgr=None, bounding_box=None, font_size=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """   
     self.factory = Factory(util)
     self.config = util.config
     m = self.factory.create_home_menu_button
     Menu.__init__(self, util, bgr, bounding_box, None, None, create_item_method=m, font_size=font_size)
     cdutil = CdUtil(util)
     
     items = []
     disabled_items = []
     
     if self.config[HOME_MENU][RADIO]: 
         items.append(RADIO)
         if not util.is_radio_enabled() or not util.connected_to_internet:
             disabled_items.append(RADIO)
             
     if self.config[HOME_MENU][AUDIO_FILES]: 
         items.append(AUDIO_FILES)
         
     if self.config[HOME_MENU][AUDIOBOOKS]: 
         items.append(AUDIOBOOKS)
         if not util.is_audiobooks_enabled() or not util.connected_to_internet:
             disabled_items.append(AUDIOBOOKS)
             
     if self.config[HOME_MENU][STREAM]:
         items.append(STREAM)
         if not util.connected_to_internet:
             disabled_items.append(STREAM)
             
     if self.config[HOME_MENU][CD_PLAYER]: 
         cd_drives_info = cdutil.get_cd_drives_info()
         player = self.config[AUDIO][PLAYER_NAME]
         if len(cd_drives_info) == 0:
             disabled_items.append(CD_PLAYER)
         items.append(CD_PLAYER)
     
     l = self.get_layout(items)
     bounding_box = l.get_next_constraints()
     self.modes = util.load_menu(items, NAME, disabled_items, V_ALIGN_TOP, bb=bounding_box, scale=0.5)
     va_commands = self.util.get_voice_commands()
     
     if self.config[USAGE][USE_VOICE_ASSISTANT]:
         if self.config[HOME_MENU][RADIO]:
             r = [va_commands["VA_RADIO"].strip(), va_commands["VA_GO_RADIO"].strip()]
             self.modes[RADIO].voice_commands = r            
         if self.config[HOME_MENU][AUDIO_FILES]:
             f = [va_commands["VA_FILES"].strip(), va_commands["VA_GO_FILES"].strip(), va_commands["VA_AUDIO_FILES"].strip()]
             self.modes[AUDIO_FILES].voice_commands = f
         if self.config[HOME_MENU][AUDIOBOOKS]:    
             a = [va_commands["VA_AUDIOBOOKS"].strip(), va_commands["VA_BOOKS"].strip(), va_commands["VA_GO_BOOKS"].strip()]
             self.modes[AUDIOBOOKS].voice_commands = a
         if self.config[HOME_MENU][STREAM]:    
             s = [va_commands["VA_STREAM"].strip(), va_commands["VA_GO_STREAM"].strip()]
             self.modes[STREAM].voice_commands = s
         if self.config[HOME_MENU][CD_PLAYER]:    
             s = [va_commands["VA_CD_PLAYER"].strip()]
             self.modes[STREAM].voice_commands = s
         
     if not items:
         return
     
     if not self.config[CURRENT][MODE]:
         for i in items:
             if i not in disabled_items:            
                 mode = i
                 break            
     else:
         mode = self.config[CURRENT][MODE]
     
     self.set_items(self.modes, 0, self.change_mode, False)
     self.current_mode = self.modes[mode.lower()]
     self.item_selected(self.current_mode) 
Ejemplo n.º 20
0
    def __init__(self, util, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        m = self.factory.create_saver_menu_button
        self.config = util.config

        items = []
        if self.config[SCREENSAVER_MENU][CLOCK]: items.append(CLOCK)
        if self.config[SCREENSAVER_MENU][LOGO]: items.append(LOGO)
        if self.config[SCREENSAVER_MENU][SLIDESHOW]: items.append(SLIDESHOW)
        if self.config[SCREENSAVER_MENU][VUMETER]: items.append(VUMETER)
        if self.config[SCREENSAVER_MENU][WEATHER]: items.append(WEATHER)
        if self.config[SCREENSAVER_MENU][SPECTRUM]: items.append(SPECTRUM)

        Menu.__init__(self,
                      util,
                      bgr,
                      bounding_box,
                      2,
                      None,
                      create_item_method=m)

        current_saver_name = items[0]
        for s in items:
            if s == self.config[SCREENSAVER][NAME]:
                current_saver_name = s
                break

        l = self.get_layout(items)
        bounding_box = l.get_next_constraints()
        self.savers = util.load_menu(items,
                                     GENRE,
                                     v_align=V_ALIGN_TOP,
                                     bb=bounding_box,
                                     scale=0.4)

        if self.config[USAGE][USE_VOICE_ASSISTANT]:
            voice_commands = util.get_voice_commands()
            self.savers[CLOCK].voice_commands = [
                voice_commands["VA_CLOCK"].strip()
            ]
            self.savers[LOGO].voice_commands = [
                voice_commands["VA_LOGO"].strip()
            ]
            self.savers[SLIDESHOW].voice_commands = [
                voice_commands["VA_SLIDESHOW"].strip()
            ]
            self.savers[VUMETER].voice_commands = [
                voice_commands["VA_INDICATOR"].strip()
            ]
            self.savers[WEATHER].voice_commands = [
                voice_commands["VA_WEATHER"].strip()
            ]

        self.set_items(self.savers, 0, self.change_saver, False)
        self.current_saver = self.savers[current_saver_name]
        self.item_selected(self.current_saver)
Ejemplo n.º 21
0
    def __init__(self,
                 filelist,
                 util,
                 playlist_provider,
                 bgr=None,
                 bounding_box=None,
                 align=ALIGN_CENTER):
        """ Initializer
        
        :param filelist: file list
        :param util: utility object
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.factory = Factory(util)
        self.util = util
        self.cdutil = CdUtil(self.util)
        self.playlist_provider = playlist_provider
        self.config = self.util.config
        self.filelist = filelist
        m = self.factory.create_file_menu_button
        self.bounding_box = bounding_box

        r = c = 3
        if filelist:
            r = filelist.rows
            c = filelist.columns
        Menu.__init__(self,
                      util,
                      bgr,
                      self.bounding_box,
                      r,
                      c,
                      create_item_method=m,
                      align=align,
                      button_padding_x=5)

        self.browsing_history = {}
        self.left_number_listeners = []
        self.right_number_listeners = []
        self.change_folder_listeners = []
        self.play_file_listeners = []
        self.playlist_size_listeners = []
        self.menu_navigation_listeners = []
        self.page_turned = False
        self.separator = os.sep
        self.empty_state = State()
        url = selection = None
        self.current_folder = self.config[FILE_PLAYBACK][CURRENT_FOLDER]
        folder = self.current_folder

        playback_mode = self.config[FILE_PLAYBACK][CURRENT_FILE_PLAYBACK_MODE]
        if playback_mode == FILE_AUDIO or playback_mode == FILE_RECURSIVE:
            if not self.current_folder.endswith(os.sep):
                self.current_folder += os.sep

            if self.config[CURRENT][MODE] == CD_PLAYER:
                cd_drive_name = self.config[CD_PLAYBACK][CD_DRIVE_NAME]
                track = self.config[CD_PLAYBACK][CD_TRACK]
                url = self.cdutil.get_cd_track_url(cd_drive_name, track)
            else:
                url = self.current_folder + self.config[FILE_PLAYBACK][
                    CURRENT_FILE]
        elif playback_mode == FILE_PLAYLIST:
            url = self.config[FILE_PLAYBACK][CURRENT_FILE]
            self.browsing_history[self.current_folder] = 0
            p = self.current_folder + self.separator + self.config[
                FILE_PLAYBACK][CURRENT_FILE_PLAYLIST]
            self.browsing_history[p] = 0
            folder = p
            self.current_folder = folder
        selection = url

        if url and self.filelist:
            self.filelist.set_current_item_by_url(url)

        p_index = self.filelist.current_page_index
        pl = self.filelist.items
        self.change_folder(folder,
                           page_index=p_index,
                           playlist=pl,
                           selected=selection)

        if not self.config[FILE_PLAYBACK][CURRENT_FOLDER] and not self.config[
                FILE_PLAYBACK][CURRENT_FILE]:
            self.select_first_item()
Ejemplo n.º 22
0
 def __init__(self, util, bgr=None, bounding_box=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bounding_box: bounding box
     """
     self.factory = Factory(util)
     self.config = util.config
     
     items = []
     if self.config[SCREENSAVER_MENU][CLOCK]: items.append(CLOCK)
     if self.config[SCREENSAVER_MENU][LOGO]: items.append(LOGO)
     if self.config[SCREENSAVER_MENU][SLIDESHOW]: items.append(SLIDESHOW)
     if self.config[SCREENSAVER_MENU][VUMETER]: items.append(VUMETER)
     if self.config[SCREENSAVER_MENU][WEATHER]: items.append(WEATHER)
     if self.config[SCREENSAVER_MENU][SPECTRUM]: items.append(SPECTRUM)
     if self.config[SCREENSAVER_MENU][LYRICS]: items.append(LYRICS)
     if self.config[SCREENSAVER_MENU][RANDOM]: items.append(RANDOM)
     
     rows_num = 2
     cols_num = 4
     length = len(items)
     
     if length == 6 or length == 5:
         rows_num = 2
         cols_num = 3
     elif length == 4:
         rows_num = 2
         cols_num = 2
     elif length == 3:
         rows_num = 1
         cols_num = 3
     elif length == 2:
         rows_num = 1
         cols_num = 2
     elif length == 1:
         rows_num = 1
         cols_num = 1
     
     m = self.create_saver_menu_button
     label_area = (bounding_box.h / rows_num / 100) * (100 - ICON_AREA)
     font_size = int((label_area / 100) * FONT_HEIGHT)
     Menu.__init__(self, util, bgr, bounding_box, rows=rows_num, cols=cols_num, create_item_method=m, font_size=font_size)
             
     current_saver_name = items[0]
     for s in items:
         if s == self.config[SCREENSAVER][NAME]:
             current_saver_name = s
             break
     
     l = self.get_layout(items)
     bounding_box = l.get_next_constraints()
     box = self.factory.get_icon_bounding_box(bounding_box, ICON_LOCATION, ICON_AREA, ICON_SIZE, BUTTON_PADDING)
     box.w = box.w / 2
     self.savers = util.load_menu(items, GENRE, v_align=V_ALIGN_TOP, bb=box)
     
     if self.config[USAGE][USE_VOICE_ASSISTANT]:
         voice_commands = util.get_voice_commands()
         self.savers[CLOCK].voice_commands = [voice_commands["VA_CLOCK"].strip()]
         self.savers[LOGO].voice_commands = [voice_commands["VA_LOGO"].strip()]
         self.savers[SLIDESHOW].voice_commands = [voice_commands["VA_SLIDESHOW"].strip()]
         self.savers[VUMETER].voice_commands = [voice_commands["VA_INDICATOR"].strip()]
         self.savers[WEATHER].voice_commands = [voice_commands["VA_WEATHER"].strip()]
     
     self.set_items(self.savers, 0, self.change_saver, False)
     self.current_saver = self.savers[current_saver_name]
     self.item_selected(self.current_saver)