~sircmpwn/hiprompt-gtk-py

ce90e08f0990aa027350007ab8cc024742a7e3f9 — Martijn Braam 2 years ago 4cdf013
Implement the disclose operation
1 files changed, 45 insertions(+), 2 deletions(-)

M hiprompt_gtk/window.py
M hiprompt_gtk/window.py => hiprompt_gtk/window.py +45 -2
@@ 28,7 28,7 @@ class Window:
        if self.session.mode == PromptMode.unlock:
            self.make_unlock_ui()
        elif self.session.mode == PromptMode.disclose:
            pass
            self.make_disclose_ui()
        else:
            raise ValueError("Unexpected mode")



@@ 49,6 49,10 @@ class Window:
            self.entry.set_text("")
            self.entry.set_sensitive(True)

    def on_disclose_grant(self, *args):
        self.session.status = 0
        Gtk.main_quit()

    def make_unlock_ui(self):
        for child in self.box:
            self.box.remove(child)


@@ 57,7 61,10 @@ class Window:

        self.header.set_title("Unlock keyring")

        deny = Gtk.Button("Deny access")
        if len(self.session.keys) == 0:
            deny = Gtk.Button("Cancel")
        else:
            deny = Gtk.Button("Deny access")
        deny.connect("clicked", self.on_deny)
        self.header.pack_start(deny)



@@ 108,6 115,42 @@ class Window:

        self.window.show_all()

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

        self.header.set_title("Review secret access request")

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

        grant = Gtk.Button("Grant access")
        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 permission "
                          "to view your private account information.\n"
                          "If you consent, the application will have access to "
                          "the following information:")
        box.add(label)
        box.add(self.make_key_box())

        self.window.show_all()

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