added clear all/ended buttons

This commit is contained in:
Lynne Megido 2020-08-23 19:53:47 +10:00
parent d50cd17f9d
commit f0cfa46f28
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 26 additions and 5 deletions

View file

@ -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,

View file

@ -126,13 +126,14 @@
</packing>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkToolButton" id="btnClearEnded">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Clear ended</property>
<property name="label" translatable="yes">Clear ended</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-clear</property>
<signal name="clicked" handler="btnClearEndedClicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -140,13 +141,14 @@
</packing>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkToolButton" id="btnClearAll">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Clear all</property>
<property name="label" translatable="yes">Clear all</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-delete</property>
<signal name="clicked" handler="btnClearAllClicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>