def signal_clicked_cb(self, gl, item):
        pp = Popup(self._parent)
        pp.part_text_set('title,text', 'Signal content')

        en = Entry(self, text=prettify_if_needed(item.data['args']))
        en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        en.size_hint_min = 800, 800  # TODO: this should be respected :/
        en.editable = False
        en.scrollable = True
        pp.content = en

        bt = Button(pp, text="Close")
        bt.callback_clicked_add(lambda b: pp.delete())
        pp.part_content_set('button2', bt)

        def prettify_clicked_cb(chk):
            options.pretty_output = chk.state
            en.text = prettify_if_needed(item.data['args'])

        ck = Check(pp, text="Prettify")
        ck.state = options.pretty_output
        ck.callback_changed_add(prettify_clicked_cb)
        pp.part_content_set('button1', ck)

        pp.show()
Example #2
0
    def content_get(self, obj, part, data):
        checked = data[1]

        # "edit" EDC layout is like below. each part is swallow part.
        # the existing item is swllowed to elm.swallow.edit.content part.
        # --------------------------------------------------------------------
        # | elm.edit.icon.1 | elm.swallow.decorate.content | elm.edit.icon,2 |
        # --------------------------------------------------------------------

        if part == "elm.swallow.end":
            ic = Icon(obj,
                      file=os.path.join(img_path, "bubble.png"),
                      size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
            return ic
        elif part == "elm.edit.icon.1":
            ck = Check(obj, state=checked, propagate_events=False)
            ck.show()
            return ck
        elif part == "elm.edit.icon.2":
            icn = Icon(obj,
                       file=os.path.join(img_path, "icon_06.png"),
                       propagate_events=False,
                       size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
            icn.callback_clicked_add(edit_icon_clicked_cb, data)
            return icn
        else:
            return
Example #3
0
    def _settings_open(self, obj, it):
        h = Hover(self)
        t = it.track_object
        h.pos = t.bottom_center
        del t
        del it.track_object

        l = List(h)
        l.mode = ELM_LIST_EXPAND
        h.part_content_set("bottom", l)
        l.show()

        chk = Check(self, text="Scroll By Page")
        chk.state = self.settings["scroll_by_page"]

        def _scroll_by_page_cb(obj):
            target_state = obj.state
            self.settings["scroll_by_page"] = target_state
            if self.tabs.currentContent:
                if target_state:
                    self.tabs.currentContent.scroll_freeze()
                else:
                    self.tabs.currentContent.scroll_thaw()
            h.dismiss()

        chk.callback_changed_add(_scroll_by_page_cb)

        l.item_append(None, chk)
        l.go()

        h.show()
    def content_get(self, obj, part, data):
        checked = data[1]

        # "edit" EDC layout is like below. each part is swallow part.
        # the existing item is swllowed to elm.swallow.edit.content part.
        # --------------------------------------------------------------------
        # | elm.edit.icon.1 | elm.swallow.decorate.content | elm.edit.icon,2 |
        # --------------------------------------------------------------------

        if part == "elm.swallow.end":
            ic = Icon(obj, file=os.path.join(img_path, "bubble.png"),
                size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
            return ic
        elif part == "elm.edit.icon.1":
            ck = Check(obj, state=checked, propagate_events=False)
            ck.show()
            return ck
        elif part == "elm.edit.icon.2":
            icn = Icon(obj, file=os.path.join(img_path, "icon_06.png"),
                propagate_events=False,
                size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
            icn.callback_clicked_add(edit_icon_clicked_cb, data)
            return icn
        else:
            return
def window_states_clicked(obj):
    win = Window("window-states", ELM_WIN_BASIC,
        title="Window States test", autodel=True, size=(280, 400))
    win.callback_moved_add(cb_win_moved)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    print(win.available_profiles)

    bg = Background(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
        size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    for state in [True, False]:
        bt = Button(win, text="Alpha " + ("On" if state else "Off"),
            size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_alpha, win, bg, state)
        hbox.pack_end(bt)
        bt.show()

    for state in [True, False]:
        bt = Button(win, text="FS " + ("On" if state else "Off"),
            size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_fullscreen, win, state)
        hbox.pack_end(bt)
        bt.show()

    sl = Slider(win, text="Visual test", indicator_format="%3.0f",
        min_max=(50, 150), value=50, inverted=True,
        size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, EVAS_HINT_FILL))
    vbox.pack_end(sl)
    sl.show()

    ck = Check(win, text="Resize on rotate", size_hint_align=(0.0, 0.0))
    vbox.pack_end(ck)
    ck.show()

    hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
        size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    for rot in [0, 90, 180, 270]:
        bt = Button(win, text="Rot " + str(rot), size_hint_align=FILL_HORIZ,
            size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_rot, win, ck, rot)
        hbox.pack_end(bt)
        bt.show()

    win.show()
Example #6
0
    def __init__(self, parent, app, branch):
        self.app = app
        self.branch = branch

        Popup.__init__(self, parent)
        self.part_text_set("title,text", "Delete branch")
        self.part_content_set("title,icon", Icon(self, standard="user-trash"))

        # main vertical box
        box = Box(self)
        self.content = box
        box.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        box.pack_end(sep)
        sep.show()

        # label
        en = Entry(
            self,
            editable=False,
            text="%s<br><br><hilight>%s</hilight><br>" % ("Are you sure you want to delete this branch?", branch.name),
            size_hint_expand=EXPAND_BOTH,
            size_hint_fill=FILL_BOTH,
        )
        box.pack_end(en)
        en.show()

        # force checkbox
        ck = Check(
            self,
            text="Force delete (even if not fully merged)",
            size_hint_expand=EXPAND_BOTH,
            size_hint_align=(0.0, 0.5),
        )
        box.pack_end(ck)
        ck.show()
        self.force_chk = ck

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        box.pack_end(sep)
        sep.show()

        bt = Button(self, text="Cancel")
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set("button1", bt)
        bt.show()

        bt = Button(self, text="Delete branch")
        bt.callback_clicked_add(self._delete_btn_cb)
        self.part_content_set("button2", bt)
        bt.show()

        #
        self.show()
Example #7
0
    def __init__(self, parent, app):
        PushPullBase.__init__(self, parent, app,
                              'Push changes to the remote', 'git-push')
        self.remote_combo.guide = 'Where to push to'
        self.rbranch_combo.guide = 'The remote branch to push to'
        self.action_btn.text = 'Push'

        ck = Check(self, text='dry-run (only simulate the operation)', 
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(1.0, 0.5))
        self.table.pack(ck, 0, 6, 2, 1)
        ck.show()
        self.dryrun_chk = ck
Example #8
0
    def _gl_content_get(self, li, part, item_data):
        if isinstance(item_data, tuple): # in real commits
            mod, staged, name, new = item_data
        else: # in local changes (item_data is the path)
            mod, staged, name, new = self.app.repo.status.changes[item_data]

        if part == 'elm.swallow.icon':
            return Icon(self, standard='git-mod-'+mod)
        elif part == 'elm.swallow.end' and staged is not None:
            ck = Check(self, state=staged, propagate_events=False)
            ck.callback_changed_add(self._stage_unstage_check_cb)
            ck.data['path'] = name
            return ck
Example #9
0
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', 'Save current status')
        self.part_content_set('title,icon', SafeIcon(self, 'git-stash'))

        # main vertical box
        box = Box(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = box
        box.show()

        # separator
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        box.pack_end(sep)
        sep.show()

        # description
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Stash description (or empty for the default)')
        en.text = 'WIP on ' + app.repo.status.head_describe
        box.pack_end(en)
        en.show()

        # include untracked
        ck = Check(self, text='Include untracked files', state=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_align=(0.0,0.5))
        box.pack_end(ck)
        ck.show()

        # separator
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        box.pack_end(sep)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text='Stash', content=SafeIcon(self, 'git-stash'))
        bt.callback_clicked_add(self._stash_clicked_cb, en, ck)
        self.part_content_set('button2', bt)
        bt.show()

        # focus to the entry and show
        en.select_all()
        en.focus = True
        self.show()
def focus5_clicked(obj, item=None):

    theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj"))

    win = StandardWindow("focus5", "Focus Custom", autodel=True, size=(320, 320))
    win.focus_highlight_enabled = True
    win.focus_highlight_animate = True
    win.focus_highlight_style = "glow"

    fr = Frame(win, style="pad_large",
              size_hint_weight=EXPAND_BOTH);
    win.resize_object_add(fr)
    fr.show()

    bx = Box(fr)
    fr.content = bx
    bx.show()

    chk = Check(bx, text='Enable glow effect on "Glow" Button', state=True,
                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(chk)
    chk.show()

    spinner = Spinner(bx, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(spinner)
    spinner.show()

    bt = Button(bx, text="Glow Button",
                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bt.callback_focused_add(_glow_effect_on_cb, win, chk)
    bt.callback_unfocused_add(_glow_effect_off_cb, win, chk)
    bx.pack_end(bt)
    bt.show()

    sp = Separator(bx, horizontal=True,
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(sp)
    sp.show()

    bx2 = Box(bx, horizontal=True,
              size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    for i in range (1, 5):
        bt = Button(bx2, text="Button %d" % i,
                    size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()

    win.show()
Example #11
0
    def show_local_status(self):
        sortd = sorted(self.repo.status.changes, key=lambda c: c[2])
        for mod, staged, name in sortd:
            icon_name = 'mod_{}.png'.format(mod.lower())
            icon = Icon(self, file=theme_resource_get(icon_name))

            check = Check(self, text="", state=staged)
            check.callback_changed_add(self.stage_unstage_cb)
            check.data['path'] = name

            it = self.diff_list.item_append(name, icon, check)
            it.data['change'] = mod, name

        self.diff_list.go()
Example #12
0
def clock_clicked(obj):
    win = StandardWindow("clock", "Clock", autodel=True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    L = []

    ck = Clock(win)
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    ck = Clock(win, show_am_pm=True)
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    print((ck.time_get()))

    ck = Clock(win, show_seconds=True)
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    ck = Clock(win, show_seconds=True, show_am_pm=True)
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    ck = Clock(win, edit=True, show_seconds=True, show_am_pm=True,
        time=(10, 11, 12))
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    ck = Clock(
        win, edit=True, show_seconds=True, edit_mode = (
            ELM_CLOCK_EDIT_HOUR_DECIMAL |
            ELM_CLOCK_EDIT_MIN_DECIMAL |
            ELM_CLOCK_EDIT_SEC_DECIMAL
            )
        )
    bx.pack_end(ck)
    ck.show()
    L.append(ck)

    hbox = Box(win, horizontal=True)
    bx.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="pause")
    ck.callback_changed_add(pause_changed_cb, L)
    ck.show()
    hbox.pack_end(ck)

    win.show()
Example #13
0
def genlist15_clicked(obj, item=None):
    win = StandardWindow("genlist-decorate-all-mode",
                         "Genlist Decorate All Mode",
                         autodel=True,
                         size=(520, 520))

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    gl.show()

    itc15 = ItemClass15(item_style="default", decorate_all_item_style="edit")
    itc15.state_get = gl_state_get

    for i in range(100):
        ck = Check(gl)
        data = [i, False]
        it = GenlistItem(
            item_class=itc15,
            item_data=data,
            parent_item=None,
            flags=ELM_GENLIST_ITEM_NONE,
            func=gl15_sel,
            func_data=data,
        ).append_to(gl)

        data.append(it)

    bx.pack_end(gl)
    bx.show()

    bx2 = Box(win,
              horizontal=True,
              homogeneous=True,
              size_hint_weight=EXPAND_HORIZ,
              size_hint_align=FILL_BOTH)

    bt = Button(win,
                text="Decorate All mode",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(gl15_deco_all_mode, gl)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Normal mode",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(gl15_normal_mode, gl)
    bx2.pack_end(bt)
    bt.show()

    bx.pack_end(bx2)
    bx2.show()

    win.show()
 def content_get(self, obj, part, data):
     file_entry, progress, n, h = data
     if part == "elm.swallow.icon":
         check = Check(obj)
         check.tooltip_text_set("Enable/disable file download")
         check.state = h.file_priorities()[n]
         check.callback_changed_add(self.toggle_file_enabled, n, h)
         return check
def check_add(win, bx):
    ad = win.data["ad"]

    bx2 = Box(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=(EVAS_HINT_FILL, 0.0), align=(0.0, 0.5),
        horizontal=True)
    bx.pack_end(bx2)
    bx2.show()

    ll = []

    for profile in ad.profiles:
        ck = Check(win, text=profile, size_hint_weight=EXPAND_BOTH)
        ck.data["profile"] = profile
        bx2.pack_end(ck)
        ck.show()

        ll.append(ck)

    return ll
Example #16
0
    def addPackage(self, pak):
        row = []

        ourCheck = Check(self)
        ourCheck.data['packageName'] = pak.name
        ourCheck.callback_changed_add(self.app.checkChange)
        ourCheck.show()
        row.append(ourCheck)

        ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        ourName.text = pak.name
        ourName.data["packageDes"] = pak.candidate.description
        ourName.callback_pressed_add(self.packagePressed)
        ourName.show()
        row.append(ourName)

        ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        ourVersion.text = pak.installed.version
        ourVersion.show()
        row.append(ourVersion)

        newVersion = Label(self, size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        newVersion.text = pak.candidate.version
        newVersion.show()
        row.append(newVersion)

        self.app.packagesToUpdate[pak.name] = {'check':ourCheck, 'selected':False}
        self.packageList.row_pack(row, sort=False)
def check_add(win, bx):
    ad = win.data["ad"]

    bx2 = Box(win,
              size_hint_weight=EXPAND_HORIZ,
              size_hint_align=(EVAS_HINT_FILL, 0.0),
              align=(0.0, 0.5),
              horizontal=True)
    bx.pack_end(bx2)
    bx2.show()

    ll = []

    for profile in ad.profiles:
        ck = Check(win, text=profile, size_hint_weight=EXPAND_BOTH)
        ck.data["profile"] = profile
        bx2.pack_end(ck)
        ck.show()

        ll.append(ck)

    return ll
Example #18
0
    def _settings_open(self, obj, it):
        h = Hover(self)
        t = it.track_object
        h.pos = t.bottom_center
        del t
        del it.track_object

        l = List(h)
        l.mode = ELM_LIST_EXPAND
        h.part_content_set("bottom", l)
        l.show()

        chk = Check(self, text="Scroll By Page")
        chk.state = self.settings["scroll_by_page"]
        def _scroll_by_page_cb(obj):
            self.settings["scroll_by_page"] = obj.state
            h.dismiss()
        chk.callback_changed_add(_scroll_by_page_cb)

        l.item_append(None, chk)
        l.go()

        h.show()
Example #19
0
    def __init__(self, parent, session):
        self.session = session

        Frame.__init__(self, parent)
        self.size_hint_align = -1.0, 0.0
        self.text = "Encryption settings"

        pes = self.pes = session.get_pe_settings()

        b = Box(parent)

        enc_values = lt.enc_policy.disabled, lt.enc_policy.enabled, lt.enc_policy.forced
        enc_levels = lt.enc_level.plaintext, lt.enc_level.rc4, lt.enc_level.both

        inc = self.inc = ActSWithLabel(parent, "Incoming encryption",
                                       enc_values, pes.in_enc_policy)
        b.pack_end(inc)
        inc.show()

        out = self.out = ActSWithLabel(parent, "Outgoing encryption",
                                       enc_values, pes.out_enc_policy)
        b.pack_end(out)
        out.show()

        lvl = self.lvl = ActSWithLabel(parent, "Allowed encryption level",
                                       enc_levels, pes.allowed_enc_level)
        b.pack_end(lvl)
        lvl.show()

        prf = self.prf = Check(parent)
        prf.style = "toggle"
        prf.text = "Prefer RC4 ecryption"
        prf.state = pes.prefer_rc4
        b.pack_end(prf)
        prf.show()

        a_btn = Button(parent)
        a_btn.text = "Apply"
        a_btn.callback_clicked_add(self.apply)
        b.pack_end(a_btn)
        a_btn.show()

        b.show()
        self.content = b
Example #20
0
File: ePad.py Project: nijek/ePad
    def __init__(self, parent, canvas):
        Toolbar.__init__(self, canvas)
        self._parent = parent
        self._canvas = canvas

        self.homogeneous = False
        self.size_hint_weight = (0.0, 0.0)
        self.size_hint_align = (EVAS_HINT_FILL, 0.0)
        self.select_mode = ELM_OBJECT_SELECT_MODE_NONE

        self.menu_parent = canvas

        self.item_append("document-new", "New", self.newPress)
        self.item_append("document-open", "Open", self.openPress)
        self.item_append("document-save", "Save", self.savePress)
        self.item_append("document-save-as", "Save As", self.saveAsPress)
        # -- Edit Dropdown Menu --
        tb_it = self.item_append("edit", "Edit")
        tb_it.menu = True
        menu = tb_it.menu
        menu.item_add(None, "Copy", "edit-copy", self.copyPress)
        menu.item_add(None, "Paste", "edit-paste", self.pastePress)
        menu.item_add(None, "Cut", "edit-cut", self.cutPress)
        menu.item_separator_add()
        menu.item_add(None, "Select All", "edit-select-all",
                      self.selectAllPress)
        # -----------------------
        #
        # -- Options Dropdown Menu --
        #
        # self.item_append("settings", "Options", self.optionsPress)
        tb_it = self.item_append("preferences-desktop", "Options")
        tb_it.menu = True
        menu = tb_it.menu
        self._parent.wordwrap = WORD_WRAP
        it = menu.item_add(None, "Wordwrap", None, self.optionsWWPress)
        chk = Check(canvas, disabled=True)
        it.content = chk

        # ---------------------------

        self.item_append("dialog-information", "About", self.aboutPress)
    def __init__(self, parent):
        Frame.__init__(self, parent, text="Signals")
        self._parent = parent

        vbox = Box(self)
        vbox.show()
        self.content = vbox

        self.siglist = Genlist(self, homogeneous=True, mode=ELM_LIST_SCROLL)
        self.siglist.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        self.siglist.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self.siglist.callback_clicked_double_add(self.signal_clicked_cb)
        self.siglist.show()
        vbox.pack_end(self.siglist)
        self.itc = SignalItemClass()

        hbox = Box(self, horizontal=True)
        hbox.size_hint_align = 0.0, 0.5
        hbox.show()
        vbox.pack_end(hbox)

        bt = Button(self, text='Clear')
        bt.callback_clicked_add(lambda b: self.siglist.clear())
        hbox.pack_end(bt)
        bt.show()

        def scroll_on_signal_clicked_cb(chk):
            options.scroll_on_signal = chk.state

        ck = Check(self, text='Scroll on signal')
        ck.state = options.scroll_on_signal
        ck.callback_changed_add(scroll_on_signal_clicked_cb)
        hbox.pack_end(ck)
        ck.show()

        for b in session_bus, system_bus:
            b.add_signal_receiver(self.signal_cb,
                                  sender_keyword='sender',
                                  destination_keyword='dest',
                                  interface_keyword='iface',
                                  member_keyword='signal',
                                  path_keyword='path')
Example #22
0
    def addPackage(self, pak):
        row = []

        ourCheck = Check(self)
        ourCheck.data['packageName'] = pak.name
        ourCheck.callback_changed_add(self.app.checkChange)
        ourCheck.show()
        row.append(ourCheck)

        ourName = Button(self,
                         style="anchor",
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        ourName.text = pak.name
        ourName.data["packageDes"] = pak.candidate.description
        ourName.callback_pressed_add(self.packagePressed)
        ourName.show()
        row.append(ourName)

        ourVersion = Label(self,
                           size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        ourVersion.text = pak.installed.version
        ourVersion.show()
        row.append(ourVersion)

        newVersion = Label(self,
                           size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=(0.1, 0.5))
        newVersion.text = pak.candidate.version
        newVersion.show()
        row.append(newVersion)

        self.app.packagesToUpdate[pak.name] = {
            'check': ourCheck,
            'selected': False
        }
        self.packageList.row_pack(row, sort=False)
Example #23
0
    def __init__(self, app, revert_commit=None, cherrypick_commit=None):
        self.app = app
        self.confirmed = False
        self.revert_commit = revert_commit
        self.cherrypick_commit = cherrypick_commit

        DialogWindow.__init__(self, app.win, 'Egitu', 'Egitu',
                              size=(500,500), autodel=True)

        vbox = Box(self, size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        # title
        if revert_commit:
            title = 'Revert commit'
        elif cherrypick_commit:
            title = 'Cherry-pick commit'
        else:
            title = 'Commit changes'
        en = Entry(self, editable=False,
                   text='<title><align=center>%s</align></title>' % title,
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        vbox.pack_end(en)
        en.show()

        # auto-commit checkbox (for revert and cherry-pick)
        if revert_commit or cherrypick_commit:
            ck = Check(vbox, state=True)
            ck.text = 'Automatically commit, in branch: %s' % \
                      app.repo.status.current_branch.name
            ck.callback_changed_add(lambda c: self.msg_entry.disabled_set(not c.state))
            vbox.pack_end(ck)
            ck.show()
            self.autocommit_chk = ck

        # Panes
        panes = Panes(self, content_left_size = 0.2, horizontal=True,
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        vbox.pack_end(panes)
        panes.show()

        # message entry
        en = Entry(self, editable=True, scrollable=True,
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        en.part_text_set('guide', 'Enter commit message here')
        panes.part_content_set("left", en)
        if revert_commit:
            en.text = 'Revert "%s"<br><br>This reverts commit %s.<br><br>' % \
                      (utf8_to_markup(revert_commit.title),
                       revert_commit.sha)
        elif cherrypick_commit:
            en.text = '%s<br><br>%s<br>(cherry picked from commit %s)<br>' % \
                      (utf8_to_markup(cherrypick_commit.title),
                       utf8_to_markup(cherrypick_commit.message),
                       cherrypick_commit.sha)
        en.cursor_end_set()
        en.show()
        self.msg_entry = en

        # diff entry
        self.diff_entry = DiffedEntry(self)
        panes.part_content_set('right', self.diff_entry)
        self.diff_entry.show()

        # buttons
        hbox = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(hbox)
        hbox.show()

        bt = Button(self, text='Cancel')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        if revert_commit:
            label = 'Revert'
        elif cherrypick_commit:
            label = 'Cherry-pick'
        else:
            label = 'Commit'
        bt = Button(self, text=label)
        bt.callback_clicked_add(self.commit_button_cb)
        hbox.pack_end(bt)
        bt.show()

        # show the window and give focus to the editable entry
        self.show()
        en.focus = True

        # load the diff
        if revert_commit:
            app.repo.request_diff(self.diff_done_cb, revert=True,
                                  ref1=revert_commit.sha)
        elif cherrypick_commit:
            app.repo.request_diff(self.diff_done_cb, ref1=cherrypick_commit.sha)
        else:
            app.repo.request_diff(self.diff_done_cb, only_staged=True)
def index_clicked(obj):
    win = StandardWindow("index", "Index test", autodel=True, size=(320, 480))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    # index
    idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    idx.callback_delay_changed_add(cb_idx_delay_changed)
    idx.callback_changed_add(cb_idx_changed)
    idx.callback_selected_add(cb_idx_selected)
    win.resize_object_add(idx)
    idx.show()

    # genlist
    itc = GenlistItemClass(item_style="default", text_get_func=gl_text_get)
    # content_get_func=gl_content_get,
    # state_get_func=gl_state_get)
    gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(gl)
    gl.show()

    for i in 'ABCDEFGHILMNOPQRSTUVZ':
        for j in 'acegikmo':
            gl_item = gl.item_append(itc, i + j)
            if j == 'a':
                idx_item = idx.item_append(i, cb_idx_item, gl_item)
                idx_item.data["gl_item"] = gl_item

    idx.level_go(0)

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="autohide_disabled")
    ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="indicator_disabled")
    ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="horizontal")
    ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    win.show()
Example #25
0
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)

        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True  # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

        # popup buttons
        btn = Button(parent)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', btn)

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
Example #26
0
File: gui.py Project: lonid/epack
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        # main vertical box
        vbox = Box(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        ### header horiz box (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        self.header_box = Box(self, horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        frame.content = self.header_box
        self.header_box.show()

        # genlist with archive content
        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=gl_file_text_get)
        self.fold_itc = GenlistItemClass(item_style="one_icon",
                                         text_get_func=gl_fold_text_get,
                                         content_get_func=gl_fold_icon_get)
        self.file_list = Genlist(self, homogeneous=True,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        vbox.pack_end(self.file_list)
        self.file_list.show()

        ### footer table (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        table = Table(frame)
        frame.content = table
        table.show()

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 0, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True,
                        size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 1, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 2, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 2, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table, text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 2, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table, text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 3, 1, 1)
        self.create_folder_chk.callback_changed_add(
                               lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.resize(300, 380)
        self.show()
def gengrid_clicked(obj):

    global item_count
    item_count = 25

    win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 800))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    tb = Table(win, homogeneous=False, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # gengrid
    itc = GengridItemClass(item_style="default",
                                       text_get_func=gg_text_get,
                                       content_get_func=gg_content_get,
                                       state_get_func=gg_state_get,
                                       del_func=gg_del)
    gg = ScrollableGengrid(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, horizontal=False, bounce=(False, True),
        item_size=(80, 80), align=(0.5, 0.0))
    tb.pack(gg, 0, 0, 6, 1)
    gg.callback_selected_add(gg_sel)
    gg.callback_unselected_add(gg_unsel)
    gg.callback_clicked_double_add(gg_clicked_double)
    gg.show()

    # add the first items
    for i in range(item_count):
        gg.item_append(itc, i, None)

    # multi select
    def multi_select_changed(bt, gg):
        gg.multi_select_set(bt.state)
        print((gg.multi_select))

    bt = Check(win, text="MultiSelect", state=gg.multi_select)
    bt.callback_changed_add(multi_select_changed, gg)
    tb.pack(bt, 0, 1, 1, 1)
    bt.show()

    # horizontal
    def horizontal_changed(bt, gg):
        gg.horizontal_set(bt.state)

    bt = Check(win, text="Horizontal")
    bt.callback_changed_add(horizontal_changed, gg)
    tb.pack(bt, 1, 1, 1, 1)
    bt.show()

    # bounce h
    def bounce_h_changed(bt, gg):
        (h_bounce, v_bounce) = gg.bounce_get()
        gg.bounce_set(bt.state, v_bounce)
        print((gg.bounce_get()))

    bt = Check(win, text="BounceH")
    h_bounce = gg.bounce[0]
    bt.state = h_bounce
    bt.callback_changed_add(bounce_h_changed, gg)
    tb.pack(bt, 4, 1, 1, 1)
    bt.show()

    # bounce v
    def bounce_v_changed(bt, gg):
        (h_bounce, v_bounce) = gg.bounce_get()
        gg.bounce_set(h_bounce, bt.state)
        print((gg.bounce_get()))

    bt = Check(win, text="BounceV")
    v_bounce = gg.bounce[1]
    bt.state = v_bounce
    bt.callback_changed_add(bounce_v_changed, gg)
    tb.pack(bt, 5, 1, 1, 1)
    bt.show()

    # item size
    def item_size_w_changed(sl, gg):
        (w, h) = gg.item_size_get()
        gg.item_size_set(sl.value, h)
        print((gg.item_size_get()))

    def item_size_h_changed(sl, gg):
        (w, h) = gg.item_size_get()
        gg.item_size_set(w, sl.value)
        print((gg.item_size_get()))

    (w, h) = gg.item_size
    sl = Slider(win, text="ItemSizeW", min_max=(0, 500),
        indicator_format="%.0f", unit_format="%.0f", span_size=100, value=w)
    sl.callback_changed_add(item_size_w_changed, gg)
    tb.pack(sl, 0, 2, 2, 1)
    sl.show()

    sl = Slider(win, text="ItemSizeH", min_max=(0, 500),
        indicator_format="%.0f", unit_format="%.0f", span_size=100, value=h)
    sl.callback_changed_add(item_size_h_changed, gg)
    tb.pack(sl, 0, 3, 2, 1)
    sl.show()

    # align
    def alignx_changed(sl, gg):
        (ax, ay) = gg.align
        gg.align = sl.value, ay
        print(gg.align)

    def aligny_changed(sl, gg):
        (ax, ay) = gg.align
        gg.align = ax, sl.value
        print(gg.align)

    (ax, ay) = gg.align

    sl = Slider(win, text="AlignX", min_max=(0.0, 1.0),
        indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ax)
    sl.callback_changed_add(alignx_changed, gg)
    tb.pack(sl, 0, 4, 2, 1)
    sl.show()

    sl = Slider(win, text="AlignY", min_max=(0.0, 1.0),
        indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ay)
    sl.callback_changed_add(aligny_changed, gg)
    tb.pack(sl, 0, 5, 2, 1)
    sl.show()

    # select first
    def select_first_clicked(bt, gg):
        ggi = gg.first_item
        if ggi:
            ggi.selected = not ggi.selected

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Select first")
    bt.callback_clicked_add(select_first_clicked, gg)
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # select last
    def select_last_clicked(bt, gg):
        ggi = gg.last_item
        if ggi:
            ggi.selected = not ggi.selected

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Select last")
    bt.callback_clicked_add(select_last_clicked, gg)
    tb.pack(bt, 3, 2, 1, 1)
    bt.show()

    # selection del
    def seldel_clicked(bt, gg):
        for ggi in gg.selected_items_get():
            ggi.delete()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Sel del")
    bt.callback_clicked_add(seldel_clicked, gg)
    tb.pack(bt, 4, 2, 1, 1)
    bt.show()

    # clear
    def clear_clicked(bt, gg):
        global item_count
        item_count = 0
        gg.clear()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Clear")
    bt.callback_clicked_add(clear_clicked, gg)
    tb.pack(bt, 5, 2, 1, 1)
    bt.show()

    # show first/last
    def show_clicked(bt, gg, first):
        ggi = gg.first_item if first else gg.last_item
        if ggi:
            ggi.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show first")
    bt.callback_clicked_add(show_clicked, gg, True)
    tb.pack(bt, 2, 3, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show last")
    bt.callback_clicked_add(show_clicked, gg, False)
    tb.pack(bt, 3, 3, 1, 1)
    bt.show()

    # bring-in first/last
    def bring_in_clicked(bt, gg, first):
        ggi = gg.first_item if first else gg.last_item
        if ggi:
            ggi.bring_in()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn first")
    bt.callback_clicked_add(bring_in_clicked, gg, True)
    tb.pack(bt, 4, 3, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn last")
    bt.callback_clicked_add(bring_in_clicked, gg, False)
    tb.pack(bt, 5, 3, 1, 1)
    bt.show()

    # append
    def append_clicked(bt, gg, n):
        global item_count
        while n:
            item_count += 1
            gg.item_append(itc, item_count, None)
            n -= 1

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1")
    bt.callback_clicked_add(append_clicked, gg, 1)
    tb.pack(bt, 2, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 100")
    bt.callback_clicked_add(append_clicked, gg, 100)
    tb.pack(bt, 3, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1000")
    bt.callback_clicked_add(append_clicked, gg, 1000)
    tb.pack(bt, 4, 4, 1, 1)
    bt.show()

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 10000 :)")
    bt.callback_clicked_add(append_clicked, gg, 10000)
    tb.pack(bt, 5, 4, 1, 1)
    bt.show()

    # prepend
    def prepend_clicked(bt, gg):
        global item_count
        item_count += 1
        gg.item_prepend(itc, item_count)

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Prepend")
    bt.callback_clicked_add(prepend_clicked, gg)
    tb.pack(bt, 2, 5, 1, 1)
    bt.show()

    # insert_before
    def ins_before_clicked(bt, gg):
        global item_count
        item_count += 1
        before = gg.selected_item_get()
        if before:
            gg.item_insert_before(itc, item_count, before)
        else:
            print("nothing selected")

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins before")
    bt.callback_clicked_add(ins_before_clicked, gg)
    tb.pack(bt, 3, 5, 1, 1)
    bt.show()

    # insert_after
    def ins_after_clicked(bt, gg):
        global item_count
        item_count += 1
        after = gg.selected_item_get()
        if after:
            gg.item_insert_after(itc, item_count, after)
        else:
            print("nothing selected")

    bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins after")
    bt.callback_clicked_add(ins_after_clicked, gg)
    tb.pack(bt, 4, 5, 1, 1)
    bt.show()

    print(gg)

    win.show()
Example #28
0
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        ### main table (inside a padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        self.resize_object_add(frame)
        frame.content = table = Table(frame)
        frame.show()

        ### header horiz box
        self.header_box = Box(self,
                              horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        table.pack(self.header_box, 0, 0, 3, 1)
        self.header_box.show()

        # genlist with archive content (inside a small padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        table.pack(frame, 0, 1, 3, 1)

        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=self._gl_file_text_get)
        self.fold_itc = GenlistItemClass(
            item_style="one_icon",
            text_get_func=self._gl_fold_text_get,
            content_get_func=self._gl_fold_icon_get)
        self.file_list = Genlist(frame, homogeneous=True)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        frame.content = self.file_list
        frame.show()

        # rect hack to force a min size on the genlist
        r = evas.Rectangle(table.evas,
                           size_hint_min=(250, 250),
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        table.pack(r, 0, 1, 3, 1)

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 2, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 3, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 4, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 4, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table,
                             text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 4, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table,
                                       text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 5, 1, 1)
        self.create_folder_chk.callback_changed_add(
            lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.show()
    def __init__(self, parent, method):
        StandardWindow.__init__(self, "espionage", "Method", autodel=True)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # content is vbox (with surrounding pad frame)
        pad = Frame(self, style='pad_medium')
        pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self.resize_object_add(pad)
        pad.show()

        vbox = Box(self)
        vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        pad.content = vbox
        vbox.show()

        # title
        f = "font_size=16 align=0.5 font_weight=Bold"
        en = Entry(self, text='<font %s>%s()</>' % (f, method.name))
        en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        en.size_hint_align = EVAS_HINT_FILL, 0.0
        en.editable = False
        vbox.pack_end(en)
        en.show()

        # params label + entry
        if len(method.params) > 0:
            label = Entry(self, editable=False)
            label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            label.size_hint_align = EVAS_HINT_FILL, 0.0
            pars = colored_params(method.params, omit_braces=True)
            label.text = 'Params: %s' % (pars if method.params else 'None')
            vbox.pack_end(label)
            label.show()

            en = Entry(self, editable=True, scrollable=True, single_line=True)
            en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            en.size_hint_align = EVAS_HINT_FILL, 0.0
            self._param_entry = en
            vbox.pack_end(en)
            en.show()

        # returns label + entry
        label = Entry(self, editable=False)
        label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        label.size_hint_align = EVAS_HINT_FILL, 0.0
        rets = colored_params(method.returns, omit_braces=True)
        label.text = 'Returns: %s' % (rets if method.returns else 'None')
        vbox.pack_end(label)
        label.show()

        en = Entry(self, editable=False, scrollable=True)
        en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self._return_entry = en
        vbox.pack_end(en)
        en.show()

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(self)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

        sep = Separator(self, horizontal=True)
        vbox.pack_end(sep)
        sep.show()

        # buttons
        hbox = Box(self, horizontal=True)
        hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        hbox.size_hint_align = EVAS_HINT_FILL, 0.5
        vbox.pack_end(hbox)
        hbox.show()

        btn = Button(self)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(btn)
        btn.show()

        btn = Button(self)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        hbox.pack_end(btn)
        btn.show()

        btn = Button(self)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        hbox.pack_end(btn)
        btn.show()

        # show the window
        self.resize(300, 300)
        self.show()
Example #30
0
    box0 = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box0)
    box0.show()

    lb = Label(win)
    lb.text = (
        "Please select a test from the list below by clicking<br>"
        "the test button to show the test window."
        )
    lb.show()

    fr = Frame(win, text="Information", content=lb)
    box0.pack_end(fr)
    fr.show()

    tg = Check(win, style="toggle", text="UI-Mirroring:")
    tg.callback_changed_add(cb_mirroring)
    box0.pack_end(tg)
    tg.show()

    bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
        size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True)
    box0.pack_end(bx1)
    bx1.show()

    lb = Label(win, text="Filter:")
    bx1.pack_end(lb)
    lb.show()

    en = Entry(win, single_line=True, scrollable=True,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
def check_clicked(obj):
    win = StandardWindow("check", "Check test", autodel=True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
    ck = Check(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ,
        text="Icon sized to check", content=ic, state=True
        )
    ck.callback_changed_add(ck_1)
    bx.pack_end(ck)
    ck.show()
    ic.show()

    ic = Icon(win, file=ic_file, resizable=(0, 0))
    ck = Check(win, text="Icon no scale", content=ic)
    ck.callback_changed_add(ck_2)
    bx.pack_end(ck)
    ck.show()
    ic.show()

    ck = Check(win, text="Label Only")
    ck.callback_changed_add(ck_3)
    bx.pack_end(ck)
    ck.show()

    ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
    ck = Check(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ,
        text="Disabled check", content=ic, state=True
        )
    ck.callback_changed_add(ck_never)
    bx.pack_end(ck)
    ck.disabled_set(True)
    ck.show()
    ic.show()

    ic = Icon(win, file=ic_file,
        size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), resizable=(0, 0))
    ck = Check(win, content=ic)
    ck.callback_changed_add(ck_4)
    bx.pack_end(ck)
    ck.show()
    ic.show()

    win.show()
def focus4_clicked(obj, item=None):
    win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320))

    win.focus_highlight_enabled = True
    win.focus_highlight_animate = True

    fr = Frame(win, style="pad_large",
              size_hint_weight=EXPAND_BOTH);
    win.resize_object_add(fr)
    fr.show()

    # First Example - Using Focus Highlight
    bx = Box(fr)
    fr.content = bx
    bx.show()

    tg = Check(bx, text="Focus Highlight Enabled (Config)", state=True,
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_highlight_enabled_cb, win)

    bx.pack_end(tg)
    tg.show()

    tg = Check(bx, text="Focus Highlight Animate (Config)", state=True,
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_highlight_animate_cb, win)
    bx.pack_end(tg)
    tg.show()

    tg = Check(bx, text="Focus Highlight Enabled (Win)", state=True,
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_win_highlight_enabled_cb, win)
    bx.pack_end(tg)
    tg.show()

    tg = Check(bx, text="Focus Highlight Animate (Win)", state=True,
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_win_highlight_animate_cb, win)
    bx.pack_end(tg)
    tg.show()

    sp = Separator(win, horizontal=True,
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(sp)
    sp.show()

    # Second Example - Using Custom Chain
    lb = Label(bx, text="Custom Chain: Please use tab key to check",
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(lb)
    lb.show()

    bx2 = Box(bx, horizontal=True,
              size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    bt1 = Button(bx2, text="Button 1",
                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(bt1)
    bt1.show()
    
    bt2 = Button(bx2, text="Button 2",
                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(bt2)
    bt2.show()
    
    bt3 = Button(bx2, text="Button 3",
                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(bt3)
    bt3.show()
    
    bt4 = Button(bx2, text="Button 4",
                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(bt4)
    bt4.show()

    bx2.focus_custom_chain = [bt2, bt1, bt4, bt3]
   
    tg = Check(bx, text="Custom Chain", state=False, 
               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_custom_chain_cb, bx)
    bx.pack_end(tg)
    tg.show()
   

    win.show()
def fileselector_clicked(obj, item=None):
    win = StandardWindow("fileselector", "File selector test",
                         autodel=True, size=(500,500))

    box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box1)
    box1.show()

    fs = Fileselector(win, is_save=True, expandable=False, folder_only=False,
                      path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
    fs.callback_done_add(fs_cb_done, win)
    fs.callback_selected_add(fs_cb_selected, win)
    fs.callback_directory_open_add(fs_cb_directory_open, win)
    box1.pack_end(fs)
    fs.show()

    fs.custom_filter_append(custom_filter_all, filter_name="All Files")
    fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
    fs.mime_types_filter_append(["text/*"], "Text Files")
    fs.mime_types_filter_append(["image/*"], "Image Files")


    sep = Separator(win)
    box1.pack_end(sep)
    sep.show()

    vbox = Box(win)
    box1.pack_end(vbox)
    vbox.show()

    # Options frame
    fr = Frame(win, text="Options")
    vbox.pack_end(fr)
    fr.show()

    fbox1 = Box(win)
    fr.content = fbox1
    fbox1.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="is_save", state=fs.is_save)
    ck.callback_changed_add(ck_cb_is_save, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fs.folder_only)
    ck.callback_changed_add(ck_cb_folder_only, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fs.expandable)
    ck.callback_changed_add(ck_cb_expandable, fs)
    fbox2.pack_end(ck)
    ck.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="multiple selection", state=fs. multi_select)
    ck.callback_changed_add(ck_cb_multi_select, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
    ck.callback_changed_add(ck_cb_buttons, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="hidden", state=fs.hidden_visible)
    ck.callback_changed_add(ck_cb_hidden, fs)
    fbox2.pack_end(ck)
    ck.show()

    # Getters frame
    fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    bt = Button(win, text="selected_get")
    bt.callback_clicked_add(bt_cb_sel_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="path_get")
    bt.callback_clicked_add(bt_cb_path_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="selected_paths")
    bt.callback_clicked_add(bt_cb_paths_get, fs)
    fbox.pack_end(bt)
    bt.show()

    # Mode frame
    fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
    rd.callback_changed_add(rd_cb_mode, fs)
    fbox.pack_end(rd)
    rd.show()

    rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
    rd.callback_changed_add(rd_cb_mode, fs)
    rd.group_add(rdg)
    fbox.pack_end(rd)
    rd.show()

    # Thumbsize frame
    fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    sl = Slider(win, min_max=(4, 130), unit_format="%.0f px",
                value=fs.thumbnail_size[0])
    sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
    fr.content = sl
    sl.show()

    # Sort method frame
    fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    hs = Hoversel(win, text="File name (asc)")
    sorts = (
        ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
        ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
        ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
        ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
        ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
        ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
        ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
        ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
    )
    for sort in sorts:
        hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1])
    fr.content = hs
    hs.show()

    win.show()
def mapbuf_clicked(obj, item=None):
    global mb_list

    win = Window("mapbuf", ELM_WIN_BASIC, title="Mapbuf test", autodel=True,
        size=(480, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bg = Background(win, file=os.path.join(img_path, "sky_04.jpg"),
        size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    # launcher
    sc = Scroller(win, bounce=(True, False), policy=SCROLL_POLICY_OFF,
        size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(sc)

    bx = Box(win, horizontal=True, homogeneous=True)
    bx.show()

    for k in range(8):
        tb = Table(win, size_hint_align=ALIGN_CENTER,
            size_hint_weight=(0.0, 0.0))
        tb.show()

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 0, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (464, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 1, 11, 5, 1)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 0, 1, 1, 10)

        pad = Rectangle(win.evas, color=(255, 255, 0, 255))
        pad.size_hint_min = (4, 4)
        pad.size_hint_weight = (0.0, 0.0)
        pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
        pad.show()
        tb.pack(pad, 6, 1, 1, 10)

        mb = Mapbuf(win, content=tb)
        mb.point_color_set(k % 4, 255, 0, 0, 255)
        mb_list.append(mb)
        bx.pack_end(mb)
        mb.show()

        n = m = 0
        for j in range(5):
            for i in range(5):
                ic = Icon(win, scale=0.5,
                    file=os.path.join(img_path, "icon_%02d.png" % (n)),
                    resizable=(False, False), size_hint_weight=EXPAND_BOTH,
                    size_hint_align=ALIGN_CENTER)
                tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1)
                ic.show()

                lb = Label(win, style="marker", text=names[m])
                tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1)
                lb.show()

                n = n + 1 if n < 23 else 0
                m = m + 1 if m < 15 else 0

    sc.content = bx
    sc.page_relative_set(1.0, 1.0)
    sc.show()

    # controls
    hbox = Box(win, horizontal=True, homogeneous=True,
        size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
    vbox.pack_start(hbox)
    hbox.show()

    ck = Check(win, text="Map", state=False)
    ck.callback_changed_add(cb_ck_map)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Alpha", state=True)
    ck.callback_changed_add(cb_ck_alpha)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="Smooth", state=True)
    ck.callback_changed_add(cb_ck_smooth)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="FS", state=False)
    ck.callback_changed_add(cb_ck_fs, win)
    hbox.pack_end(ck)
    ck.show()

    bt = Button(win, text="Close", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ)
    bt.callback_clicked_add(cb_btn_close, win)
    hbox.pack_end(bt)
    bt.show()

    win.show()
Example #35
0
    def __init__(self, windowGrid, name):
        offset = 0
        if (name == 'Yau'):
            offset = 50

        self.BaseBox = Box(windowGrid,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        windowGrid.pack(self.BaseBox, offset, 0, 50, 100)
        self.BaseBox.show()

        self.frame = Frame(self.BaseBox,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
                           text=name)
        self.BaseBox.pack_end(self.frame)
        self.frame.show()

        self.FrameBox = Box(self.BaseBox,
                            size_hint_weight=(EVAS_HINT_EXPAND,
                                              EVAS_HINT_EXPAND),
                            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        self.frame.content_set(self.FrameBox)
        self.FrameBox.show()

        self.FrameCheck = Check(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                text="{0} Frame Check".format(name))
        self.FrameBox.pack_end(self.FrameCheck)
        self.FrameCheck.show()

        self.FrameSeparator = Separator(self.BaseBox,
                                        horizontal=True,
                                        size_hint_weight=(EVAS_HINT_EXPAND,
                                                          0.0),
                                        size_hint_align=(EVAS_HINT_FILL, 0.5))
        self.FrameBox.pack_end(self.FrameSeparator)
        self.FrameSeparator.show()

        self.FrameScroller = Scroller(
            self.BaseBox,
            content_min_limit=(True, False),
            size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
            scrollbar_policy=(ELM_SCROLLER_POLICY_OFF,
                              ELM_SCROLLER_POLICY_OFF))
        self.FrameBox.pack_end(self.FrameScroller)
        self.FrameScroller.show()

        self.FrameTable = Table(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.0))
        self.FrameScroller.content_set(self.FrameTable)
        self.FrameTable.show()

        self.BaseLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Base:")
        self.FrameTable.pack(self.BaseLabel, 0, 0, 1, 1)
        self.BaseLabel.show()

        self.BaseEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BaseEntry, 1, 0, 1, 1)
        self.BaseEntry.show()

        self.SecretLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Secret:")
        self.FrameTable.pack(self.SecretLabel, 2, 0, 1, 1)
        self.SecretLabel.show()

        self.SecretEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SecretEntry, 3, 0, 1, 1)
        self.SecretEntry.show()

        self.SignalLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Signal:")
        self.FrameTable.pack(self.SignalLabel, 4, 0, 1, 1)
        self.SignalLabel.show()

        self.SignalEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SignalEntry, 5, 0, 1, 1)
        self.SignalEntry.show()

        self.ChannelLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Channel:")
        self.FrameTable.pack(self.ChannelLabel, 0, 1, 1, 1)
        self.ChannelLabel.show()

        self.ChannelEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ChannelEntry, 1, 1, 1, 1)
        self.ChannelEntry.show()

        self.PoleLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Pole:")
        self.FrameTable.pack(self.PoleLabel, 2, 1, 1, 1)
        self.PoleLabel.show()

        self.PoleEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.PoleEntry, 3, 1, 1, 1)
        self.PoleEntry.show()

        self.IdentityLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Identity:")
        self.FrameTable.pack(self.IdentityLabel, 4, 1, 1, 1)
        self.IdentityLabel.show()

        self.IdentityEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.IdentityEntry, 5, 1, 1, 1)
        self.IdentityEntry.show()

        self.FoundationLabel = Label(self.FrameTable,
                                     size_hint_weight=(0.0, 0.0),
                                     size_hint_align=(0.0, 0.5),
                                     text="Foundation:")
        self.FrameTable.pack(self.FoundationLabel, 0, 2, 1, 1)
        self.FoundationLabel.show()

        self.FoundationEntry = Entry(self.FrameTable,
                                     size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                     size_hint_align=(EVAS_HINT_FILL, 0.5),
                                     single_line=True,
                                     scrollable=True,
                                     text="")
        self.FrameTable.pack(self.FoundationEntry, 1, 2, 1, 1)
        self.FoundationEntry.show()

        self.ElementLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Element:")
        self.FrameTable.pack(self.ElementLabel, 2, 2, 1, 1)
        self.ElementLabel.show()

        self.ElementEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ElementEntry, 3, 2, 1, 1)
        self.ElementEntry.show()

        self.DynamoLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Dynamo:")
        self.FrameTable.pack(self.DynamoLabel, 4, 2, 1, 1)
        self.DynamoLabel.show()

        self.DynamoEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.DynamoEntry, 5, 2, 1, 1)
        self.DynamoEntry.show()

        self.ManifoldLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Manifold:")
        self.FrameTable.pack(self.ManifoldLabel, 0, 3, 1, 1)
        self.ManifoldLabel.show()

        self.ManifoldEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.ManifoldEntry, 1, 3, 1, 1)
        self.ManifoldEntry.show()

        self.RingLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Ring:")
        self.FrameTable.pack(self.RingLabel, 2, 3, 1, 1)
        self.RingLabel.show()

        self.RingEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.RingEntry, 3, 3, 1, 1)
        self.RingEntry.show()

        self.BarnLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Barn:")
        self.FrameTable.pack(self.BarnLabel, 4, 3, 1, 1)
        self.BarnLabel.show()

        self.BarnEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BarnEntry, 5, 3, 1, 1)
        self.BarnEntry.show()

        self.VoltpereLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Voltpere:")
        self.FrameTable.pack(self.VoltpereLabel, 0, 4, 1, 1)
        self.VoltpereLabel.show()

        self.VoltpereEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.VoltpereEntry, 1, 4, 5, 1)
        self.VoltpereEntry.show()

        self.AmpereLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Ampere:")
        self.FrameTable.pack(self.AmpereLabel, 0, 5, 1, 1)
        self.AmpereLabel.show()

        self.AmpereEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.AmpereEntry, 1, 5, 2, 1)
        self.AmpereEntry.show()

        self.HenryLabel = Label(self.FrameTable,
                                size_hint_weight=(0.0, 0.0),
                                size_hint_align=(0.0, 0.5),
                                text="Henry:")
        self.FrameTable.pack(self.HenryLabel, 0, 6, 1, 1)
        self.HenryLabel.show()

        self.HenryEntry = Entry(self.FrameTable,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                single_line=True,
                                scrollable=True,
                                text="")
        self.FrameTable.pack(self.HenryEntry, 1, 6, 2, 1)
        self.HenryEntry.show()

        self.MaxwellLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Maxwell:")
        self.FrameTable.pack(self.MaxwellLabel, 0, 7, 1, 1)
        self.MaxwellLabel.show()

        self.MaxwellEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.MaxwellEntry, 1, 7, 2, 1)
        self.MaxwellEntry.show()

        self.FermatLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Fermat:")
        self.FrameTable.pack(self.FermatLabel, 0, 8, 1, 1)
        self.FermatLabel.show()

        self.FermatEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.FermatEntry, 1, 8, 2, 1)
        self.FermatEntry.show()

        self.PropelButton = Button(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Propel")
        self.FrameTable.pack(self.PropelButton, 4, 8, 1, 1)
        self.PropelButton.show()
        self.PropelButton.callback_clicked_add(self.propelClicked)
Example #36
0
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None

        self.__first_run = True
        self.use_theme = False
        self.override_theme_font_size = True
        self.override_font_size = 14
        self.theme_data = None
        self.default_font = 'Sans'
        self.default_font_style = 'Regular'
        self.default_font_size = 14
        self.selected_font = self.default_font
        self.selected_font_style = self.default_font_style
        self.selected_font_size = self.default_font_size
        self.font_style_str = self.get_text_style(self.selected_font,
                                                  self.selected_font_style,
                                                  self.selected_font_size)
        self.preview_text = 'abcdefghijk ABCDEFGHIJK'
        # Font size min and max
        self.fs_min = 8
        self.fs_max = 72

        lb = Label(self,
                   text="<br><hilight><i>Select Font</i></hilight>",
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
        lb.show()
        self.pack_end(lb)
        sp = Separator(self,
                       horizontal=True,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        sp.show()
        self.pack_end(sp)
        # A horizontal box to hold our font list and font styles
        fontBox = Box(self,
                      horizontal=True,
                      homogeneous=True,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        fontBox.show()
        self.pack_end(fontBox)
        # A vertical box to hold label and list of font families
        vBoxFL = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFL.show()
        fontBox.pack_end(vBoxFL)
        # A vertical box to hold label and list of font styles
        vBoxFS = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFS.show()
        fontBox.pack_end(vBoxFS)
        # Generate our needed font data
        #now =time.time()
        fonts = []
        fonts_raw = self.evas.font_available_list()
        # populate with default font families
        #   see elm_font_available_hash_add Function in EFL
        f_families = ['Sans', 'Serif', 'Monospace']
        f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic']
        fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles]

        self.fonts_hash = {}
        for font in fonts_raw:
            a = font_properties_get(font)
            # if font name contains a '-' a.name will replace with '\\-'
            #   This needs removed to properly display the name
            fn = a.name.replace('\\', '')
            fonts.append(fn)
            if fn in self.fonts_hash:
                self.fonts_hash.setdefault(fn, []).append(a.styles[0])
            else:
                self.fonts_hash[fn] = [a.styles[0]]

        # Deal with some problematic special cases
        for a, s in self.fonts_hash.items():
            #print(a,s)
            if s:
                if len(s) == 1:
                    s[0] = s[0].rstrip()
                    if s[0] == u'regular':
                        s[0] = u'Regular'
                    if s[0] == u'Medium Italic':
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    elif s[0] == u'Italic':
                        if a != u'Romande ADF Script Std':
                            self.fonts_hash.setdefault(a,
                                                       []).append(u'Regular')
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 2:
                    if any(u'Oblique' in w for w in s):
                        if a not in {
                                u'Baskervald ADF Std Heavy',
                                u'Latin Modern Roman Demi'
                        }:
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                            self.fonts_hash.setdefault(
                                a, []).append(u'Bold Oblique')
                    elif any(u'Italic' in w for w in s):
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 3 and set(s) == {
                        u'Bold', u'Oblique', u'Medium'
                }:
                    # case GWMonospace
                    self.fonts_hash.setdefault(a, []).append(u'Bold Oblique')
                elif len(s) == 3 and set(s) == {
                        u'Italic', u'Regular', u'Bold'
                }:
                    # Case Eden Mills
                    self.fonts_hash.setdefault(a, []).append(u'Bold Italic')
                elif len(s) < 4:
                    print("may need fixed Font style for %s: %s" % (a, s))
        #print(self.fonts_hash)

        # for some strange reason many fonts are displayed multiple times. The following lines remove
        # all duplicates and then sort them alphabetically.
        # FIXME: Is this still true
        fonts = list(set(fonts))
        fonts.sort(cmp=locale.strcoll)

        # Elm List for holding font options
        self.font_list = List(self,
                              size_hint_align=FILL_BOTH,
                              size_hint_weight=EXPAND_BOTH,
                              mode=ELM_LIST_LIMIT)
        #self.font_list.callback_selected_add(self.__font_demo_name_set)
        for font in fonts:
            self.font_list.item_append(font.replace('\\', ''))
            if font == self.selected_font:
                font_it = self.font_list.last_item_get()
        #print  (time.time()- now)
        self.font_list.go()
        self.font_list.show()

        font_family_label = Label(self)
        font_family_label.text = "<br><b>Font:</b>"
        font_family_label.show()
        vBoxFL.pack_end(font_family_label)
        vBoxFL.pack_end(self.font_list)

        # Elm List for hold font styles
        self.font_style = List(self,
                               size_hint_align=FILL_BOTH,
                               size_hint_weight=EXPAND_BOTH,
                               mode=ELM_LIST_LIMIT)
        #self.font_style.callback_selected_add(self.__font_demo_style_set)

        self.__reset_font_style_list(font_it.text_get())

        self.font_style.go()
        self.font_style.show()

        font_style_label = Label(self)
        font_style_label.text = "<br><b>Style:</b>"
        font_style_label.show()
        vBoxFS.pack_end(font_style_label)
        vBoxFS.pack_end(self.font_style)

        # A table to hold font size Spinner and set theme default Check
        tb = Table(self,
                   homogeneous=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        self.pack_end(tb)
        tb.show()

        # spinner to choose the font size
        self.font_sizer = Spinner(self)
        self.font_sizer.min_max_set(self.fs_min, self.fs_max)
        self.font_sizer.value_set(self.selected_font_size)
        #self.font_sizer.callback_changed_add(self.__font_demo_size_set)
        self.font_sizer.show()
        # Label for Spinner
        font_sizer_label = Label(self)
        font_sizer_label.text = "Font Size:  "
        font_sizer_label.show()

        size_box = Box(self,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        size_box.horizontal_set(True)
        size_box.pack_end(font_sizer_label)
        size_box.pack_end(self.font_sizer)
        size_box.show()
        tb.pack(size_box, 33, 0, 34, 34)

        self.use_theme_ck = Check(self,
                                  text="Theme Default   ",
                                  size_hint_weight=EXPAND_HORIZ,
                                  size_hint_align=(1, 0.5))
        self.use_theme_ck.callback_changed_add(self.__use_theme_checked)
        self.use_theme_ck.show()
        tb.pack(self.use_theme_ck, 67, 0, 33, 34)

        # Entry to hold sample text
        self.font_demo = Entry(self,
                               single_line=True,
                               editable=False,
                               context_menu_disabled=True,
                               text=self.preview_text,
                               scrollable=True,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.font_demo.show()

        demo_box = Frame(self,
                         size_hint_align=FILL_BOTH,
                         text="Preview:",
                         content=self.font_demo)
        demo_box.show()

        # Fixme: move this shit
        font_it.selected_set(True)
        font_it.show()
        # Ensure focus is on Font List
        self.font_list.focus_set(True)
        self.pack_end(demo_box)

        # cancel and OK buttons
        ok_button = Button(self)
        ok_button.text = "OK"
        ok_button.callback_pressed_add(self.__ok_button_pressed)
        ok_button.show()

        cancel_button = Button(self)
        cancel_button.text = "Cancel"
        cancel_button.callback_pressed_add(self.__cancel_button_pressed)
        cancel_button.show()

        # box for buttons
        button_box = Box(self)
        button_box.horizontal_set(True)
        button_box.show()
        button_box.pack_end(cancel_button)
        button_box.pack_end(ok_button)
        self.pack_end(button_box)
def fileselector_entry_clicked(obj, item=None):
    win = StandardWindow("fileselector", "File selector test",
                         autodel=True, size=(240, 150))

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
                            size_hint_align=FILL_BOTH,
                            size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(fse)
    fse.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="inwin", state=fse.inwin_mode)
    ck.callback_changed_add(toggle_inwin, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fse.folder_only)
    ck.callback_changed_add(toggle_folder_only, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="is_save", state=fse.is_save)
    ck.callback_changed_add(toggle_is_save, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fse.expandable)
    ck.callback_changed_add(toggle_expandable, fse)
    hbox.pack_end(ck)
    ck.show()

    win.show()
Example #38
0
    def __init__(self, parent, session):
        PreferencesDialog.__init__(self, "Session")

        # TODO: Construct and populate this with an Idler

        self.session = session

        widgets = {}

        elm_conf = Configuration()

        s = session.settings()

        t = Table(self,
                  padding=(5, 5),
                  homogeneous=True,
                  size_hint_align=FILL_BOTH)
        self.box.pack_end(t)
        t.show()

        i = 0

        INT_MIN = -2147483648
        INT_MAX = 2147483647

        scale = elm_conf.scale

        for k in dir(s):
            if k.startswith("__"): continue
            try:
                a = getattr(s, k)
                if isinstance(a, lt.disk_cache_algo_t):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    # XXX: lt-rb python bindings don't have all values.
                    w.min_max = 0, 2  #len(lt.disk_cache_algo_t.values.keys())
                    for name, val in lt.disk_cache_algo_t.names.items():
                        w.special_value_add(val, name)
                    w.value = a
                elif isinstance(a, bool):
                    w = Check(t)
                    w.size_hint_align = 1.0, 0.0
                    w.style = "toggle"
                    w.state = a
                elif isinstance(a, int):
                    w = Spinner(t)
                    w.size_hint_align = FILL_HORIZ
                    w.min_max = INT_MIN, INT_MAX
                    w.value = a
                elif isinstance(a, float):
                    w = Slider(t)
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.unit_format = "%1.2f"
                    if k.startswith("peer_turnover"):
                        w.min_max = 0.0, 1.0
                    else:
                        w.min_max = 0.0, 20.0
                    w.value = a
                elif k == "peer_tos":
                    # XXX: This is an int pair in libtorrent,
                    #      which doesn't have a python equivalent.
                    continue
                elif k == "user_agent":
                    w = Entry(t)
                    w.size_hint_align = 1.0, 0.0
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.editable = False
                    w.entry = cgi.escape(a)
                else:
                    w = Entry(t)
                    w.part_text_set("guide", "Enter here")
                    w.size_hint_align = FILL_HORIZ
                    w.size_hint_weight = EXPAND_HORIZ
                    w.single_line = True
                    w.entry = cgi.escape(a)
                l = Label(t)
                l.text = k.replace("_", " ").capitalize()
                l.size_hint_align = 0.0, 0.0
                l.size_hint_weight = EXPAND_HORIZ
                l.show()
                t.pack(l, 0, i, 1, 1)
                #w.size_hint_min = scale * 150, scale * 25
                t.pack(w, 1, i, 1, 1)
                w.show()
                widgets[k] = w
                i += 1
            except TypeError:
                pass  #print("Error {}".format(k))

        save_btn = Button(self)
        save_btn.text = "Apply session settings"
        save_btn.callback_clicked_add(self.apply_settings, widgets, session)
        save_btn.show()
        self.box.pack_end(save_btn)
Example #39
0
File: find.py Project: emctoo/ePad
    def __init__(self):

        # Dialog Window Basics
        self.findDialog = Window("find", ELM_WIN_DIALOG_BASIC)
        self.findDialog.callback_delete_request_add(self.closeFind)
        #    Set Window Icon
        #       Icons work  in ubuntu min everything compiled
        #       but not bodhi rc3
        icon = Icon(self.findDialog,
                    size_hint_weight=EXPAND_BOTH,
                    size_hint_align=FILL_BOTH)
        icon.standard_set('edit-find-replace')
        icon.show()
        self.findDialog.icon_object_set(icon.object_get())
        #    Set Dialog background
        background = Background(self.findDialog, size_hint_weight=EXPAND_BOTH)
        self.findDialog.resize_object_add(background)
        background.show()
        #    Main box to hold shit
        mainBox = Box(self.findDialog, size_hint_weight=EXPAND_BOTH)
        self.findDialog.resize_object_add(mainBox)
        mainBox.show()

        # Search Section
        #    Horizontal Box to hold search stuff
        seachBox = Box(self.findDialog, horizontal=True,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_BOTH, padding=PADDING)
        seachBox.show()
        mainBox.pack_end(seachBox)
        #    Label for search entry
        seachLabel = Label(self.findDialog, text="Search for:",
                           size_hint_weight=EXPAND_NONE,
                           size_hint_align=FILL_HORIZ)
        seachBox.pack_end(seachLabel)
        seachLabel.show()
        #    Search Entry
        self.sent = Entry(self.findDialog, scrollable=True, single_line=True,
                          size_hint_weight=EXPAND_HORIZ,
                          size_hint_align=FILL_HORIZ)
        self.sent.callback_activated_add(self.find)  # Enter activates find fn
        self.sent.show()
        seachBox.pack_end(self.sent)

        #    Check boxs for Search Options
        #   FIXME: add callbacks  These states should be in config file
        caseCk = Check(self.findDialog, text="Case sensitive",
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_HORIZ, state=CASE_SENSITIVE)
        caseCk.callback_changed_add(self.ckCase)
        caseCk.show()
        mainBox.pack_end(caseCk)
        wordCk = Check(self.findDialog, text="Match only a whole word",
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_HORIZ, state=WHOLE_WORD)
        wordCk.callback_changed_add(self.ckWord)
        wordCk.show()
        mainBox.pack_end(wordCk)

        # Dialog Buttons
        #    Horizontal Box for Dialog Buttons
        buttonBox = Box(self.findDialog, horizontal=True,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH, padding=PADDING)
        buttonBox.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0)
        buttonBox.show()
        mainBox.pack_end(buttonBox)
        #    Cancel Button
        cancelBtn = Button(self.findDialog, text="Cancel",
                           size_hint_weight=EXPAND_NONE)
        cancelBtn.callback_clicked_add(self.closeFind)
        cancelBtn.show()
        buttonBox.pack_end(cancelBtn)
        #    Ok Button
        okBtn = Button(self.findDialog, text=" Find ",
                       size_hint_weight=EXPAND_NONE)
        okBtn.callback_clicked_add(self.find)
        okBtn.show()
        buttonBox.pack_end(okBtn)

        # Ensure the min height
        self.findDialog.resize(300, 1)
        self.findDialog.show()
def index_clicked(obj):
    win = StandardWindow("index", "Index test", autodel=True, size=(320, 480))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    # index
    idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    idx.callback_delay_changed_add(cb_idx_delay_changed)
    idx.callback_changed_add(cb_idx_changed)
    idx.callback_selected_add(cb_idx_selected)
    win.resize_object_add(idx)
    idx.show()

    # genlist
    itc = GenlistItemClass(item_style="default",
                           text_get_func=gl_text_get)
                           # content_get_func=gl_content_get,
                           # state_get_func=gl_state_get)
    gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(gl)
    gl.show()


    for i in 'ABCDEFGHILMNOPQRSTUVZ':
        for j in 'acegikmo':
            gl_item = gl.item_append(itc, i + j)
            if j == 'a':
                idx_item = idx.item_append(i, cb_idx_item, gl_item)
                idx_item.data["gl_item"] = gl_item

    idx.level_go(0)

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="autohide_disabled")
    ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="indicator_disabled")
    ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="horizontal")
    ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    win.show()
    def __init__(self):
        StandardWindow.__init__(self, "espionage", "EFL DBus Spy - Espionage")

        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: elm.exit())

        box = Box(self)
        self.resize_object_add(box)
        box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        box.show()

        tb = Table(self)
        box.pack_end(tb)
        tb.show()

        lb = Label(self, text="Connect to:", scale=1.3)
        tb.pack(lb, 0, 0, 1, 2)
        lb.show()

        flip = FlipSelector(self, scale=1.3)
        flip.item_append("Session Bus", self.flip_selected_cb, session_bus)
        flip.item_append("System Bus", self.flip_selected_cb, system_bus)
        tb.pack(flip, 1, 0, 1, 2)
        flip.show()

        chk = Check(self, text="Show private services")
        chk.size_hint_align = 0.0, 1.0
        chk.state = options.show_private_stuff
        chk.callback_changed_add(self.show_private_cb)
        tb.pack(chk, 2, 0, 1, 1)
        chk.show()

        chk = Check(self, text="Show DBus introspectables")
        chk.size_hint_align = 0.0, 0.0
        chk.state = options.show_introspect_stuff
        chk.callback_changed_add(self.show_introspectables_cb)
        tb.pack(chk, 2, 1, 1, 1)
        chk.show()

        vpanes = Panes(self, horizontal=True)
        vpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        vpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        vpanes.content_left_size = 2.0 / 3
        box.pack_end(vpanes)
        vpanes.show()

        hpanes = Panes(self)
        hpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        hpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        hpanes.content_left_size = 1.0 / 3
        vpanes.part_content_set("left", hpanes)
        self.panes = hpanes
        hpanes.show()

        self.names_list = NamesList(self)
        hpanes.part_content_set("left", self.names_list)

        self.detail_list = DetailList(self)
        hpanes.part_content_set("right", self.detail_list)

        self.sigs_receiver = SignalReceiver(self)
        vpanes.part_content_set("right", self.sigs_receiver)

        self.resize(700, 500)
        self.show()
def window_states_clicked(obj):
    win = Window("window-states",
                 ELM_WIN_BASIC,
                 title="Window States test",
                 autodel=True,
                 size=(280, 400))
    win.callback_moved_add(cb_win_moved)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    print(win.available_profiles)

    bg = Background(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    hbox = Box(win,
               horizontal=True,
               size_hint_align=FILL_HORIZ,
               size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    for state in [True, False]:
        bt = Button(win,
                    text="Alpha " + ("On" if state else "Off"),
                    size_hint_align=FILL_HORIZ,
                    size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_alpha, win, bg, state)
        hbox.pack_end(bt)
        bt.show()

    for state in [True, False]:
        bt = Button(win,
                    text="FS " + ("On" if state else "Off"),
                    size_hint_align=FILL_HORIZ,
                    size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_fullscreen, win, state)
        hbox.pack_end(bt)
        bt.show()

    sl = Slider(win,
                text="Visual test",
                indicator_format="%3.0f",
                min_max=(50, 150),
                value=50,
                inverted=True,
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.5, EVAS_HINT_FILL))
    vbox.pack_end(sl)
    sl.show()

    ck = Check(win, text="Resize on rotate", size_hint_align=(0.0, 0.0))
    vbox.pack_end(ck)
    ck.show()

    hbox = Box(win,
               horizontal=True,
               size_hint_align=FILL_HORIZ,
               size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    for rot in [0, 90, 180, 270]:
        bt = Button(win,
                    text="Rot " + str(rot),
                    size_hint_align=FILL_HORIZ,
                    size_hint_weight=EXPAND_HORIZ)
        bt.callback_clicked_add(cb_rot, win, ck, rot)
        hbox.pack_end(bt)
        bt.show()

    win.show()
Example #43
0
File: gui.py Project: DaveMDS/egitu
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)

        # title
        self.part_text_set('title,text', 'Clone')
        self.part_content_set('title,icon', SafeIcon(self, 'egitu'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # url
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Path or URL to clone')
        tb.pack(en, 0, 1, 2, 1)
        en.show()
        self.url_entry = en

        # parent folder
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Parent folder to clone into')
        tb.pack(en, 0, 2, 1, 1)
        en.show()

        bt = Button(self, text='', content=SafeIcon(self, 'folder'))
        bt.callback_clicked_add(self._folder_clicked_cb)
        tb.pack(bt, 1, 2, 1, 1)
        bt.show()
        self.folder_entry = en

        # shallow check
        ck = Check(self, text='Shallow (no history and no branches, faster)',
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 2, 1)
        ck.show()
        self.shallow_check = ck

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # bottons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Clone')
        bt.callback_clicked_add(self._clone_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.clone_btn = bt

        #
        self.show()
Example #44
0
class MainWin(StandardWindow):
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        ### main table (inside a padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        self.resize_object_add(frame)
        frame.content = table = Table(frame)
        frame.show()

        ### header horiz box
        self.header_box = Box(self,
                              horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        table.pack(self.header_box, 0, 0, 3, 1)
        self.header_box.show()

        # genlist with archive content (inside a small padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        table.pack(frame, 0, 1, 3, 1)

        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=self._gl_file_text_get)
        self.fold_itc = GenlistItemClass(
            item_style="one_icon",
            text_get_func=self._gl_fold_text_get,
            content_get_func=self._gl_fold_icon_get)
        self.file_list = Genlist(frame, homogeneous=True)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        frame.content = self.file_list
        frame.show()

        # rect hack to force a min size on the genlist
        r = evas.Rectangle(table.evas,
                           size_hint_min=(250, 250),
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        table.pack(r, 0, 1, 3, 1)

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 2, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 3, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 4, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 4, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table,
                             text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 4, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table,
                                       text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 5, 1, 1)
        self.create_folder_chk.callback_changed_add(
            lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.show()

    def del_check_cb(self, check):
        self.app.delete_after_extract = check.state

    def update_ui(self, listing_in_progress=False):
        box = self.header_box
        box.clear()
        ui_disabled = True

        # file listing in progress
        if listing_in_progress:
            spin = Progressbar(box, style='wheel', pulse_mode=True)
            spin.pulse(True)
            spin.show()
            box.pack_end(spin)

            lb = Label(box,
                       text=_('Reading archive, please wait...'),
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=(0.0, 0.5))
            lb.show()
            box.pack_end(lb)

        # or header button
        else:
            if self.app.file_name is None:
                txt = _('No archive loaded, click to choose a file')
            else:
                ui_disabled = False
                txt = _('<b>Archive:</b> %s') % \
                      (os.path.basename(self.app.file_name))

            txt = '<align=left>%s</align>' % txt
            lb = Label(box, ellipsis=True, text=txt)
            bt = Button(box,
                        content=lb,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_fill=FILL_HORIZ)
            bt.callback_clicked_add(lambda b: \
                        FileSelectorInwin(self, _('Choose an archive'),
                                          self._archive_selected_cb,
                                          path=os.getcwd()))
            box.pack_end(bt)
            bt.show()

        # always show the about button
        sep = Separator(box)
        box.pack_end(sep)
        sep.show()

        ic = SafeIcon(box, 'help-about', size_hint_min=(24, 24))
        ic.callback_clicked_add(lambda i: InfoWin(self))
        box.pack_end(ic)
        ic.show()

        for widget in (self.extract_btn, self.fsb, self.create_folder_chk,
                       self.del_chk):
            widget.disabled = ui_disabled

        self.update_fsb_label()

    def _archive_selected_cb(self, path):
        if os.path.isfile(path):
            self.app.load_file(path)

    def update_fsb_label(self):
        if self.create_folder_chk.state is True:
            name = os.path.splitext(os.path.basename(self.app.file_name))[0]
            self.fsb.text = os.path.join(self.app.dest_folder, name)
        else:
            self.fsb.text = self.app.dest_folder or ''

    def show_error_msg(self, msg):
        pop = Popup(self, text=msg)
        pop.part_text_set('title,text', _('Error'))

        btn = Button(self, text=_('Continue'))
        btn.callback_clicked_add(lambda b: pop.delete())
        pop.part_content_set('button1', btn)

        btn = Button(self, text=_('Exit'))
        btn.callback_clicked_add(lambda b: self.app.exit())
        pop.part_content_set('button2', btn)

        pop.show()

    def tree_populate(self, file_list=None, parent=None):
        if file_list is not None:
            self.file_list.clear()
            self._file_list = file_list

        if parent is None:
            prefix = None  # items must match this prefix to be listed
            fscount = 0  # folder must have this number of slashes
            dscount = 1  # files must have this number of slashes
        else:
            prefix = parent.data[:-1]
            fscount = prefix.count('/') + 1
            dscount = fscount + 1

        files = []
        for path in self._file_list:
            if prefix and not path.startswith(prefix):
                continue

            if path.endswith('/'):
                if path.count('/') == dscount:
                    self.file_list.item_append(self.fold_itc,
                                               path,
                                               parent,
                                               flags=ELM_GENLIST_ITEM_TREE)
            else:
                if path.count('/') == fscount:
                    files.append(path)

        for path in files:
            self.file_list.item_append(self.file_itc, path, parent)

    def _gl_fold_text_get(self, obj, part, item_data):
        return item_data[:-1].split('/')[-1]

    def _gl_fold_icon_get(self, obj, part, item_data):
        return SafeIcon(obj, 'folder')

    def _gl_file_text_get(self, obj, part, item_data):
        return item_data.split('/')[-1]

    def _gl_expand_req_cb(self, gl, item):
        item.expanded = True

    def _gl_expanded_cb(self, gl, item):
        self.tree_populate(None, item)

    def _gl_contract_req_cb(self, gl, item):
        item.expanded = False

    def _gl_contracted_cb(self, gl, item):
        item.subitems_clear()

    def extract_btn_cb(self, btn):
        self.prog_popup = None
        self.app.dest_folder = self.fsb.text
        self.app.extract_archive()

    def build_prog_popup(self):
        pp = Popup(self)
        pp.part_text_set('title,text', _('Extracting files, please wait...'))
        pp.show()

        vbox = Box(self)
        pp.part_content_set('default', vbox)
        vbox.show()

        lb = Label(self,
                   ellipsis=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(lb)
        lb.show()

        pb = Progressbar(pp,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        vbox.pack_end(pb)
        pb.show()

        bt = Button(pp, text=_('Cancel'))
        bt.callback_clicked_add(lambda b: self.app.abort_operation())
        pp.part_content_set('button1', bt)

        self.prog_pbar = pb
        self.prog_label = lb
        self.prog_popup = pp

    def extract_progress(self, progress, cur_name):
        if self.prog_popup is None:
            self.build_prog_popup()

        self.prog_pbar.value = progress
        self.prog_label.text = cur_name

    def extract_finished(self):
        if self.prog_popup:
            self.prog_popup.delete()
            self.prog_popup = None

    def _open_fm_and_exit_cb(self, bt):
        utils.xdg_open(self.app.dest_folder)
        self.app.exit()

    def _open_term_and_exit_cb(self, bt):
        utils.open_in_terminal(self.app.dest_folder)
        self.app.exit()

    def ask_what_to_do_next(self):
        pop = Popup(self)
        pop.part_text_set('title,text', _('Extract completed'))

        box = Box(pop)
        pop.content = box
        box.show()

        lb = Label(pop, text=_('What to do next?'), size_hint_align=FILL_HORIZ)
        box.pack_end(lb)
        lb.show()

        btn = Button(pop,
                     text=_('Open Filemanager'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(self._open_fm_and_exit_cb)
        box.pack_end(btn)
        btn.show()

        btn = Button(pop, text=_('Open Terminal'), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(self._open_term_and_exit_cb)
        box.pack_end(btn)
        btn.show()

        btn = Button(pop,
                     text=_('Close this popup'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: pop.delete())
        box.pack_end(btn)
        btn.show()

        btn = Button(pop, text=_('Exit'), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: self.app.exit())
        box.pack_end(btn)
        btn.show()

        pop.show()
Example #45
0
def fileselector_entry_clicked(obj, item=None):
    win = StandardWindow("fileselector",
                         "File selector test",
                         autodel=True,
                         size=(240, 150))

    vbox = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    fse = FileselectorEntry(win,
                            text="Select a file",
                            inwin_mode=False,
                            size_hint_align=FILL_BOTH,
                            size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(fse)
    fse.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="inwin", state=fse.inwin_mode)
    ck.callback_changed_add(toggle_inwin, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fse.folder_only)
    ck.callback_changed_add(toggle_folder_only, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="is_save", state=fse.is_save)
    ck.callback_changed_add(toggle_is_save, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fse.expandable)
    ck.callback_changed_add(toggle_expandable, fse)
    hbox.pack_end(ck)
    ck.show()

    win.show()
Example #46
0
File: gui.py Project: lonid/epack
class MainWin(StandardWindow):
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        # main vertical box
        vbox = Box(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        ### header horiz box (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        self.header_box = Box(self, horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        frame.content = self.header_box
        self.header_box.show()

        # genlist with archive content
        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=gl_file_text_get)
        self.fold_itc = GenlistItemClass(item_style="one_icon",
                                         text_get_func=gl_fold_text_get,
                                         content_get_func=gl_fold_icon_get)
        self.file_list = Genlist(self, homogeneous=True,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        vbox.pack_end(self.file_list)
        self.file_list.show()

        ### footer table (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        table = Table(frame)
        frame.content = table
        table.show()

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 0, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True,
                        size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 1, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 2, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 2, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table, text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 2, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table, text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 3, 1, 1)
        self.create_folder_chk.callback_changed_add(
                               lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.resize(300, 380)
        self.show()

    def del_check_cb(self, check):
        self.app.delete_after_extract = check.state

    def update_ui(self, listing_in_progress=False):
        box = self.header_box
        box.clear()
        ui_disabled = True

        # file listing in progress
        if listing_in_progress:
            spin = Progressbar(box, style='wheel', pulse_mode=True)
            spin.pulse(True)
            spin.show()
            box.pack_end(spin)

            lb = Label(box, text=_('Reading archive, please wait...'),
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=(0.0, 0.5))
            lb.show()
            box.pack_end(lb)

        # or header button
        else:
            if self.app.file_name is None:
                txt = _('No archive loaded, click to choose a file')
            else:
                ui_disabled = False
                txt = _('<b>Archive:</b> %s') % \
                      (os.path.basename(self.app.file_name))

            lb = Label(box, text='<align=left>%s</align>' % txt)
            bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ,
                        size_hint_fill=FILL_HORIZ)
            bt.callback_clicked_add(lambda b: \
                        FileSelectorInwin(self, _('Choose an archive'),
                                          self._archive_selected_cb,
                                          path=os.getcwd()))
            box.pack_end(bt)
            bt.show()

        # always show the about button
        sep = Separator(box)
        box.pack_end(sep)
        sep.show()

        ic = Icon(box, standard='dialog-info', size_hint_min=(24,24))
        ic.callback_clicked_add(lambda i: InfoWin(self))
        box.pack_end(ic)
        ic.show()

        for widget in (self.extract_btn, self.fsb,
                       self.create_folder_chk, self.del_chk):
            widget.disabled = ui_disabled

        self.update_fsb_label()

    def _archive_selected_cb(self, path):
        if os.path.isfile(path):
            self.app.load_file(path)

    def update_fsb_label(self):
        if self.create_folder_chk.state is True:
            name = os.path.splitext(os.path.basename(self.app.file_name))[0]
            self.fsb.text = os.path.join(self.app.dest_folder, name)
        else:
            self.fsb.text = self.app.dest_folder or ''

    def show_error_msg(self, msg):
        pop = Popup(self, text=msg)
        pop.part_text_set('title,text', _('Error'))

        btn = Button(self, text=_('Continue'))
        btn.callback_clicked_add(lambda b: pop.delete())
        pop.part_content_set('button1', btn)

        btn = Button(self, text=_('Exit'))
        btn.callback_clicked_add(lambda b: self.app.exit())
        pop.part_content_set('button2', btn)

        pop.show()

    def tree_populate(self, file_list=None, parent=None):
        if file_list is not None:
            self.file_list.clear()
            self._file_list = file_list

        if parent is None:
            prefix = None # items must match this prefix to be listed
            fscount = 0   # folder must have this number of slashes
            dscount = 1   # files must have this number of slashes
        else:
            prefix = parent.data[:-1]
            fscount = prefix.count('/') + 1
            dscount = fscount + 1

        files = []
        for path in self._file_list:
            if prefix and not path.startswith(prefix):
                continue

            if path.endswith('/'):
                if path.count('/') == dscount:
                    self.file_list.item_append(self.fold_itc, path, parent,
                                               flags=ELM_GENLIST_ITEM_TREE)
            else:
                if path.count('/') == fscount:
                    files.append(path)

        for path in files:
            self.file_list.item_append(self.file_itc, path, parent)

    def _gl_expand_req_cb(self, gl, item):
        item.expanded = True

    def _gl_expanded_cb(self, gl, item):
        self.tree_populate(None, item)

    def _gl_contract_req_cb(self, gl, item):
        item.expanded = False

    def _gl_contracted_cb(self, gl, item):
        item.subitems_clear()

    def extract_btn_cb(self, btn):
        self.prog_popup = None
        self.app.dest_folder = self.fsb.text
        self.app.extract_archive()

    def build_prog_popup(self):
        pp = Popup(self)
        pp.part_text_set('title,text', _('Extracting files, please wait...'))
        pp.show()

        vbox = Box(self)
        pp.part_content_set('default', vbox)
        vbox.show()

        lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(lb)
        lb.show()

        pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        vbox.pack_end(pb)
        pb.show()

        bt = Button(pp, text=_('Cancel'))
        bt.callback_clicked_add(lambda b: self.app.abort_operation())
        pp.part_content_set('button1', bt)

        self.prog_pbar = pb
        self.prog_label = lb
        self.prog_popup = pp

    def extract_progress(self, progress, cur_name):
        if self.prog_popup is None:
            self.build_prog_popup()

        self.prog_pbar.value = progress
        self.prog_label.text = cur_name

    def extract_finished(self):
        if self.prog_popup:
            self.prog_popup.delete()
            self.prog_popup = None

    def _open_fm_and_exit_cb(self, bt):
        utils.xdg_open(self.app.dest_folder)
        self.app.exit()

    def _open_term_and_exit_cb(self, bt):
        utils.open_in_terminal(self.app.dest_folder)
        self.app.exit()

    def ask_what_to_do_next(self):
        pop = Popup(self)
        pop.part_text_set('title,text', _('Extract completed'))

        box = Box(pop)
        pop.content = box
        box.show()

        lb = Label(pop, text=_('What to do next?'),
                   size_hint_align=FILL_HORIZ)
        box.pack_end(lb)
        lb.show()

        btn = Button(pop, text=_('Open Filemanager'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(self._open_fm_and_exit_cb)
        box.pack_end(btn)
        btn.show()

        btn = Button(pop, text=_('Open Terminal'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(self._open_term_and_exit_cb)
        box.pack_end(btn)
        btn.show()

        btn = Button(pop, text=_('Close this popup'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: pop.delete())
        box.pack_end(btn)
        btn.show()

        btn = Button(pop, text=_('Exit'),
                     size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: self.app.exit())
        box.pack_end(btn)
        btn.show()

        pop.show()
Example #47
0
                                    str4="test4")

    box0 = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box0)
    box0.show()

    lb = Label(win)
    lb.text = ("Please select a test from the list below by clicking<br>"
               "the test button to show the test window.")
    lb.show()

    fr = Frame(win, text="Information", content=lb)
    box0.pack_end(fr)
    fr.show()

    tg = Check(win, style="toggle", text="UI-Mirroring:")
    tg.callback_changed_add(cb_mirroring)
    box0.pack_end(tg)
    tg.show()

    bx1 = Box(win,
              size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
              size_hint_align=(EVAS_HINT_FILL, 0.0),
              horizontal=True)
    box0.pack_end(bx1)
    bx1.show()

    lb = Label(win, text="Filter:")
    bx1.pack_end(lb)
    lb.show()
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)
        
        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state
        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

        # popup buttons
        btn = Button(parent)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', btn)

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
Example #49
0
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set(
            "Settings", "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set(
            "Settings", "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
Example #50
0
    def __init__(self, app):
        self.app = app

        Popup.__init__(self, app.win)
        self.part_text_set('title,text', 'Discard local changes')
        self.part_content_set('title,icon', Icon(self, standard='user-trash'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 1, 1)
        sep.show()

        # warning label
        en = Entry(self, editable=False,
                   text='<warning>WARNING: This operation is not reversible!</warning><br>' \
                        'Selected files (or ALL files, if nothing is selected) will be ' \
                        'reverted to the state of the last commit.',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 0, 1, 1, 1)
        en.show()

        # changes list
        r = Rectangle(self.evas, size_hint_min=(300,200),
                      size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li = List(self, multi_select=True,
                  size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li.callback_selected_add(self._list_selection_changed_cb)
        li.callback_unselected_add(self._list_selection_changed_cb)
        tb.pack(li, 0, 2, 1, 1)
        tb.pack(r, 0, 2, 1, 1)

        for path in sorted(self.app.repo.status.changes):
            mod, staged, name, new_name = self.app.repo.status.changes[path]
            icon = Icon(self, standard='git-mod-'+mod)
            check = Check(self, text='', state=staged, disabled=True)
            label = '{} → {}'.format(name, new_name) if new_name else name
            it = li.item_append(label, icon, check)
            it.data['mod'] = mod

        li.go()
        li.show()
        self.file_list = li

        # delete untracked check
        ck = Check(self, text='Also delete untracked files', state=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 1, 1)
        ck.show()
        self.untracked_chk = ck

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 1, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text="Discard EVERYTHING!",
                    content=Icon(self, standard='user-trash'))
        bt.callback_clicked_add(self._confirm_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.confirm_btn = bt

        #
        self.show()
Example #51
0
class FontSelector(Box):
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None

        self.__first_run = True
        self.use_theme = False
        self.override_theme_font_size = True
        self.override_font_size = 14
        self.theme_data = None
        self.default_font = 'Sans'
        self.default_font_style = 'Regular'
        self.default_font_size = 14
        self.selected_font = self.default_font
        self.selected_font_style = self.default_font_style
        self.selected_font_size = self.default_font_size
        self.font_style_str = self.get_text_style(self.selected_font,
                                                  self.selected_font_style,
                                                  self.selected_font_size)
        self.preview_text = 'abcdefghijk ABCDEFGHIJK'
        # Font size min and max
        self.fs_min = 8
        self.fs_max = 72

        lb = Label(self,
                   text="<br><hilight><i>Select Font</i></hilight>",
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
        lb.show()
        self.pack_end(lb)
        sp = Separator(self,
                       horizontal=True,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        sp.show()
        self.pack_end(sp)
        # A horizontal box to hold our font list and font styles
        fontBox = Box(self,
                      horizontal=True,
                      homogeneous=True,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        fontBox.show()
        self.pack_end(fontBox)
        # A vertical box to hold label and list of font families
        vBoxFL = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFL.show()
        fontBox.pack_end(vBoxFL)
        # A vertical box to hold label and list of font styles
        vBoxFS = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFS.show()
        fontBox.pack_end(vBoxFS)
        # Generate our needed font data
        #now =time.time()
        fonts = []
        fonts_raw = self.evas.font_available_list()
        # populate with default font families
        #   see elm_font_available_hash_add Function in EFL
        f_families = ['Sans', 'Serif', 'Monospace']
        f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic']
        fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles]

        self.fonts_hash = {}
        for font in fonts_raw:
            a = font_properties_get(font)
            # if font name contains a '-' a.name will replace with '\\-'
            #   This needs removed to properly display the name
            fn = a.name.replace('\\', '')
            fonts.append(fn)
            if fn in self.fonts_hash:
                self.fonts_hash.setdefault(fn, []).append(a.styles[0])
            else:
                self.fonts_hash[fn] = [a.styles[0]]

        # Deal with some problematic special cases
        for a, s in self.fonts_hash.items():
            #print(a,s)
            if s:
                if len(s) == 1:
                    s[0] = s[0].rstrip()
                    if s[0] == u'regular':
                        s[0] = u'Regular'
                    if s[0] == u'Medium Italic':
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    elif s[0] == u'Italic':
                        if a != u'Romande ADF Script Std':
                            self.fonts_hash.setdefault(a,
                                                       []).append(u'Regular')
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 2:
                    if any(u'Oblique' in w for w in s):
                        if a not in {
                                u'Baskervald ADF Std Heavy',
                                u'Latin Modern Roman Demi'
                        }:
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                            self.fonts_hash.setdefault(
                                a, []).append(u'Bold Oblique')
                    elif any(u'Italic' in w for w in s):
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 3 and set(s) == {
                        u'Bold', u'Oblique', u'Medium'
                }:
                    # case GWMonospace
                    self.fonts_hash.setdefault(a, []).append(u'Bold Oblique')
                elif len(s) == 3 and set(s) == {
                        u'Italic', u'Regular', u'Bold'
                }:
                    # Case Eden Mills
                    self.fonts_hash.setdefault(a, []).append(u'Bold Italic')
                elif len(s) < 4:
                    print("may need fixed Font style for %s: %s" % (a, s))
        #print(self.fonts_hash)

        # for some strange reason many fonts are displayed multiple times. The following lines remove
        # all duplicates and then sort them alphabetically.
        # FIXME: Is this still true
        fonts = list(set(fonts))
        fonts.sort(cmp=locale.strcoll)

        # Elm List for holding font options
        self.font_list = List(self,
                              size_hint_align=FILL_BOTH,
                              size_hint_weight=EXPAND_BOTH,
                              mode=ELM_LIST_LIMIT)
        #self.font_list.callback_selected_add(self.__font_demo_name_set)
        for font in fonts:
            self.font_list.item_append(font.replace('\\', ''))
            if font == self.selected_font:
                font_it = self.font_list.last_item_get()
        #print  (time.time()- now)
        self.font_list.go()
        self.font_list.show()

        font_family_label = Label(self)
        font_family_label.text = "<br><b>Font:</b>"
        font_family_label.show()
        vBoxFL.pack_end(font_family_label)
        vBoxFL.pack_end(self.font_list)

        # Elm List for hold font styles
        self.font_style = List(self,
                               size_hint_align=FILL_BOTH,
                               size_hint_weight=EXPAND_BOTH,
                               mode=ELM_LIST_LIMIT)
        #self.font_style.callback_selected_add(self.__font_demo_style_set)

        self.__reset_font_style_list(font_it.text_get())

        self.font_style.go()
        self.font_style.show()

        font_style_label = Label(self)
        font_style_label.text = "<br><b>Style:</b>"
        font_style_label.show()
        vBoxFS.pack_end(font_style_label)
        vBoxFS.pack_end(self.font_style)

        # A table to hold font size Spinner and set theme default Check
        tb = Table(self,
                   homogeneous=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        self.pack_end(tb)
        tb.show()

        # spinner to choose the font size
        self.font_sizer = Spinner(self)
        self.font_sizer.min_max_set(self.fs_min, self.fs_max)
        self.font_sizer.value_set(self.selected_font_size)
        #self.font_sizer.callback_changed_add(self.__font_demo_size_set)
        self.font_sizer.show()
        # Label for Spinner
        font_sizer_label = Label(self)
        font_sizer_label.text = "Font Size:  "
        font_sizer_label.show()

        size_box = Box(self,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        size_box.horizontal_set(True)
        size_box.pack_end(font_sizer_label)
        size_box.pack_end(self.font_sizer)
        size_box.show()
        tb.pack(size_box, 33, 0, 34, 34)

        self.use_theme_ck = Check(self,
                                  text="Theme Default   ",
                                  size_hint_weight=EXPAND_HORIZ,
                                  size_hint_align=(1, 0.5))
        self.use_theme_ck.callback_changed_add(self.__use_theme_checked)
        self.use_theme_ck.show()
        tb.pack(self.use_theme_ck, 67, 0, 33, 34)

        # Entry to hold sample text
        self.font_demo = Entry(self,
                               single_line=True,
                               editable=False,
                               context_menu_disabled=True,
                               text=self.preview_text,
                               scrollable=True,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.font_demo.show()

        demo_box = Frame(self,
                         size_hint_align=FILL_BOTH,
                         text="Preview:",
                         content=self.font_demo)
        demo_box.show()

        # Fixme: move this shit
        font_it.selected_set(True)
        font_it.show()
        # Ensure focus is on Font List
        self.font_list.focus_set(True)
        self.pack_end(demo_box)

        # cancel and OK buttons
        ok_button = Button(self)
        ok_button.text = "OK"
        ok_button.callback_pressed_add(self.__ok_button_pressed)
        ok_button.show()

        cancel_button = Button(self)
        cancel_button.text = "Cancel"
        cancel_button.callback_pressed_add(self.__cancel_button_pressed)
        cancel_button.show()

        # box for buttons
        button_box = Box(self)
        button_box.horizontal_set(True)
        button_box.show()
        button_box.pack_end(cancel_button)
        button_box.pack_end(ok_button)
        self.pack_end(button_box)

    def callback_activated_add(self, cb):
        self.actionCallback = cb

    def callback_cancel_add(self, cb):
        self.cancelCallback = cb

    def set_preview_text(self, text):
        self.preview_text = text
        self.font_demo.entry_set(text)

    def __cancel_button_pressed(self, btn):
        self.use_theme = self.show.use_theme_init
        #print("cancel", self.use_theme)
        self.selected_font = self.default_font
        self.selected_font_style = self.default_font_style
        self.selected_font_size = self.default_font_size
        self.font_style_str = self.get_text_style(self.selected_font,
                                                  self.selected_font_style,
                                                  self.selected_font_size)
        if self.cancelCallback:
            self.cancelCallback(self)

    def __ok_button_pressed(self, btn):
        # Set selections
        # if use_theme is set any of these could be potentially unset
        try:
            self.selected_font = self.font_list.selected_item_get().text_get()
            self.selected_font_style = self.font_style.selected_item_get(
            ).text_get()
            self.selected_font_size = self.font_sizer.value_get()
            self.font_style_str = self.get_text_style(self.selected_font,
                                                      self.selected_font_style,
                                                      self.selected_font_size)
        except AttributeError:
            self.selected_font = self.default_font
            if self.default_font_style in self.fonts_hash[self.selected_font]:
                self.selected_font_style = self.default_font_style
            else:
                #print("OK attribute error", self.selected_font, self.default_font_style)
                self.selected_font_style = self.fonts_hash.items[
                    self.selected_font][0]
            self.selected_font_size = self.default_font_size
            self.font_style_str = self.get_text_style(self.selected_font,
                                                      self.selected_font_style,
                                                      self.selected_font_size)
        self.use_theme = self.use_theme_ck.state_get()
        if self.actionCallback:
            self.actionCallback(self)

    def __use_theme_checked(self, ck):
        self.use_theme = ck.state_get()
        #print ( '__use_theme_checked')
        if self.use_theme:
            if not self.theme_data:
                self._set_theme_data()
            self.set_font(*self.theme_data)
            while self.font_demo.text_style_user_peek():
                self.font_demo.text_style_user_pop()
            if self.theme_data[1] == None:
                try:
                    self.font_style.selected_item_get().selected = False
                except AttributeError:
                    pass
            if self.override_theme_font_size:
                self.font_demo.text_style_user_push(
                    "DEFAULT='font_size={0}'".format(self.override_font_size))
                self.font_sizer.value_set(self.override_font_size)
            # Ensure these are unchanged
            ck.state = self.use_theme = True
        else:
            # ensure style is selected
            self.selected_font = self.default_font
            self.selected_font_style = self.default_font_style
            self.selected_font_size = self.default_font_size
            self.font_style_str = self.get_text_style(self.selected_font,
                                                      self.selected_font_style,
                                                      self.selected_font_size)

            self.set_font(self.default_font, self.default_font_style,
                          self.default_font_size)
            # Ensure these are unchanged
            ck.state = self.use_theme = False

    def _set_theme_data(self):
        tb_style = self.font_demo.textblock.style_get()

        font = tb_style.split('text_class=entry_text')[1].split(
            'font=')[1].split("'em=")[0]
        # font may or may not have style associated with it
        if ':style=' in font:
            font, style = font.split(':style=')
        else:
            style = None
        # If font name or styyle has spaces in it
        #   textblock.style_get() inserts '\' before space
        #   then the python string split function adds another space
        # To set the style with a font name that has spaces spaces need to be removed
        font = font.replace('\\ ', ' ')
        if style:
            style = style.replace('\\ ', ' ')
        size = tb_style.split('text_class=entry_text')[1].split(
            'font_size=')[1].split(' ')[0]
        self.theme_data = [font, style, float(size)]

    def set_font(self, font, style=None, size=None):
        found_font = found_style = False

        #print(self.set_font.__name__, font, style, size, self.use_theme)
        for font_it in self.font_list.items:
            if '\\' in font:
                # Special characters in font names cause problems
                #   need to remove the escape characters before comparison
                font = font.replace('\\', '')
            if font == font_it.text:
                found = True
                self.selected_font = font_it.text
                font_it.selected = True
                font_it.show()
                break
        if size and self.fs_min <= size <= self.fs_max:
            self.selected_font_size = size
            self.font_sizer.value_set(size)
        if found_font:
            self.__reset_font_style_list(font)
            if style in self.fonts_hash[font_it.text]:
                for style_it in self.font_style.items:
                    if style == style_it.text:
                        self.selected_font_style = style_it.text
                        style_it.selected = True
                        style_it.show()
                        found_style = True
                        break

        if not found_style:
            self.__font_style_set(self.selected_font)
        # Ensure focus is on Font List
        self.font_list.focus_set(True)

    def __font_demo_name_set(self, f_list, font):

        if self.use_theme:
            self.use_theme = self.use_theme_ck.state = False
        self.__reset_font_style_list(font.text_get())
        self.__font_style_set(font.text_get())
        # Ensure focus is on Font List
        self.font_list.focus_set(True)

    def __font_demo_style_set(self, s_list, style):
        if self.use_theme:
            self.use_theme = self.use_theme_ck.state = False
        self.__font_style_set(self.font_list.selected_item_get().text_get())

    def __font_demo_size_set(self, sizer):
        if self.use_theme:
            self.use_theme = self.use_theme_ck.state = False
        self.__font_style_set(self.font_list.selected_item_get().text_get())

    def __font_style_set(self, font_name):
        #print (" __font_style_set", font_name)
        while self.font_demo.text_style_user_peek():
            self.font_demo.text_style_user_pop()

        if self.font_style.selected_item_get():
            font_style = self.font_style.selected_item_get().text_get()
        else:
            font_style = self.font_style.first_item_get().text_get()

        font_size = self.font_sizer.value_get()

        style = self.get_text_style(font_name, font_style, font_size)
        self.font_demo.text_style_user_push(style)
        self.font_style_str = style

    def __reset_font_style_list(self, font_name):
        self.font_style.clear()
        self.__normalize_font_style_list(font_name)
        for style in self.fonts_hash[font_name]:
            self.font_style.item_append(style)
            if font_name == self.default_font and style == self.selected_font_style:
                self.font_style.last_item_get().selected_set(True)
        if font_name != self.default_font:
            self.font_style.first_item_get().selected_set(True)
        #print(self.font_style.first_item_get())
        #self.font_style.first_item_get().selected_set(True)
        self.font_style.first_item_get().show()

    def get_text_style(self, font_name, font_style_str, font_size):
        if "'" in font_name:
            # Special characters in font name issue
            font_name = font_name.replace("'", "\\'")
        if font_style_str:
            style = "DEFAULT='font_size={0} font={1}:style={2}'".format(
                font_size, font_name.replace(' ', '\ '),
                font_style_str.replace(' ', '\ '))
        else:
            style = "DEFAULT='font_size={0} font={1}'".format(
                font_size, font_name.replace(' ', '\ '))
        return style

    def __normalize_font_style_list(self, font_name):
        styles_list = self.fonts_hash[font_name]
        if 'Regular' in styles_list and styles_list[0] != 'Regular':
            styles_list.remove('Regular')
            styles_list.insert(0, 'Regular')

    def show(self):
        #print("SHOW  Selected ", self.use_theme, self.selected_font, self.selected_font_style)
        #print("SHOW  default ", self.use_theme, self.default_font, self.default_font_style)
        if self.__first_run:
            # only set the callbacks once
            # needed when called from another window repeatedly
            #print("__first_run__")
            self.font_list.callback_selected_add(self.__font_demo_name_set)
            self.font_style.callback_selected_add(self.__font_demo_style_set)
            self.font_sizer.callback_changed_add(self.__font_demo_size_set)
            self.__first_run = False
        self.show.__func__.use_theme_init = self.use_theme
        self.use_theme_ck.state = self.use_theme
        if self.use_theme:
            self.__use_theme_checked(self.use_theme_ck)
        #print("selected", self.font_list.selected_item_get().text_get())
        if not self.use_theme:
            self.set_font(self.selected_font, self.selected_font_style,
                          self.selected_font_size)
        super(FontSelector, self).show()
def focus_clicked(obj, item=None):
    win = StandardWindow("focus", "Focus", autodel=True, size=(800,600))
    
    win.focus_highlight_enabled = True

    tbx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tbx)
    tbx.show()

    ### Toolbar
    tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
                   size_hint_align=(EVAS_HINT_FILL,0.0))

    tb_it = tbar.item_append("document-print", "Hello", _tb_sel)
    tb_it.disabled = True
    tb_it = tbar.item_append("folder-new", "World", _tb_sel)
    tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel)
    tb_it = tbar.item_append("mail-send", "Comes", _tb_sel)
    tb_it = tbar.item_append("clock", "Elementary", _tb_sel)

    tb_it = tbar.item_append("refresh", "Menu", _tb_sel)
    tb_it.menu = True
    tbar.menu_parent = win
    menu = tb_it.menu

    menu.item_add(None, "Shrink", "edit-cut", _tb_sel)
    menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel)
    menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel)
    menu.item_add(menu_it, "or to", "edit-paste", _tb_sel)
    menu.item_add(None, "Menu", "edit-delete", _tb_sel)

    tbx.pack_end(tbar)
    tbar.show()


    mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    tbx.pack_end(mainbx)
    mainbx.show()

    ## First Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>",
                    size_hint_align=FILL_BOTH)
    bx.pack_end(lb)
    lb.show()

    tg = Check(win, style="toggle")
    tg.part_text_set("on", "Yes")
    tg.part_text_set("off", "No")
    bx.pack_end(tg)
    tg.show()
    
    en = Entry(win, scrollable=True, single_line=True, text="This is a single line",
                    size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
    bx.pack_end(en)
    en.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()

    for i in range(2):
        bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 2))
        bx2.pack_end(bt)
        bt.show()

    sc = Scroller(win, bounce=(True,True), content_min_limit=(1,1),
                  size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    bx2.pack_end(sc)
    sc.show()

    bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH)
    sc.content = bt
    bt.show()

    #
    bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
    bx.pack_end(bt)
    bt.show()

    #
    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    bx.pack_end(bx2)
    bx2.show()
    
    for i in range(2):
        bx3 = Box(win, size_hint_align=FILL_BOTH)
        bx2.pack_end(bx3)
        bx3.show()

        for j in range(3):
            bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
            bx3.pack_end(bt)
            bt.show()
    

    sc = Scroller(win, bounce=(False, True), content_min_limit=(1,0),
                  size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    sc.content_min_limit=(1,1)
    bx2.pack_end(sc)
    sc.show()

    bx3 = Box(win, size_hint_align=FILL_BOTH)
    sc.content = bx3
    bx3.show()

    for i in range(5):
        bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH)
        bx3.pack_end(bt)
        bt.show()


    ## Second Col
    ly = Layout(win, size_hint_weight=EXPAND_BOTH)
    ly.file = edj_file, "twolines"
    mainbx.pack_end(ly)
    ly.show()

    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    ly.part_content_set("element1", bx2)
    bx2.show()

    for i in range(3):
        bt = Button(win, text="Layout", size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()
        bx2.focus_custom_chain_prepend(bt)

    bx2 = Box(win, size_hint_align=FILL_BOTH)
    ly.part_content_set("element2", bx2)
    bx2.show()

    bt = Button(win, text="Disable", size_hint_align=FILL_BOTH)
    bt.callback_clicked_add(lambda b: b.disabled_set(True))
    bx2.pack_end(bt)
    bt.show()
    bx2.focus_custom_chain_prepend(bt)

    bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH)
    bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt)
    bx2.pack_end(bt2)
    bt2.show()
    bx2.focus_custom_chain_append(bt2)

    ## Third Col
    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    mainbx.pack_end(bx)
    bx.show()

    fr = Frame(win, text="Frame", )
    bx.pack_end(fr)
    fr.show()

    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(1):
        for i in range(2):
            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()

    #
    fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    bx.pack_end(fr)
    fr.show()

    tb = Table(win,  size_hint_weight=EXPAND_BOTH)
    fr.content = tb
    tb.show()

    for j in range(2):
        for i in range(1):
            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
            tb.pack(bt, i, j, 1, 1)
            bt.show()


    win.show()
def fileselector_clicked(obj, item=None):
    win = StandardWindow("fileselector",
                         "File selector test",
                         autodel=True,
                         size=(500, 500))

    box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box1)
    box1.show()

    fs = Fileselector(win,
                      is_save=True,
                      expandable=False,
                      folder_only=False,
                      path=os.getenv("HOME"),
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
    fs.callback_done_add(fs_cb_done, win)
    fs.callback_selected_add(fs_cb_selected, win)
    fs.callback_directory_open_add(fs_cb_directory_open, win)
    box1.pack_end(fs)
    fs.show()

    fs.custom_filter_append(custom_filter_all, filter_name="All Files")
    fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
    fs.mime_types_filter_append(["text/*"], "Text Files")
    fs.mime_types_filter_append(["image/*"], "Image Files")

    sep = Separator(win)
    box1.pack_end(sep)
    sep.show()

    vbox = Box(win)
    box1.pack_end(vbox)
    vbox.show()

    # Options frame
    fr = Frame(win, text="Options")
    vbox.pack_end(fr)
    fr.show()

    fbox1 = Box(win)
    fr.content = fbox1
    fbox1.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="is_save", state=fs.is_save)
    ck.callback_changed_add(ck_cb_is_save, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fs.folder_only)
    ck.callback_changed_add(ck_cb_folder_only, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fs.expandable)
    ck.callback_changed_add(ck_cb_expandable, fs)
    fbox2.pack_end(ck)
    ck.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="multiple selection", state=fs.multi_select)
    ck.callback_changed_add(ck_cb_multi_select, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
    ck.callback_changed_add(ck_cb_buttons, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="hidden", state=fs.hidden_visible)
    ck.callback_changed_add(ck_cb_hidden, fs)
    fbox2.pack_end(ck)
    ck.show()

    # Getters frame
    fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    bt = Button(win, text="selected_get")
    bt.callback_clicked_add(bt_cb_sel_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="path_get")
    bt.callback_clicked_add(bt_cb_path_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="selected_paths")
    bt.callback_clicked_add(bt_cb_paths_get, fs)
    fbox.pack_end(bt)
    bt.show()

    # Mode frame
    fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
    rd.callback_changed_add(rd_cb_mode, fs)
    fbox.pack_end(rd)
    rd.show()

    rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
    rd.callback_changed_add(rd_cb_mode, fs)
    rd.group_add(rdg)
    fbox.pack_end(rd)
    rd.show()

    # Thumbsize frame
    fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    sl = Slider(win,
                min_max=(4, 130),
                unit_format="%.0f px",
                value=fs.thumbnail_size[0])
    sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
    fr.content = sl
    sl.show()

    # Sort method frame
    fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    hs = Hoversel(win, text="File name (asc)")
    sorts = (
        ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
        ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
        ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
        ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
        ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
        ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
        ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
        ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
    )
    for sort in sorts:
        hs.item_add(label=sort[0],
                    callback=hs_cb_sort_method,
                    fs=fs,
                    method=sort[1])
    fr.content = hs
    hs.show()

    win.show()
def map_clicked(obj):
    win = StandardWindow("map", "Map test", autodel=True, size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    vbox = Box(win)
    vbox.size_hint_weight = EXPAND_BOTH
    vbox.size_hint_align = FILL_BOTH
    win.resize_object_add(vbox)
    vbox.show()

    map_obj = Map(win, zoom=2)
    map_obj.size_hint_weight = EXPAND_BOTH
    map_obj.size_hint_align = FILL_BOTH
    map_obj.callback_tile_load_add(cb_map_load)
    map_obj.callback_tile_loaded_add(cb_map_load)
    map_obj.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, cb_map_mouse_down)
    vbox.pack_end(map_obj)
    map_obj.show()

    ###
    lb = Label(win, text="load_status: 0 / 0")
    vbox.pack_end(lb)
    lb.show()
    map_obj.data["lb_load_status"] = lb

    ###
    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    bt = Button(win, text="Goto")
    bt.callback_clicked_add(cb_btn_goto, map_obj)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Zoom +")
    bt.callback_clicked_add(cb_btn_zoom, map_obj, 1)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Zoom -")
    bt.callback_clicked_add(cb_btn_zoom, map_obj, -1)
    hbox.pack_end(bt)
    bt.show()

    sl = Slider(win, text="Rotation:", min_max=(0, 360), value=0,
        indicator_format="%3.0f")
    sl.callback_changed_add(cb_slider_rot, map_obj)
    hbox.pack_end(sl)
    sl.show()

    src_type = ELM_MAP_SOURCE_TYPE_TILE
    ho = Hoversel(win, hover_parent=win,
                  text="Tiles: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Tiles")
    hbox.pack_end(ho)
    ho.show()

    ###
    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="wheel_disabled")
    ck.callback_changed_add(lambda bt: map_obj.wheel_disabled_set(bt.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="paused")
    ck.callback_changed_add(lambda bt: map_obj.paused_set(bt.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="hide overlays")
    ck.callback_changed_add(cb_chk_overlays_hidden, map_obj)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="pause overlays")
    ck.callback_changed_add(cb_chk_overlays_paused, map_obj)
    hbox.pack_end(ck)
    ck.show()

    ###
    sp = Separator(win, horizontal=True)
    sp.show()
    vbox.pack_end(sp)

    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    src_type = ELM_MAP_SOURCE_TYPE_ROUTE
    ho = Hoversel(win, hover_parent=win,
                  text="Routes: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Routes")
    hbox.pack_end(ho)
    ho.show()

    lb = Label(win, text="Set Start and End point to calculate route")
    hbox.pack_end(lb)
    lb.show()
    map_obj.data["lb_distance"] = lb

    bt = Button(win, text="Calc route")
    bt.callback_clicked_add(cb_btn_calc_route, map_obj)
    hbox.pack_end(bt)
    bt.show()

    ###
    sp = Separator(win, horizontal=True)
    sp.show()
    vbox.pack_end(sp)

    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()
    
    src_type = ELM_MAP_SOURCE_TYPE_NAME
    ho = Hoversel(win, hover_parent=win,
                  text="Names: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Names")
    hbox.pack_end(ho)
    ho.show()

    en = Entry(win, scrollable=True, text="type an address here")
    en.size_hint_weight = EXPAND_BOTH
    en.size_hint_align = FILL_BOTH
    en.single_line = True
    hbox.pack_end(en)
    en.show()

    bt = Button(win, text="Search address")
    bt.callback_clicked_add(cb_btn_search_name, map_obj, en)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Search start point")
    bt.callback_clicked_add(cb_btn_search_region, map_obj, en)
    hbox.pack_end(bt)
    bt.show()


    print_map_info(map_obj)
    win.show()
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set("Settings",
            "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set("Settings",
            "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
    def __init__(self, parent, h):
        if not h.is_valid():
            Information(parent.win, "Invalid torrent handle.")
            return

        if not h.has_metadata():
            Information(parent.win, "Torrent contains no metadata.")
            return

        i = h.get_torrent_info()

        InnerWindow.__init__(self, parent.win)

        box = Box(self)
        box.size_hint_align = -1.0, -1.0
        box.size_hint_weight = 1.0, 1.0

        tname = Label(self)
        tname.size_hint_align = -1.0, 0.5
        tname.line_wrap = ELM_WRAP_CHAR
        tname.ellipsis = True
        tname.text = "{}".format(cgi.escape(i.name()))
        tname.show()
        box.pack_end(tname)

        for func in i.comment, i.creation_date, i.creator:
            try:
                w = func()
            except Exception as e:
                log.debug(e)
            else:
                if w:
                    f = Frame(self)
                    f.size_hint_align = -1.0, 0.0
                    f.text = func.__name__.replace("_", " ").capitalize()
                    l = Label(self)
                    l.ellipsis = True
                    l.text = cgi.escape(str(w))
                    l.show()
                    f.content = l
                    f.show()
                    box.pack_end(f)

        tpriv = Check(self)
        tpriv.size_hint_align = 0.0, 0.0
        tpriv.text = "Private"
        tpriv.tooltip_text_set("Whether this torrent is private.<br> \
            i.e., it should not be distributed on the trackerless network<br> \
            (the kademlia DHT).")
        tpriv.disabled = True
        tpriv.state = i.priv()

        magnet_uri = lt.make_magnet_uri(h)

        f = Frame(self)
        f.size_hint_align = -1.0, 0.0
        f.text = "Magnet URI"
        me_box = Box(self)
        me_box.horizontal = True
        me = Entry(self)
        me.size_hint_align = -1.0, 0.0
        me.size_hint_weight = 1.0, 0.0
        #me.editable = False
        me.entry = magnet_uri
        me_box.pack_end(me)
        me.show()
        me_btn = Button(self)
        me_btn.text = "Copy"
        if hasattr(me, "cnp_selection_set"):
            me_btn.callback_clicked_add(
                lambda x: me.top_widget.cnp_selection_set(
                    ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text))
        else:
            import pyperclip
            me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri))
        me_btn.show()
        me_box.pack_end(me_btn)
        me_box.show()
        f.content = me_box
        f.show()
        box.pack_end(f)

        fl_btn = Button(self)
        fl_btn.text = "Files ->"
        fl_btn.callback_clicked_add(self.file_list_cb, h)

        xbtn = Button(self)
        xbtn.text_set("Close")
        xbtn.callback_clicked_add(lambda x: self.delete())

        for w in tpriv, fl_btn, xbtn:
            w.show()
            box.pack_end(w)

        box.show()

        nf = self.nf = Naviframe(self)
        nf.item_simple_push(box)

        self.content_set(nf)
        self.activate()
def icon_clicked(obj, item=None):
    win = StandardWindow("icon test", "Icon Test", autodel=True,
        size=(400, 400))
    win.show()

    box = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box)
    box.show()

    ic = Icon(box, file=os.path.join(img_path, "logo.png"),
        resizable=(True, True), size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    box.pack_end(ic)
    ic.show()

    hbox = Box(box, horizontal=True, size_hint_weight=EXPAND_HORIZ)
    box.pack_end(hbox)
    hbox.show()

    # Test Aspect Fixed
    tg = Check(hbox, text="Aspect Fixed", state=True)
    tg.callback_changed_add(aspect_fixed_cb, ic)
    hbox.pack_end(tg)
    tg.show()

    # Test Fill Outside
    tg = Check(hbox, text="Fill Outside")
    tg.callback_changed_add(fill_outside_cb, ic)
    hbox.pack_end(tg)
    tg.show()

    # Test Smooth
    tg = Check(hbox, text="Smooth", state=True)
    tg.callback_changed_add(smooth_cb, ic)
    hbox.pack_end(tg)
    tg.show()

    # Test Preload, Prescale
    bt = Button(hbox, text="Preload & Prescale")
    bt.callback_clicked_add(bt_clicked)
    hbox.pack_end(bt)
    bt.show()