Reset detail pane when new search is started
This commit is contained in:
@@ -60,6 +60,12 @@ class DetailBar(Gtk.ScrolledWindow):
|
|||||||
pixbuf = util.load_card_image(card, 63 * 5, 88 * 5)
|
pixbuf = util.load_card_image(card, 63 * 5, 88 * 5)
|
||||||
self.bigcard.set_from_pixbuf(pixbuf)
|
self.bigcard.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
pixbuf = util.load_dummy_image(63 * 5, 88 * 5)
|
||||||
|
self.bigcard.set_from_pixbuf(pixbuf)
|
||||||
|
self.rulingslabel.set_visible(False)
|
||||||
|
self.rulesstore.clear()
|
||||||
|
|
||||||
def set_card_detail(self, card):
|
def set_card_detail(self, card):
|
||||||
print("Loading infos for \"" + card.name + "\"")
|
print("Loading infos for \"" + card.name + "\"")
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,8 @@ class SearchView(Gtk.Grid):
|
|||||||
def online_search_clicked(self, button):
|
def online_search_clicked(self, button):
|
||||||
# Clear old data from liststore
|
# Clear old data from liststore
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
|
# Reset details pane
|
||||||
|
self.details.reset()
|
||||||
# Define the function to load cards in a seperate thread, so the UI is not blocked
|
# Define the function to load cards in a seperate thread, so the UI is not blocked
|
||||||
self.loadthread = threading.Thread(target=self.load_cards)
|
self.loadthread = threading.Thread(target=self.load_cards)
|
||||||
# Deamonize Thread so it tops if the main thread exits
|
# Deamonize Thread so it tops if the main thread exits
|
||||||
@@ -167,11 +169,12 @@ class SearchView(Gtk.Grid):
|
|||||||
def load_cards(self):
|
def load_cards(self):
|
||||||
# Get search term
|
# Get search term
|
||||||
term = self.searchEntry.get_text()
|
term = self.searchEntry.get_text()
|
||||||
|
|
||||||
# Lock down search controls
|
# Lock down search controls
|
||||||
GObject.idle_add(self.do_activate_controls, False, priorty=GObject.PRIORITY_DEFAULT)
|
GObject.idle_add(self.do_activate_controls, False, priorty=GObject.PRIORITY_DEFAULT)
|
||||||
|
|
||||||
# Get filter rules
|
# Get filter rules
|
||||||
colorlist = self.get_color_filter()
|
colorlist = self.get_color_filter()
|
||||||
|
|
||||||
tree_iter = self.rarity_combobox.get_active_iter()
|
tree_iter = self.rarity_combobox.get_active_iter()
|
||||||
rarityfilter = self.rarity_store.get_value(tree_iter, 0)
|
rarityfilter = self.rarity_store.get_value(tree_iter, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ imagecache = []
|
|||||||
manaicons ={}
|
manaicons ={}
|
||||||
window = None
|
window = None
|
||||||
|
|
||||||
|
|
||||||
def show_message(title, message):
|
def show_message(title, message):
|
||||||
dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.INFO,
|
dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.INFO,
|
||||||
Gtk.ButtonsType.OK, title)
|
Gtk.ButtonsType.OK, title)
|
||||||
@@ -19,6 +20,7 @@ def show_message(title, message):
|
|||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
|
|
||||||
def load_mana_icons():
|
def load_mana_icons():
|
||||||
path = os.path.dirname(__file__) + "/resources/mana_icons/"
|
path = os.path.dirname(__file__) + "/resources/mana_icons/"
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@@ -31,6 +33,7 @@ def load_mana_icons():
|
|||||||
img = PImage.open(path + image)
|
img = PImage.open(path + image)
|
||||||
manaicons[os.path.splitext(image)[0]] = img
|
manaicons[os.path.splitext(image)[0]] = img
|
||||||
|
|
||||||
|
|
||||||
def reload_image_cache():
|
def reload_image_cache():
|
||||||
if not os.path.exists(config.cachepath):
|
if not os.path.exists(config.cachepath):
|
||||||
os.makedirs(config.cachepath)
|
os.makedirs(config.cachepath)
|
||||||
@@ -49,11 +52,12 @@ def reload_image_cache():
|
|||||||
def load_dummy_image(sizex, sizey):
|
def load_dummy_image(sizex, sizey):
|
||||||
return GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.dirname(__file__) +
|
return GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.dirname(__file__) +
|
||||||
'/resources/images/dummy.jpg', sizex, sizey)
|
'/resources/images/dummy.jpg', sizex, sizey)
|
||||||
|
|
||||||
def load_card_image_online(card, sizex, sizey):
|
def load_card_image_online(card, sizex, sizey):
|
||||||
url = card.image_url
|
url = card.image_url
|
||||||
if url is None:
|
if url is None:
|
||||||
print("No Image URL provided")
|
print("No Image URL provided")
|
||||||
return load_dummy_image()
|
return load_dummy_image(sizex, sizey)
|
||||||
filename = config.cachepath + card.multiverse_id.__str__() + ".PNG"
|
filename = config.cachepath + card.multiverse_id.__str__() + ".PNG"
|
||||||
print("Loading image from: " + url)
|
print("Loading image from: " + url)
|
||||||
response = request.urlretrieve(url, filename)
|
response = request.urlretrieve(url, filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user