~sircmpwn/hiprompt-gtk-py

52ac6fc2ac585cd3df38ee4827266e1520f1209d — Alexey Yerin 2 years ago d4e3855
Implement 'delete' prompt mode
2 files changed, 35 insertions(+), 0 deletions(-)

M hiprompt_gtk/proto.py
M hiprompt_gtk/window.py
M hiprompt_gtk/proto.py => hiprompt_gtk/proto.py +1 -0
@@ 5,6 5,7 @@ from .key import Key

class PromptMode(Enum):
    disclose = "disclose"
    delete = "delete"


class Session:

M hiprompt_gtk/window.py => hiprompt_gtk/window.py +34 -0
@@ 27,6 27,8 @@ class Window:

        if self.session.mode == PromptMode.disclose:
            self.make_disclose_ui()
        elif self.session.mode == PromptMode.delete:
            self.make_delete_ui()
        else:
            raise ValueError("Unexpected mode")



@@ 150,6 152,38 @@ class Window:
        box.add(label)
        box.add(self.make_key_box())

    def make_delete_ui(self):
        for child in self.box:
            self.box.remove(child)
        for child in self.header:
            self.header.remove(child)

        self.header.set_title("Delete key request")

        deny = Gtk.Button("Cancel")
        deny.connect("clicked", self.on_deny)
        self.header.pack_start(deny)

        grant = Gtk.Button("Confirm deletion")
        grant.get_style_context().add_class("destructive-action")
        grant.connect("clicked", self.on_disclose_grant)
        self.header.pack_end(grant)

        scroller = Gtk.ScrolledWindow()
        scroller.set_propagate_natural_height(True)
        scroller.set_propagate_natural_width(True)
        scroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
        self.box.add(scroller)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
        box.get_style_context().add_class("mainbox")
        scroller.add(box)

        label = Gtk.Label("An application has requested to remove "
                          "the following keys from your store:")
        box.add(label)
        box.add(self.make_key_box())

    def make_key_box(self):
        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)