diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index bba9ba7c..4ba7cc19 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -61,7 +61,8 @@ class MainAppWindow: "on_view_popup_menu": self.on_view_popup_menu, "on_view_focus": self.on_view_focus, "on_hide": self.on_hide, - "on_locked": self.on_locked} + "on_locked": self.on_locked, + "on_model_changed": self.on_model_changed} self.__options = get_config() # Used for copy/paste. When adding the previous data will not be deleted. @@ -90,6 +91,11 @@ class MainAppWindow: # dynamically active elements depending on the selected view self.__tool_elements = {k: builder.get_object(k) for k in self.__DYNAMIC_ELEMENTS} self.__cas_label = builder.get_object("cas_label") + self.__fav_count_label = builder.get_object("fav_count_label") + self.__bouquets_count_label = builder.get_object("bouquets_count_label") + 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") builder.connect_signals(handlers) self.init_drag_and_drop() # drag and drop self.__main_window.show() @@ -424,6 +430,7 @@ class MainAppWindow: self.append_blacklist(data_path) self.append_services(data_path) self.append_bouquets(data_path) + self.update_services_counts() except FileNotFoundError as e: show_dialog("error_dialog", self.__main_window, getattr(e, "message", str(e)) + "\n\nPlease, download files from receiver or setup your path for read data!") @@ -656,6 +663,40 @@ class MainAppWindow: return True return False + @run_idle + def on_model_changed(self, model, path, itr=None): + model_name = model.get_name() + + if model_name == self._FAV_LIST_NAME: + self.__fav_count_label.set_text(str(len(model))) + elif model_name == self._SERVICE_LIST_NAME: + self.update_services_counts() + elif model_name == self._BOUQUETS_LIST_NAME: + self.__bouquets_count_label.set_text(str(len(self.__bouquets.keys()))) + + @run_idle + def update_services_counts(self): + """ Updates counters for services + + May be temporary! (Needs optimising.) + """ + tv_count = 0 + radio_count = 0 + data_count = 0 + + for ch in self.__channels.values(): + ch_type = ch.service_type + if ch_type in ("TV", "TV (HD)"): + tv_count += 1 + elif ch_type == "Radio": + radio_count += 1 + elif ch_type == "Data": + data_count += 1 + + self.__tv_count_label.set_text(str(tv_count)) + self.__radio_count_label.set_text(str(radio_count)) + self.__data_count_label.set_text(str(data_count)) + def start_app(): MainAppWindow() diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade index 9808c459..a27a48aa 100644 --- a/app/ui/main_window.glade +++ b/app/ui/main_window.glade @@ -46,6 +46,8 @@ + + @@ -60,6 +62,8 @@ + + True @@ -148,6 +152,7 @@ + 640 @@ -1029,18 +1034,18 @@ - 85 25 True False queue + 2 - + True False - 10 + 5 2 - CAS: + system-lock-screen False @@ -1052,6 +1057,9 @@ True False + CAS + 8 + 0 False @@ -1072,6 +1080,83 @@ 2 + + + True + False + tv-symbolic + + + False + True + 3 + + + + + True + False + TV + 5 + 0 + + + False + True + 4 + + + + + True + False + network-wireless-symbolic + + + False + True + 5 + + + + + True + False + Radio + 5 + 0 + + + False + True + 6 + + + + + True + False + system-run + + + False + True + 7 + + + + + True + False + Data + 0 + + + False + True + 8 + + False @@ -1213,12 +1298,12 @@ 25 True False + 2 True - False False - Channels: + Services: False @@ -1230,6 +1315,9 @@ True False + 0 + 5 + 0 False @@ -1332,10 +1420,10 @@ 25 True False + 2 True - False False Bouquets: @@ -1349,6 +1437,9 @@ True False + 0 + 5 + 0 False