Exemplo n.º 1
0
    def item_selected(self, url, user_data):
        dia = EmcDialog(self._lbl,
                        style='list',
                        done_cb=self._dia_list_selected_cb)

        if self._mul:
            choosed = ini.get_string_list(self._sec, self._opt)
        else:
            choosed = [ini.get(self._sec, self._opt)]

        item = None
        for code2, (code3, code5, name) in sorted(utils.iso639_table.items(),
                                                  key=lambda x: x[1][2]):
            if name is not None:
                if code2 in choosed:
                    item = dia.list_item_append(name, end='icon/check_on')
                    item.data['code2'] = code2
                else:
                    it = dia.list_item_append(name)
                    it.data['code2'] = code2
        dia.list_go()

        if item:
            item.show()
            item.selected = True
Exemplo n.º 2
0
 def movies_dialog(self, movies):
     dia = EmcDialog(style='list', title=self.info['name'])
     for movie in sorted(movies.values(), key=itemgetter('title')):
         label = '<big>{}</big>'.format(movie['title'])
         if 'character' in movie:
             label += ' <i>{} <big>{}</big></i>'.format(
                 _('as'), movie['character'])
         if 'jobs' in movie:
             label += ' <i>({})</i>'.format(', '.join(movie['jobs']))
         dia.list_item_append(label, movie.get('poster_path'))
     dia.list_go()
Exemplo n.º 3
0
 def item_selected(self, url, user_data):
     dia = EmcDialog(self._lbl,
                     style='list',
                     done_cb=self._dia_list_selected_cb)
     for string in self._sli:
         if string == ini.get(self._sec, self._opt):
             it = dia.list_item_append(string, end='icon/check_on')
             it.selected = True
         else:
             dia.list_item_append(string)
     dia.list_go()
Exemplo n.º 4
0
    def grabbed_key_func(self, key):
        # ungrab remote keys & delete the first dialog
        self.grab_key_func = None
        self.pressed_key = key
        self.dia.delete()

        # create the dialog to choose the event to bind
        dia = EmcDialog(title=_('Choose an event to bind'),
                        style='list',
                        done_cb=self.event_choosed_cb)
        for event in input_events.STANDARD_EVENTS.split():
            dia.list_item_append(event)
        dia.list_go()
Exemplo n.º 5
0
 def item_selected(self, url, user_data):
     dia = EmcDialog(self._lbl,
                     style='list',
                     done_cb=self._dia_list_selected_cb)
     i = 0
     for string in self._vals:
         if i == ini.get_int(self._sec, self._opt):
             it = dia.list_item_append(string, end='icon/check_on')
             it.selected = True
         else:
             it = dia.list_item_append(string)
         it.data['i'] = i
         i += 1
     dia.list_go()
Exemplo n.º 6
0
def _vkeyb_layouts_list():
    dia = EmcDialog(title=_('Virtual keyboard layouts'),
                    style='list',
                    done_cb=_vkeyb_layouts_select_cb)
    dia.button_add(_('Close'),
                   selected_cb=_vkeyb_layouts_close_cb,
                   cb_data=dia)
    dia.button_add(_('Select'),
                   default=True,
                   selected_cb=_vkeyb_layouts_select_cb,
                   cb_data=dia)

    avail = ini.get_string_list('general', 'keyb_layouts')
    for k in sorted(gui.keyboard_layouts.keys()):
        name = gui.keyboard_layouts[k][0]
        end = 'icon/check_on' if k in avail else 'icon/check_off'
        it = dia.list_item_append(name, end=end)
        it.data['key'] = k
Exemplo n.º 7
0
class EmcFolderSelector(object):
    """
    Open a dialog that allow the user to choose a path on the filesystem.

    Args:
       title:
          The (optional) dialog title.
       done_cb:
          The (mandatory) function to call when the selection is done.
          Signature: func(path, **kargs)
       **kargs:
          Any other keyword arguments will be passed back in the done_cd func
    """

    def __init__(self, title=None, done_cb=None, **kargs):
        self._user_cb = done_cb
        self._user_kargs = kargs

        self._dialog = EmcDialog(title or _('Source Selector'), style='list')
        self._dialog.button_add(_('Select'), self._btn_select_cb)
        self._dialog.button_add(_('Browse'), self._btn_browse_cb, default=True)

        self.populate_devices()

    def populate_devices(self):
        self._dialog.list_clear()

        # other storage devices
        for dev in storage.list_devices():
            if dev.is_mounted:
                it = self._dialog.list_item_append(dev.label, dev.icon)
                it.data['root'] = it.data['path'] = dev.mount_point
        self._dialog.list_go()

    def populate_folder(self, root, folder):
        if folder == '':  # back in '/'
            self.populate_devices()
            return

        try:
            folders = os.listdir(folder)
        except PermissionError:
            EmcDialog(style='error', text=_('Permission denied'))
            return

        self._dialog.list_clear()

        # back item
        parent = os.path.normpath(os.path.join(folder, '..'))
        it = self._dialog.list_item_append(_('Back'), 'icon/back')
        it.data['root'] = root
        it.data['path'] = parent if parent != folder else ''  # back in '/'

        # folders
        for fname in utils.natural_sort(folders):
            fullpath = os.path.join(folder, fname)
            if fname[0] != '.' and os.path.isdir(fullpath):
                it = self._dialog.list_item_append(fname, 'icon/folder')
                it.data['root'] = root
                it.data['path'] = fullpath

        self._dialog.list_go()

    def _btn_browse_cb(self, btn):
        it = self._dialog.list_item_selected_get()
        if len(it.data['path']) < len(it.data['root']):
            self.populate_devices()
        else:
            self.populate_folder(it.data['root'], it.data['path'])

    def _btn_select_cb(self, btn):
        path = self._dialog.list_item_selected_get().data['path']
        if path and callable(self._user_cb):
            self._user_cb('file://' + path, **self._user_kargs)
        self._dialog.delete()
Exemplo n.º 8
0
 def photos_dialog(self):
     dia = EmcDialog(style='image_list_portrait', title=self.info['name'])
     for image in self.info['images']['profiles']:
         dia.list_item_append(None, image['file_path'])
     dia.list_go()
Exemplo n.º 9
0
    def item_selected(self, url, user_data):
        # main item selected, create the subpage
        if url == 'uitest://dialog':
            _browser.page_add(url, user_data, None, self.populate_subpage)

        # Dialog - Info
        elif url.endswith('/info'):
            print("DIALOG INFO", url, user_data)
            EmcDialog(title='Dialog - Info', text=LOREM, style='info')

        # Dialog - Warning
        elif url.endswith('/warning'):
            text = 'This is an <br><br><b>Warning</><br>dialog<br>'
            EmcDialog(title='Dialog - Warning', text=text, style='warning')

        # Dialog - Warning (no title)
        elif url.endswith('/warning2'):
            text = 'This is an <br><br><b>Warning</><br>dialog<br>'
            EmcDialog(text=text, style='warning')

        # Dialog - Error
        elif url.endswith('/error'):
            text = 'This is an <br><br><b>Error</><br>dialog<br>'
            EmcDialog(title='Dialog - Error', text=text, style='error')

        # Dialog - YesNo (with callbacks)
        elif url.endswith('/yesno1'):
            text = 'This is an <br><br><b>Yes/No</><br>dialog<br>'
            EmcDialog(title='Dialog - YesNo',
                      text=text,
                      style='yesno',
                      done_cb=lambda dia: print('done', dia),
                      canc_cb=lambda dia: print('canc', dia))

        # Dialog - YesNo (without callbacks)
        elif url.endswith('/yesno2'):
            text = 'This is an <br><br><b>Yes/No</><br>dialog<br>'
            EmcDialog(title='Dialog - YesNo', text=text, style='yesno')

        # Dialog - Cancel
        elif url.endswith('/cancel'):
            text = 'This is an <br><br><b>Cancel operation</><br>dialog<br>'
            EmcDialog(title='Dialog - Cancel',
                      text=text,
                      style='cancel',
                      spinner=True)

        # Dialog - Progress
        elif url.startswith('uitest://dialog/progress'):

            def _canc_cb(dialog):
                t.delete()
                d.delete()

            def _progress_timer():
                d.progress_set(self._progress)
                self._progress += 0.01
                if self._progress > 1:
                    self._progress = 0

            text = 'This is a <br><br><b>Progress operation</><br>dialog<br>'
            d = EmcDialog(title='Dialog - Progress',
                          text=text,
                          style='progress',
                          done_cb=_canc_cb,
                          canc_cb=_canc_cb)
            if url.endswith('btn'):
                d.button_add("btn1",
                             selected_cb=lambda b: print('btn1 callback'))
                d.button_add("btn2",
                             selected_cb=lambda b: print('btn2 callback'))
                d.button_add("btn3",
                             selected_cb=lambda b: print('btn3 callback'))
            self._progress = 0.0
            t = EmcTimer(0.2, _progress_timer)

        # Dialog - List
        elif url.endswith('/list'):

            def _dia_list_cb(dia):
                item = dia.list_item_selected_get()
                print('Selected: ' + str(item))
                # dia.delete()

            d = EmcDialog(title='Dialog - List',
                          style='list',
                          done_cb=_dia_list_cb)
            d.list_item_append('item 1', 'icon/home')
            d.list_item_append('item 2', 'icon/star', 'icon/check_on')
            d.list_item_append(
                'item 3 <b>bold</> <info>info</> '
                '<success>success</> <failure>failure</> '
                '<i>etc...</>', 'icon/star', 'icon/check_on')
            d.list_item_append('item 4', 'icon/tag', 'text/End Text')
            d.list_item_append('item 5', 'icon/tag',
                               'text/Styled <b>End</> <info>Text</>')
            d.list_item_append('item 6 ' + ('A really long text, ' * 6))
            for i in range(7, 101):
                d.list_item_append('item #%d' % i)
            d.list_go()

        # Dialog - List with buttons
        elif url.endswith('/list-btn'):
            d = EmcDialog(title='Dialog - List with buttons', style='list')
            for i in range(1, 40):
                d.list_item_append('item %d' % i)

            def _btn_cb(b):
                item = d.list_item_selected_get()
                print('Selected:', item)
                d.delete()

            d.button_add('One', selected_cb=_btn_cb)
            d.button_add('Two', selected_cb=_btn_cb)
            d.button_add('Tree', selected_cb=_btn_cb)
            d.list_go()

        # Dialog - Image list (landscape)
        elif url.endswith('/list-img-landscape'):
            d = EmcDialog(title=user_data,
                          style='image_list_landscape',
                          done_cb=lambda x, t: print(t))
            for i in range(20):
                d.list_item_append('item #%d' % i, self.backdrop)
            d.list_go()

        # Dialog - Image list (portrait)
        elif url.endswith('/list-img-portrait'):
            d = EmcDialog(title=user_data,
                          style='image_list_portrait',
                          done_cb=lambda x, t: print(t))
            for i in range(20):
                d.list_item_append('item #%d' % i, self.poster)
            d.list_go()

        # Dialog - Panel full
        elif url.endswith('/panel1'):
            d = EmcDialog(title='Dialog - Panel full',
                          text=LOREM * 8,
                          style='panel',
                          spinner=True)
            d.button_add('One', selected_cb=lambda b: print('btn1 callback'))
            d.button_add('Two', selected_cb=lambda b: print('btn2 callback'))
            d.button_add('Tree', selected_cb=lambda b: print('btn3 callback'))

        # Dialog - Panel full more
        elif url.endswith('/panel4'):
            d = EmcDialog(title='Dialog - Panel full more',
                          text=LOREM * 8,
                          style='panel',
                          spinner=False,
                          content='image/dvd_cover_blank.png')
            d.button_add('One', selected_cb=lambda b: print('btn1 callback'))
            d.button_add('Two', selected_cb=lambda b: print('btn2 callback'))
            d.button_add('Tree', selected_cb=lambda b: print('btn3 callback'))

        # Dialog - Panel no buttons
        elif url.endswith('/panel2'):
            text = LOREM
            d = EmcDialog(title='Dialog - Panel full',
                          text=text,
                          style='panel',
                          spinner=True)

        # Dialog - Panel no title
        elif url.endswith('/panel3'):
            text = LOREM
            d = EmcDialog(text=text, style='panel', spinner=True)

        # Dialog - Buffering ** TODO **
        elif url.endswith('/buffering'):

            def _progress_timer2():
                self._progress += 0.05
                d.progress_set(self._progress)
                if self._progress >= 1.0:
                    d.delete()
                    return False  # stop the timer
                else:
                    return True  # renew the callback

            d = EmcDialog(style='buffering', title=_('Buffering'))
            self._progress = 0.0
            EmcTimer(0.2, _progress_timer2)