~sircmpwn/hiprompt-gtk-py

f8659e52886c1b329730d3b446d59a41ba5f2ca9 — Martijn Braam 2 years ago dd5ed36
Add timeout for enabling the grant buttons
1 files changed, 13 insertions(+), 3 deletions(-)

M hiprompt_gtk/window.py
M hiprompt_gtk/window.py => hiprompt_gtk/window.py +13 -3
@@ 1,5 1,5 @@
import gi
from gi.repository import Gtk, Gio, Gdk
from gi.repository import Gtk, Gio, Gdk, GLib

from hiprompt_gtk.proto import PromptMode



@@ 24,16 24,18 @@ class Window:
        self.window.add(self.box)

        self.entry = None
        self.buttons = []

        self.make_ui()
        GLib.timeout_add(700, self.enable_actions)

    def make_ui(self):
        if self.session.mode == PromptMode.disclose:
            self.make_disclose_ui()
        elif self.session.mode == PromptMode.delete:
            self.make_delete_ui()
        elif self.session.mode == None:
            assert(self.session.unlock)
        elif self.session.mode is None:
            assert self.session.unlock
        else:
            raise ValueError("Unexpected mode")



@@ 43,6 45,10 @@ class Window:
        self.header.show_all()
        self.box.show_all()

    def enable_actions(self, *args):
        for button in self.buttons:
            button.set_sensitive(True)

    def on_close(self, *args):
        Gtk.main_quit()



@@ 142,6 148,8 @@ class Window:

        grant = Gtk.Button("Grant access")
        grant.get_style_context().add_class("destructive-action")
        grant.set_sensitive(False)
        self.buttons.append(grant)
        grant.connect("clicked", self.on_disclose_grant)
        self.header.pack_end(grant)



@@ 177,6 185,8 @@ class Window:
        grant = Gtk.Button("Confirm deletion")
        grant.get_style_context().add_class("destructive-action")
        grant.connect("clicked", self.on_disclose_grant)
        self.buttons.append(grant)
        grant.set_sensitive(False)
        self.header.pack_end(grant)

        scroller = Gtk.ScrolledWindow()