Skip to content

Commit

Permalink
loading services list in the background
Browse files Browse the repository at this point in the history
  • Loading branch information
DYefremov committed Jul 11, 2021
1 parent c5e8e19 commit b15cae8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
18 changes: 14 additions & 4 deletions app/ui/main_app_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def __init__(self, **kwargs):
self._tv_count_label = builder.get_object("tv_count_label")
self._radio_count_label = builder.get_object("radio_count_label")
self._data_count_label = builder.get_object("data_count_label")
self._services_load_spinner = builder.get_object("services_load_spinner")
self._save_header_button = builder.get_object("save_header_button")
self._app_info_box.bind_property("visible", self._save_header_button, "visible", 4)
self._save_header_button.bind_property("visible", builder.get_object("save_menu_button"), "visible")
Expand Down Expand Up @@ -610,6 +611,11 @@ def on_close_app(self, *args):
if not self._main_window.is_maximized():
self._settings.add("window_size", self._main_window.get_size())

if self._services_load_spinner.get_property("active"):
msg = "{}\n\n\t{}".format(get_message("Data loading in progress!"), get_message("Are you sure?"))
if show_dialog(DialogType.QUESTION, self._main_window, msg) == Gtk.ResponseType.CANCEL:
return True

if self._recorder:
if self._recorder.is_record():
msg = "{}\n\n\t{}".format(get_message("Recording in progress!"), get_message("Are you sure?"))
Expand Down Expand Up @@ -1527,8 +1533,6 @@ def update_data(self, data_path, callback=None):
else:
self.append_blacklist(black_list)
yield from self.append_data(bouquets, services)
finally:
self._wait_dialog.hide()
self._profile_combo_box.set_sensitive(True)
if callback:
callback()
Expand All @@ -1540,6 +1544,8 @@ def update_data(self, data_path, callback=None):
if self._filter_box.get_visible():
self.on_filter_changed()
yield True
finally:
self._wait_dialog.hide()

def append_data(self, bouquets, services):
if self._app_info_box.get_visible():
Expand Down Expand Up @@ -1631,7 +1637,9 @@ def append_services(self, services):
# Adding channels to dict with fav_id as keys.
self._services[srv.fav_id] = srv
self.update_services_counts(len(self._services.values()))
factor = self.DEL_FACTOR * 2
self._wait_dialog.hide()
self._services_load_spinner.start()
factor = self.DEL_FACTOR

for index, srv in enumerate(services):
tooltip, background = None, None
Expand All @@ -1646,6 +1654,8 @@ def append_services(self, services):
self._services_model.append(s)
if index % factor == 0:
yield True

self._services_load_spinner.stop()
yield True

def clear_current_data(self):
Expand Down Expand Up @@ -2053,7 +2063,7 @@ def on_tree_view_key_release(self, view, event):

def on_view_focus(self, view, focus_event=None):
model_name, model = get_model_data(view)
not_empty = len(model) > 0 # if > 0 model has items
not_empty = len(model) > 0 if model else False
is_service = model_name == self.SERVICE_MODEL_NAME

if model_name == self.BQ_MODEL_NAME:
Expand Down
2 changes: 1 addition & 1 deletion app/ui/main_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def get_base_paths(paths, model):
def get_model_data(view):
""" Returns model name and base model from the given view """
model = get_base_model(view.get_model())
model_name = model.get_name()
model_name = model.get_name() if model else ""
return model_name, model


Expand Down
18 changes: 17 additions & 1 deletion app/ui/main_window.glade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2
<!-- Generated with glade 3.22.1
The MIT License (MIT)
Expand Down Expand Up @@ -2529,6 +2529,22 @@ Author: Dmitriy Yefremov
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="services_load_spinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Loading data...</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_right">10</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">10</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand Down

0 comments on commit b15cae8

Please sign in to comment.