Provide a reset button where, if there was text to start out with, in case it was accidentally overwritten
This commit is contained in:
parent
67ff99afe1
commit
d4edd49862
1 changed files with 11 additions and 2 deletions
|
@ -10,6 +10,7 @@ class PromptWindow(Gtk.Window):
|
||||||
|
|
||||||
if task is None:
|
if task is None:
|
||||||
task = ""
|
task = ""
|
||||||
|
self.orig_task = task
|
||||||
|
|
||||||
Gtk.Window.__init__(self, title="Pomodoro Prompt")
|
Gtk.Window.__init__(self, title="Pomodoro Prompt")
|
||||||
self.set_size_request(500, 100)
|
self.set_size_request(500, 100)
|
||||||
|
@ -22,7 +23,7 @@ class PromptWindow(Gtk.Window):
|
||||||
self.add(vbox)
|
self.add(vbox)
|
||||||
|
|
||||||
self.entry = Gtk.Entry()
|
self.entry = Gtk.Entry()
|
||||||
self.entry.set_text(task)
|
self.entry.set_text(self.orig_task)
|
||||||
self.entry.connect("activate", self.save)
|
self.entry.connect("activate", self.save)
|
||||||
|
|
||||||
vbox.pack_start(self.entry, True, True, 0)
|
vbox.pack_start(self.entry, True, True, 0)
|
||||||
|
@ -33,6 +34,11 @@ class PromptWindow(Gtk.Window):
|
||||||
self.button_ok.connect("clicked", self.save)
|
self.button_ok.connect("clicked", self.save)
|
||||||
hbox.pack_start(self.button_ok, True, True, 0)
|
hbox.pack_start(self.button_ok, True, True, 0)
|
||||||
|
|
||||||
|
if task:
|
||||||
|
self.button_reset = Gtk.Button.new_with_label("Reset")
|
||||||
|
self.button_reset.connect("clicked", self.reset)
|
||||||
|
hbox.pack_start(self.button_reset, True, True, 0)
|
||||||
|
|
||||||
vbox.pack_start(hbox, True, True, 0)
|
vbox.pack_start(hbox, True, True, 0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,11 +51,14 @@ class PromptWindow(Gtk.Window):
|
||||||
# A little concerned this might be sort of the nuclear option here.
|
# A little concerned this might be sort of the nuclear option here.
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def reset(self, item):
|
||||||
|
self.entry.set_text(self.orig_task)
|
||||||
|
|
||||||
def retrieve(self):
|
def retrieve(self):
|
||||||
return self.task
|
return self.task
|
||||||
|
|
||||||
|
|
||||||
win = PromptWindow(task="Making money")
|
win = PromptWindow()
|
||||||
win.show_all()
|
win.show_all()
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
tha_task = win.retrieve()
|
tha_task = win.retrieve()
|
||||||
|
|
Loading…
Reference in a new issue