Show indicator while loading lists
This commit is contained in:
@@ -105,17 +105,20 @@ class CardList(Gtk.ScrolledWindow):
|
|||||||
self.list.append_column(col_mana)
|
self.list.append_column(col_mana)
|
||||||
self.list.append_column(col_cmc)
|
self.list.append_column(col_cmc)
|
||||||
|
|
||||||
def update(self, library, progressbar=None):
|
def update(self, library, progressbar=None, loading_indicator=None):
|
||||||
progress_step = 1 / len(library)
|
progress_step = 1 / len(library)
|
||||||
progress = 0.0
|
progress = 0.0
|
||||||
|
self.store.clear()
|
||||||
|
|
||||||
if self.filtered:
|
if self.filtered:
|
||||||
self.list.freeze_child_notify()
|
self.list.freeze_child_notify()
|
||||||
self.list.set_model(None)
|
self.list.set_model(None)
|
||||||
|
|
||||||
self.store.clear()
|
|
||||||
if progressbar is not None:
|
if progressbar is not None:
|
||||||
progressbar.set_fraction(progress)
|
progressbar.set_fraction(progress)
|
||||||
|
if loading_indicator is not None:
|
||||||
|
GObject.idle_add(loading_indicator.set_visible, True, priority=GObject.PRIORITY_DEFAULT)
|
||||||
|
|
||||||
for multiverse_id, card in library.items():
|
for multiverse_id, card in library.items():
|
||||||
if card.multiverse_id is not None:
|
if card.multiverse_id is not None:
|
||||||
if card.supertypes is None:
|
if card.supertypes is None:
|
||||||
@@ -134,11 +137,15 @@ class CardList(Gtk.ScrolledWindow):
|
|||||||
card.set_name]
|
card.set_name]
|
||||||
self.store.append(item)
|
self.store.append(item)
|
||||||
progress += progress_step
|
progress += progress_step
|
||||||
|
|
||||||
if progressbar is not None:
|
if progressbar is not None:
|
||||||
progressbar.set_fraction(progress)
|
progressbar.set_fraction(progress)
|
||||||
|
if loading_indicator is not None:
|
||||||
|
GObject.idle_add(loading_indicator.set_visible, False, priority=GObject.PRIORITY_DEFAULT)
|
||||||
if self.filtered:
|
if self.filtered:
|
||||||
self.list.set_model(self.store)
|
self.list.set_model(self.filter_and_sort)
|
||||||
self.list.thaw_child_notify()
|
self.list.thaw_child_notify()
|
||||||
|
GObject.idle_add(util.push_status, "Library ready.", priority=GObject.PRIORITY_DEFAULT)
|
||||||
|
|
||||||
def update_generate(self, library, step=128):
|
def update_generate(self, library, step=128):
|
||||||
n = 0
|
n = 0
|
||||||
|
|||||||
@@ -64,6 +64,17 @@ class LibraryView(Gtk.Grid):
|
|||||||
right_pane.pack_start(Gtk.VSeparator(), False, False, 2)
|
right_pane.pack_start(Gtk.VSeparator(), False, False, 2)
|
||||||
right_pane.pack_start(self.remove_button, False, False, 2)
|
right_pane.pack_start(self.remove_button, False, False, 2)
|
||||||
|
|
||||||
|
spinner = Gtk.Spinner()
|
||||||
|
spinner.start()
|
||||||
|
label = Gtk.Label("Loading List")
|
||||||
|
|
||||||
|
self.spinner_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
self.spinner_box.pack_start(spinner, True, False, 0)
|
||||||
|
self.overlay = Gtk.Overlay()
|
||||||
|
self.overlay.add(self.lib_list)
|
||||||
|
self.overlay.add_overlay(self.spinner_box)
|
||||||
|
self.overlay.show_all()
|
||||||
|
|
||||||
# Bring it all together
|
# Bring it all together
|
||||||
|
|
||||||
self.attach(topbox, 0, 0, 3, 1)
|
self.attach(topbox, 0, 0, 3, 1)
|
||||||
@@ -74,7 +85,7 @@ class LibraryView(Gtk.Grid):
|
|||||||
|
|
||||||
self.attach(Gtk.VSeparator(), 1, 2, 1, 1)
|
self.attach(Gtk.VSeparator(), 1, 2, 1, 1)
|
||||||
|
|
||||||
self.attach(self.lib_list, 2, 2, 1, 1)
|
self.attach(self.overlay, 2, 2, 1, 1)
|
||||||
|
|
||||||
self.attach(Gtk.VSeparator(), 3, 0, 1, 3)
|
self.attach(Gtk.VSeparator(), 3, 0, 1, 3)
|
||||||
|
|
||||||
@@ -84,6 +95,7 @@ class LibraryView(Gtk.Grid):
|
|||||||
self.refresh_library()
|
self.refresh_library()
|
||||||
|
|
||||||
def refresh_library(self, button=None):
|
def refresh_library(self, button=None):
|
||||||
|
util.push_status("Loading Library")
|
||||||
self.search_entry.activate()
|
self.search_entry.activate()
|
||||||
self.fill_lib_list()
|
self.fill_lib_list()
|
||||||
|
|
||||||
@@ -113,7 +125,7 @@ class LibraryView(Gtk.Grid):
|
|||||||
|
|
||||||
def fill_lib_list(self):
|
def fill_lib_list(self):
|
||||||
# Fill List in thread
|
# Fill List in thread
|
||||||
load_thread = threading.Thread(target=self.lib_list.update, args=(util.library, ))
|
load_thread = threading.Thread(target=self.lib_list.update, args=(util.library, None, self.spinner_box, ))
|
||||||
load_thread.setDaemon(True)
|
load_thread.setDaemon(True)
|
||||||
load_thread.start()
|
load_thread.start()
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ class SearchView(Gtk.Grid):
|
|||||||
# region Public Functions
|
# region Public Functions
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
pass
|
self.searchEntry.grab_focus()
|
||||||
|
|
||||||
def load_cards(self):
|
def load_cards(self):
|
||||||
# Get search term
|
# Get search term
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ def import_library():
|
|||||||
library.clear()
|
library.clear()
|
||||||
for id, card in imported.items():
|
for id, card in imported.items():
|
||||||
library[id] = card
|
library[id] = card
|
||||||
unsaved_changes = True
|
save_library()
|
||||||
push_status("Library imported")
|
push_status("Library imported")
|
||||||
print("Library imported")
|
print("Library imported")
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
@@ -243,7 +243,6 @@ def create_mana_icons(mana_string):
|
|||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)
|
||||||
pixbuf = pixbuf.scale_simple(image.width / 5, image.height / 5, GdkPixbuf.InterpType.HYPER)
|
pixbuf = pixbuf.scale_simple(image.width / 5, image.height / 5, GdkPixbuf.InterpType.HYPER)
|
||||||
except:
|
except:
|
||||||
print("Error while loading file " + path)
|
|
||||||
return
|
return
|
||||||
# os.remove(config.cache_path + filename)
|
# os.remove(path)
|
||||||
return pixbuf
|
return pixbuf
|
||||||
|
|||||||
Reference in New Issue
Block a user