Пример #1
0
    def run(self, setting, parent, layout):
        self.edje_file = join(dirname(__file__), 'settings.edj')

        layout.elm_obj.hide()
        self.window = ElementaryListSubwindow(parent, self.edje_file,
                                              "stringsetting", "entry",
                                              layout.elm_obj)
        self.edje_obj = self.window.main_layout

        if setting != None:
            self.edje_obj.edje.signal_emit(str(setting.name), "set_text")

        textbox = Entry(parent.window.elm_obj)

        if setting != None:
            textbox.entry_set(setting.value)

        textbox.size_hint_weight_set(1.0, 1.0)

        self.edje_obj.elm_obj.content_set("entry", textbox)

        textbox.editable_set(True)

        textbox.focus()

        textbox.show()

        i, args = yield WaitFirst(Wait(self.edje_obj, 'save'),
                                  Wait(self.edje_obj, 'back'),
                                  Wait(parent, 'back'))

        if i == 0:  ##save clicked
            text = str(textbox.entry_get()).replace("<br>", "")
            text = text.strip()
            if setting != None:
                self.edje_obj.edje.signal_emit("save-notice", "*")
                self.edje_obj.elm_obj.visible_set(False)
                self.edje_obj.delete()
                layout.elm_obj.show()
                setting.set(text).start()
                parent.window.elm_obj.keyboard_mode_set(
                    gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
            else:
                self.edje_obj.elm_obj.visible_set(False)
                #if setting != None:
                self.edje_obj.delete()
                layout.elm_obj.show()
                parent.window.elm_obj.keyboard_mode_set(
                    gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                yield text
        else:
            self.edje_obj.elm_obj.visible_set(False)
            self.edje_obj.delete()
            layout.elm_obj.show()

        parent.window.elm_obj.keyboard_mode_set(
            gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
Пример #2
0
    def msg_details(self, emission, signal, source, item):
        number = item[0].peer.get_text()
        text = item[0].text
        timestamp = item[0].timestamp.local_repr()

        detail_layout = ElementaryLayout(self.window.window, self.edje_file,
                                         "message_details")
        edje_obj = detail_layout.elm_obj.edje_get()
        edje_obj.part_text_set('name-text', unicode(number).encode('utf8'))
        edje_obj.part_text_set('name-info', unicode(timestamp).encode('utf8'))
        detail_layout.elm_obj.show()

        textbox = Entry(self.window.window.elm_obj)
        textbox.entry_set(unicode(text.value).replace('&', '&amp;'))

        textbox.size_hint_weight_set(1.0, 1.0)
        textbox.scale_set(1.5)
        textbox.editable_set(False)
        textbox.line_wrap_set(True)
        textbox.show()

        sc = Scroller(self.window.window.elm_obj)
        sc.content_set(textbox)

        detail_layout.elm_obj.content_set('message', sc)
        sc.show()

        self.window.main_layout.elm_obj.hide()
        self.window.bg.elm_obj.content_set("content-swallow",
                                           detail_layout.elm_obj)

        ##add callback for delete button
        edje_obj.signal_callback_add("delete_message", "*", self.delete_msg,
                                     item[0], detail_layout)

        ##add callback for messaging buttons
        edje_obj.signal_callback_add("*", "messaging", self.adv_msg, item,
                                     detail_layout)

        ##add callbacks for back button
        edje_obj.signal_callback_add("close_details", "*",
                                     detail_layout.delete)
        edje_obj.signal_callback_add("close_details", "*",
                                     self.window.restore_orig)

        if item[0].direction == 'in' and item[0].status == 'unread':
            item[0].read()
            self.item_list._redraw_view()
Пример #3
0
def boot_cmd(win=False):
    with open("/proc/cmdline") as file1:
        bootcmd = file1.readline()[:-1]
    if win:
        from elementary import Popup, Entry, Button, Icon
        en = Entry(win)
        en.entry_set(bootcmd)
        bt = Button(win)
        bt.text = "Close"
        bt.callback_clicked_add(lambda o: popup.delete())

        ic = Icon(win)
        ic.standard_set("system")

        popup = Popup(win)
        popup.size_hint_weight = (1.0, 1.0)
        popup.part_content_set("title,icon", ic)
        popup.part_text_set("title,text", "Boot Command")
        popup.part_content_set("default", en)
        popup.part_content_set("button1", bt)
        popup.show()
    else:
        return bootcmd
Пример #4
0
    def run(self, parent, sms, mode, layout=None, *args, **kargs):
        self.dialog = Service.get("Dialog")
        try:
            self.edje_file = join(dirname(__file__), 'messages.edj')
            number_layout = 0
            text_layout = 0
            send = 0
            number = ""
            full = False
            pre_text = None

            self.window = parent

            if layout != None:
                layout.elm_obj.hide()

            if mode != "reply":
                full = True
                number = ""
            else:
                sms.text = ""

            while True:

                if full:

                    parent.window.elm_obj.keyboard_mode_set(
                        ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

                    if number_layout == 0:

                        number_layout = ElementaryLayout(
                            parent.window, self.edje_file, "edit_number")

                        edje_obj = number_layout.elm_obj.edje_get()

                        edje_obj.part_text_set('num_field-text', number)

                        number_layout.elm_obj.show()

                        parent.main_layout.elm_obj.hide()

                    else:
                        logger.info("back pressed in text")
                        number_layout.elm_obj.show()
                        edje_obj = number_layout.elm_obj.edje_get()

                    edje_obj.signal_callback_add("num_field_pressed", "*",
                                                 self.num_field_action)
                    self.number_layout = number_layout
                    parent.bg.elm_obj.content_set("content-swallow",
                                                  number_layout.elm_obj)

                    number_layout.connect("too_short", self.error_win,
                                          "number too short")

                    i, args = yield WaitFirst(Wait(number_layout, 'back'),
                                              Wait(number_layout, 'next'))

                    if i == 0:  #back
                        break

                    if i == 1:  #next
                        number_layout.elm_obj.hide()
                        number = edje_obj.part_text_get('num_field-text')
                        sms.peer = number

                if sms.text == "" or mode == "forward":

                    text_layout = ElementaryLayout(parent.window,
                                                   self.edje_file,
                                                   "CreateText")

                    parent.window.elm_obj.keyboard_mode_set(
                        ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)

                    text_layout.elm_obj.layer_set(99)

                    edje_obj = text_layout.elm_obj.edje_get()

                    text_layout.elm_obj.show()

                    parent.main_layout.elm_obj.hide()

                    parent.bg.elm_obj.content_set("content-swallow",
                                                  text_layout.elm_obj)

                    textbox = Entry(parent.window.elm_obj)

                    textbox.color_set(255, 255, 255, 255)

                    if pre_text != None:
                        textbox.entry_set(unicode(pre_text).encode("utf-8"))
                    else:
                        textbox.entry_set(unicode(sms.text).encode("utf-8"))

                    self.counter(textbox, "event", text_layout)

                    textbox.size_hint_weight_set(1.0, 1.0)

                    sc = Scroller(parent.window.elm_obj)
                    sc.content_set(textbox)

                    textbox.line_wrap_set(True)
                    text_layout.elm_obj.content_set('entry', sc)
                    sc.show()

                    textbox.editable_set(True)

                    textbox.focus()
                    textbox.show()

                    textbox.on_key_down_add(self.counter, text_layout)

                    text_layout.connect("send_request", self.send_request,
                                        textbox, sms.peer)

                i, args = yield WaitFirst(Wait(text_layout, 'back'),
                                          Wait(text_layout, 'send'))
                if i == 0:  #back
                    if full:
                        text_layout.elm_obj.hide()
                        logger.info("win set False")
                        parent.window.elm_obj.keyboard_mode_set(
                            ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                        pre_text = unicode(
                            textbox.entry_get()).encode("utf-8").replace(
                                "<br>", "")
                        pre_text = pre_text.strip()
                        textbox.on_key_down_del(self.counter)
                        continue
                    else:
                        logger.debug("breaking")
                        break
                if i == 1:  #send
                    send = 1
                    logger.info("win set False")
                    parent.window.elm_obj.keyboard_mode_set(
                        ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                    break

            logger.info("broke loop")
            if send == 1:
                text = unicode(textbox.entry_get()).encode("utf-8").replace(
                    "<br>", "")
                sms.text = text.strip()
                text_layout.elm_obj.edje_get().signal_emit("save-notice", "*")
                yield self.send_sms(sms)

            if number_layout:
                number_layout.delete()

            if text_layout:
                logger.info("deleting text layout")
                text_layout.delete()
                parent.window.elm_obj.keyboard_mode_set(
                    ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

            if layout != None:
                layout.elm_obj.show()
            else:
                parent.restore_orig()

            ret = "done"

            yield ret

        except Exception, e:
            logger.exception('run')
Пример #5
0
class LogWindow(InnerWindow):
    default_width = 500
    default_height = 500
    default_group = "editje/wizard"

    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        btn = WizardAction(self._parent, "Close", self.close, "Escape", None)
        btn.show()
        actions.pack_end(btn)

        layout = Layout(self)
        self.__edje = layout.edje_get()
        theme_file = sysconfig.theme_file_get("default")
        _width = width or self.default_width
        _height = height or self.default_height
        _group = group or self.default_group
        layout.file_set(theme_file, _group)
        layout.size_hint_min_set(_width, _height)
        layout.size_hint_max_set(_width, _height)

        InnerWindow.content_set(self, layout)
        layout.show()
        layout.content_set("content", box)

        self.__sc = Entry(self)
        self.__sc.scrollable_set(True)
        self.__sc.editable_set(False)
        self.__sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                evas.EVAS_HINT_EXPAND)
        self.__sc.size_hint_align_set(evas.EVAS_HINT_FILL,
                               evas.EVAS_HINT_FILL)
        self.__sc.bounce_set(False, False)
        self.__sc.show()
        content.pack_end(self.__sc)

    def _subtitle_text_set(self, value):
        if not value:
            self.__edje.signal_emit("wizard,subtitle,hide", "")
            self.__edje.part_text_set("subtitle.text", "")
        else:
            self.__edje.signal_emit("wizard,subtitle,show", "")
            self.__edje.part_text_set("subtitle.text", value)

    subtitle_text = property(fset=_subtitle_text_set)

    def _title_text_set(self, value):
        if not value:
            self.__edje.part_text_set("title.text", "")
        else:
            self.__edje.part_text_set("title.text", value)

    title_text = property(fset=_title_text_set)

    def message_set(self, message, title="", subtitle=""):
        self.__sc.entry_set(message)
        self.title_text = title
        self.subtitle_text = subtitle

    def show(self):
        global _instance
        if _instance:
            _instance.hide()
        _instance = self

        self._parent.block(True, self)
        InnerWindow.show(self)
        self.focus_set(True)

    def hide(self):
        global _instance
        if _instance == self:
            _instance = None
        InnerWindow.hide(self)
        self._parent.block(False)

    def open(self):
        self.show()

    def close(self):
        self._parent.focus_set(True)
        self.hide()
        self.delete()
Пример #6
0
class LogWindow(InnerWindow):
    default_width = 500
    default_height = 500
    default_group = "editje/wizard"

    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        btn = WizardAction(self._parent, "Close", self.close, "Escape", None)
        btn.show()
        actions.pack_end(btn)

        layout = Layout(self)
        self.__edje = layout.edje_get()
        theme_file = sysconfig.theme_file_get("default")
        _width = width or self.default_width
        _height = height or self.default_height
        _group = group or self.default_group
        layout.file_set(theme_file, _group)
        layout.size_hint_min_set(_width, _height)
        layout.size_hint_max_set(_width, _height)

        InnerWindow.content_set(self, layout)
        layout.show()
        layout.content_set("content", box)

        self.__sc = Entry(self)
        self.__sc.scrollable_set(True)
        self.__sc.editable_set(False)
        self.__sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                       evas.EVAS_HINT_EXPAND)
        self.__sc.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        self.__sc.bounce_set(False, False)
        self.__sc.show()
        content.pack_end(self.__sc)

    def _subtitle_text_set(self, value):
        if not value:
            self.__edje.signal_emit("wizard,subtitle,hide", "")
            self.__edje.part_text_set("subtitle.text", "")
        else:
            self.__edje.signal_emit("wizard,subtitle,show", "")
            self.__edje.part_text_set("subtitle.text", value)

    subtitle_text = property(fset=_subtitle_text_set)

    def _title_text_set(self, value):
        if not value:
            self.__edje.part_text_set("title.text", "")
        else:
            self.__edje.part_text_set("title.text", value)

    title_text = property(fset=_title_text_set)

    def message_set(self, message, title="", subtitle=""):
        self.__sc.entry_set(message)
        self.title_text = title
        self.subtitle_text = subtitle

    def show(self):
        global _instance
        if _instance:
            _instance.hide()
        _instance = self

        self._parent.block(True, self)
        InnerWindow.show(self)
        self.focus_set(True)

    def hide(self):
        global _instance
        if _instance == self:
            _instance = None
        InnerWindow.hide(self)
        self._parent.block(False)

    def open(self):
        self.show()

    def close(self):
        self._parent.focus_set(True)
        self.hide()
        self.delete()