diff --git a/buypeeb.py b/buypeeb.py
index b7ed09c..308bdbe 100755
--- a/buypeeb.py
+++ b/buypeeb.py
@@ -37,6 +37,9 @@ else:
settingsLocation = path.expanduser("~/.config/Lynnear Software/buypeeb/") # dotfiles in ~ need to die. begone dot
class BuypeebApp:
+
+ # SETUP
+
def __init__(self):
self.app = Gtk.Application.new('com.lynnearsoftware.buypeeb', 0)
self.app.connect('startup', self.startup)
@@ -71,12 +74,14 @@ class BuypeebApp:
self.settings.save()
self.app.quit()
- def msgBox(self, title, text, form = Gtk.MessageType.WARNING):
+ # CONVENIENCE FUNCTIONS
+
+ def msgBox(self, title, text, form = Gtk.MessageType.WARNING, buttons = Gtk.ButtonsType.OK):
msgbox = Gtk.MessageDialog(
parent = self.window,
flags = 0,
message_type = form,
- buttons = Gtk.ButtonsType.OK,
+ buttons = buttons,
text = title
)
@@ -122,9 +127,10 @@ class BuypeebApp:
self.items.clear()
print(self.settings.watchlist)
for id, item in self.settings.watchlist.items():
- print("heeh hoo")
self.items.append([item.name, item.price_aud(self.rate), "heenlo", id])
+ # BUTTON CLICKS
+
def btnAddClicked(self, widget):
url = self.entryBox("Add URL", "Enter the URL of the item you want to add.")
if url:
@@ -136,6 +142,19 @@ class BuypeebApp:
self.renderList()
+ def btnClearEndedClicked(self, widget):
+ if self.msgBox("Clear ended?", "Are you sure you want to clear all ended items from the watchlist?", buttons = Gtk.ButtonsType.OK_CANCEL):
+ for id, item in self.settings.watchlist.items():
+ if not item.available:
+ del self.settings.watchlist[key]
+
+ self.renderList()
+
+ def btnClearAllClicked(self, widget):
+ if self.msgBox("Clear all?", "Are you sure you want to clear all watched items?", buttons = Gtk.ButtonsType.OK_CANCEL):
+ self.settings.watchlist = {}
+ self.items.clear()
+
def btnQuitClicked(self, widget):
prompt = Gtk.MessageDialog(
parent = self.window,
diff --git a/ui/main.glade b/ui/main.glade
index 73a2d7a..35b9df0 100644
--- a/ui/main.glade
+++ b/ui/main.glade
@@ -126,13 +126,14 @@
-
-
+
True
False
Clear all
Clear all
True
gtk-delete
+
False