Exemplo n.º 1
0
 def __init__(self, rent):
     Box.__init__(self, rent)
     self.parent = rent
     
     #This appears on the button in the main swmai window
     self.name = "Light DM"
     #The section in the main window the button is added to
     self.section = "System Settings"
     #Search terms that this module should appear for
     self.searchData = ["lightdm", "autologin", "login", "display"]
     #Command line argument to open this module directly
     self.launchArg = "--lightdm"
     #Should be none by default. This value is used internally by swami
     self.button = None
     
     self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
     self.icon.standard_set('video-display')
     self.icon.show()
     
     self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     self.mainBox.show()
     
     self.config = {}
     
     with open(LightDMConf) as f:
         for line in f:
             #Sections start with [ - such as [SeatDefaults]
             if line[0] != "[":
                 setting, value = line.replace("\n", "").split("=")
                 
                 e = Entry(self)
                 e.single_line_set(True)
                 e.text = value
                 e.show()
                 
                 f = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
                 f.text = setting
                 f.content = e
                 f.show()
                 
                 self.mainBox.pack_end(f)
                 
                 self.config[setting] = f
     
     buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
     buttonBox.horizontal = True
     
     buttonSave = StandardButton(self, "Save Changes", "ok", self.savePressed)
     buttonSave.show()
     
     buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
     buttonReturn.show()
     
     buttonBox.pack_end(buttonSave)
     buttonBox.pack_end(buttonReturn)
     buttonBox.show()
     
     self.pack_end(self.mainBox)
     self.pack_end(buttonBox)
def gesture_layer_clicked(obj):
    w = 480
    h = 800

    win = Window("gesture-layer", ELM_WIN_BASIC, title="Gesture Layer",
        autodel=True, size=(w, h))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    photos = []

    photos.append(photo_object_add(win, None,
        os.path.join(img_path, "pol_sky.png"), 200, 200, 365, 400, 0))
    photos.append(photo_object_add(win, None,
        os.path.join(img_path, "pol_twofish.png"), 40, 300, 365, 400, 45))

    en = Entry(win, line_wrap=ELM_WRAP_MIXED)
    en.text = "You can use whatever object you want, even entries like this."

    postit = Layout(win,
        file=(os.path.join(script_path, "postit_ent.edj"), "main"))
    postit.part_content_set("ent", en)

    photos.append(photo_object_add(win, postit, None, 50, 50, 382, 400, 355))

    win.show()
def entry_anchor_clicked(obj, item=None):
    win = StandardWindow("entry",
                         "Entry Anchor",
                         autodel=True,
                         size=(400, 400))

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

    entry = Entry(win, anchor_hover_style="popout", anchor_hover_parent=win)
    entry.text = "<a href=url:http://www.enlightenment.org/>Enlightenment</a>"
    entry.callback_anchor_clicked_add(anchor_clicked)
    entry.callback_anchor_hover_opened_add(anchor_hover_opened)
    entry.show()

    frame = Frame(win,
                  size_hint_align=FILL_BOTH,
                  text="Entry test",
                  content=entry)
    frame.show()

    box.pack_end(frame)
    box.show()

    win.show()
Exemplo n.º 4
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 entry_anchor_clicked(obj, item=None):
    win = StandardWindow("entry", "Entry Anchor", autodel=True, size=(400,400))

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

    entry = Entry(win, anchor_hover_style="popout", anchor_hover_parent=win)
    entry.text = "<a href=url:http://www.enlightenment.org/>Enlightenment</a>"
    entry.callback_anchor_clicked_add(anchor_clicked)
    entry.callback_anchor_hover_opened_add(anchor_hover_opened)
    entry.show()

    frame = Frame(win, size_hint_align=FILL_BOTH, text="Entry test",
        content=entry)
    frame.show()

    box.pack_end(frame)
    box.show()

    win.show()
def elm_input_events_clicked(obj, item=None):
    win = StandardWindow("inputevents", "Input Events Test", autodel=True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    entry = Entry(win, scrollable=True, size_hint_align=FILL_BOTH,
        size_hint_weight=(1.0, 0.2))
    entry.text = (
        "This example will show how Elementary input events are handled. "
        "Typing in this entry will log in the entry box below all events "
        "caught by event handlers set to this Entry widget and its parent, "
        "the Window widget. Key up events are checked for in the callback "
        "and won't propagate to a parent widget."
        )
    entry.show()

    log_entry = Entry(win, editable=False, scrollable=True, focus_allow=False,
        size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.8))
    log_entry.callback_changed_add(changed_cb)
    log_entry.show()

    btn = Button(win, text="Clear log", focus_allow=False)
    btn.callback_clicked_add(lambda x: setattr(log_entry, "entry", ""))
    btn.show()

    box.pack_end(entry)
    box.pack_end(log_entry)
    box.pack_end(btn)

    entry.elm_event_callback_add(events_cb, log_entry)
    entry.markup_filter_append(filter_cb)
    win.elm_event_callback_add(events_cb, log_entry)

    win.resize(640, 480)
    win.show()

    entry.focus = True
Exemplo n.º 7
0
def gesture_layer_clicked(obj):
    w = 480
    h = 800

    win = Window("gesture-layer",
                 ELM_WIN_BASIC,
                 title="Gesture Layer",
                 autodel=True,
                 size=(w, h))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    photos = []

    photos.append(
        photo_object_add(win, None, os.path.join(img_path, "pol_sky.png"), 200,
                         200, 365, 400, 0))
    photos.append(
        photo_object_add(win, None, os.path.join(img_path, "pol_twofish.png"),
                         40, 300, 365, 400, 45))

    en = Entry(win, line_wrap=ELM_WRAP_MIXED)
    en.text = "You can use whatever object you want, even entries like this."

    postit = Layout(win,
                    file=(os.path.join(script_path, "postit_ent.edj"), "main"))
    postit.part_content_set("ent", en)

    photos.append(photo_object_add(win, postit, None, 50, 50, 382, 400, 355))

    win.show()
Exemplo n.º 8
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)
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent

        #This appears on the button in the main swmai window
        self.name = "Light DM"
        #The section in the main window the button is added to
        self.section = "System Settings"
        #Search terms that this module should appear for
        self.searchData = ["lightdm", "autologin", "login", "display"]
        #Command line argument to open this module directly
        self.launchArg = "--lightdm"
        #Should be none by default. This value is used internally by swami
        self.button = None

        self.icon = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('video-display')
        self.icon.show()

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

        self.config = {"sections": []}

        with open(LightDMConf) as f:
            currentSection = None
            for line in f:
                #Sections start with [ - such as [SeatDefaults]
                if line[0] == "[":
                    self.config["sections"].append(line)
                    currentSection = line.rstrip()
                    s = Frame(self,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
                    s.text = currentSection[1:-1]
                    s.show()

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

                    s.content = sectionBox

                    self.mainBox.pack_end(s)
                elif line[0] not in ["[", "\n"]:
                    setting, value = line.replace("\n", "").split("=")

                    e = Entry(self)
                    e.single_line_set(True)
                    e.text = value
                    e.show()

                    f = Frame(self,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
                    f.text = setting
                    f.content = e
                    f.show()

                    sectionBox.pack_end(f)

                    self.config[setting] = [f, currentSection]

        buttonBox = Box(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
        buttonBox.horizontal = True

        buttonSave = StandardButton(self, "Save Changes", "ok",
                                    self.savePressed)
        buttonSave.show()

        buttonReturn = StandardButton(self, "Back", "go-previous",
                                      self.returnPressed)
        buttonReturn.show()

        buttonBox.pack_end(buttonSave)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()

        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)