From 3d5802bfc567e7a0daf738cb31b73565bf17f61b Mon Sep 17 00:00:00 2001 From: luxick Date: Mon, 20 Feb 2017 20:52:43 +0100 Subject: [PATCH] Reset detail pane when new search is started --- mtg-collector/details.py | 6 ++++++ mtg-collector/search.py | 5 ++++- mtg-collector/util.py | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mtg-collector/details.py b/mtg-collector/details.py index 1f4a38a..3dec5e5 100644 --- a/mtg-collector/details.py +++ b/mtg-collector/details.py @@ -60,6 +60,12 @@ class DetailBar(Gtk.ScrolledWindow): pixbuf = util.load_card_image(card, 63 * 5, 88 * 5) 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): print("Loading infos for \"" + card.name + "\"") diff --git a/mtg-collector/search.py b/mtg-collector/search.py index 538e8bb..c4f33d6 100644 --- a/mtg-collector/search.py +++ b/mtg-collector/search.py @@ -157,6 +157,8 @@ class SearchView(Gtk.Grid): def online_search_clicked(self, button): # Clear old data from liststore 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 self.loadthread = threading.Thread(target=self.load_cards) # Deamonize Thread so it tops if the main thread exits @@ -167,11 +169,12 @@ class SearchView(Gtk.Grid): def load_cards(self): # Get search term term = self.searchEntry.get_text() + # Lock down search controls GObject.idle_add(self.do_activate_controls, False, priorty=GObject.PRIORITY_DEFAULT) + # Get filter rules colorlist = self.get_color_filter() - tree_iter = self.rarity_combobox.get_active_iter() rarityfilter = self.rarity_store.get_value(tree_iter, 0) diff --git a/mtg-collector/util.py b/mtg-collector/util.py index fd2e8f1..ff0582c 100644 --- a/mtg-collector/util.py +++ b/mtg-collector/util.py @@ -12,6 +12,7 @@ imagecache = [] manaicons ={} window = None + def show_message(title, message): dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, title) @@ -19,6 +20,7 @@ def show_message(title, message): dialog.run() dialog.destroy() + def load_mana_icons(): path = os.path.dirname(__file__) + "/resources/mana_icons/" if not os.path.exists(path): @@ -31,6 +33,7 @@ def load_mana_icons(): img = PImage.open(path + image) manaicons[os.path.splitext(image)[0]] = img + def reload_image_cache(): if not os.path.exists(config.cachepath): os.makedirs(config.cachepath) @@ -49,11 +52,12 @@ def reload_image_cache(): def load_dummy_image(sizex, sizey): return GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.dirname(__file__) + '/resources/images/dummy.jpg', sizex, sizey) + def load_card_image_online(card, sizex, sizey): url = card.image_url if url is None: print("No Image URL provided") - return load_dummy_image() + return load_dummy_image(sizex, sizey) filename = config.cachepath + card.multiverse_id.__str__() + ".PNG" print("Loading image from: " + url) response = request.urlretrieve(url, filename)