diff --git a/app/ui/main.glade b/app/ui/main.glade index 6974bde7..b090ede1 100644 --- a/app/ui/main.glade +++ b/app/ui/main.glade @@ -1778,6 +1778,7 @@ Author: Dmitriy Yefremov services_model_sort False 3 + True True both 20 @@ -1803,9 +1804,10 @@ Author: Dmitriy Yefremov False + fixed CAS - + 0 @@ -1815,9 +1817,10 @@ Author: Dmitriy Yefremov False + fixed Type - + 1 @@ -1827,14 +1830,16 @@ Author: Dmitriy Yefremov True - 50 + fixed + 170 Service True True 0.5 3 - + + 24 2 @@ -1843,7 +1848,8 @@ Author: Dmitriy Yefremov - + + 5 end 25 @@ -1853,8 +1859,9 @@ Author: Dmitriy Yefremov - - 2 + + 24 + 0 21 @@ -1862,8 +1869,10 @@ Author: Dmitriy Yefremov - - 2 + + 24 + 5 + 2.2351741291171123e-10 21 @@ -1875,14 +1884,15 @@ Author: Dmitriy Yefremov True - 50 + fixed + 120 Package True True 0.5 6 - + end 15 @@ -1896,6 +1906,7 @@ Author: Dmitriy Yefremov True + fixed 25 Type True @@ -1903,7 +1914,7 @@ Author: Dmitriy Yefremov 0.5 7 - + 0.51999998092651367 @@ -1915,13 +1926,14 @@ Author: Dmitriy Yefremov + fixed 25 Picon True 0.5 9 - + 21 8 @@ -1936,7 +1948,7 @@ Author: Dmitriy Yefremov Picon ID 0.5 - + 9 @@ -1946,6 +1958,7 @@ Author: Dmitriy Yefremov True + fixed 25 SID True @@ -1953,7 +1966,7 @@ Author: Dmitriy Yefremov 0.5 10 - + 0.50999999046325684 @@ -1966,6 +1979,7 @@ Author: Dmitriy Yefremov True + fixed 25 Freq True @@ -1973,7 +1987,7 @@ Author: Dmitriy Yefremov 0.5 11 - + 0.50999999046325684 @@ -1986,6 +2000,7 @@ Author: Dmitriy Yefremov True + fixed 25 Rate True @@ -1993,7 +2008,7 @@ Author: Dmitriy Yefremov 0.5 12 - + 0.50999999046325684 @@ -2006,6 +2021,7 @@ Author: Dmitriy Yefremov True + fixed 25 Pol True @@ -2013,7 +2029,7 @@ Author: Dmitriy Yefremov 0.5 13 - + 0.50999999046325684 @@ -2026,6 +2042,7 @@ Author: Dmitriy Yefremov True + fixed 25 FEC True @@ -2033,7 +2050,7 @@ Author: Dmitriy Yefremov 0.5 14 - + 0.50999999046325684 @@ -2046,6 +2063,7 @@ Author: Dmitriy Yefremov True + fixed 25 System True @@ -2053,7 +2071,7 @@ Author: Dmitriy Yefremov 0.5 15 - + 0.50999999046325684 @@ -2066,6 +2084,7 @@ Author: Dmitriy Yefremov True + fixed 25 Pos True @@ -2073,7 +2092,7 @@ Author: Dmitriy Yefremov 0.5 16 - + 0.50999999046325684 @@ -2086,9 +2105,10 @@ Author: Dmitriy Yefremov False + fixed data_id - + 17 @@ -2098,9 +2118,10 @@ Author: Dmitriy Yefremov False + fixed fav_id - + 18 @@ -2110,9 +2131,10 @@ Author: Dmitriy Yefremov False + fixed transponder - + 19 @@ -2122,15 +2144,16 @@ Author: Dmitriy Yefremov False + fixed extra - + 20 - + @@ -2676,6 +2699,7 @@ Author: Dmitriy Yefremov fav_list_store False 2 + True True both 9 @@ -2700,13 +2724,14 @@ Author: Dmitriy Yefremov True + fixed 25 Num True 0.5 - + 0.49000000953674316 5 5 @@ -2722,15 +2747,16 @@ Author: Dmitriy Yefremov True - 50 + fixed + 170 Service True True 0.5 - - 2 + + 5 10 @@ -2738,8 +2764,8 @@ Author: Dmitriy Yefremov - - 2 + + 24 10 @@ -2747,7 +2773,8 @@ Author: Dmitriy Yefremov - + + 5 end 25 @@ -2757,8 +2784,9 @@ Author: Dmitriy Yefremov - - 2 + + 24 + 0 10 @@ -2766,8 +2794,10 @@ Author: Dmitriy Yefremov - - 2 + + 24 + 5 + 0 10 @@ -2779,6 +2809,7 @@ Author: Dmitriy Yefremov True + fixed 25 Type True @@ -2786,7 +2817,7 @@ Author: Dmitriy Yefremov 0.5 - + 0.50999999046325684 @@ -2798,6 +2829,7 @@ Author: Dmitriy Yefremov + fixed 25 Pos True @@ -2805,7 +2837,7 @@ Author: Dmitriy Yefremov 0.5 - + 0.50999999046325684 @@ -2818,9 +2850,10 @@ Author: Dmitriy Yefremov False + fixed fav_id - + 7 @@ -2830,15 +2863,16 @@ Author: Dmitriy Yefremov False + fixed extra - + 9 - + @@ -3285,7 +3319,7 @@ Author: Dmitriy Yefremov True 0.5 - + end @@ -3293,13 +3327,13 @@ Author: Dmitriy Yefremov - + 1 - + 0 @@ -3315,7 +3349,7 @@ Author: Dmitriy Yefremov autosize Type - + 3 diff --git a/app/ui/main.py b/app/ui/main.py index a200becb..56fa0d53 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -2,7 +2,7 @@ # # The MIT License (MIT) # -# Copyright (c) 2018-2021 Dmitriy Yefremov +# Copyright (c) 2018-2022 Dmitriy Yefremov # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -243,7 +243,7 @@ class Application(Gtk.Application): self._ftp_client = None # Record self._recorder = None - # http api + # HTTP API self._http_api = None self._fav_click_mode = None # Appearance @@ -434,6 +434,11 @@ class Application(Gtk.Application): self._data_paned.bind_property("visible", main_header_box, "visible") self._player_box.bind_property("visible", profile_box, "visible", 4) self._player_box.bind_property("visible", toolbar_box, "visible", 4) + # Picons. + column = builder.get_object("picon_column") + column.set_cell_data_func(builder.get_object("picon_renderer"), self.picon_data_func) + column = builder.get_object("fav_service_column") + column.set_cell_data_func(builder.get_object("fav_picon_renderer"), self.fav_picon_data_func) # Setting the last size of the window if it was saved. main_window_size = self._settings.get("window_size") if main_window_size: @@ -696,7 +701,7 @@ class Application(Gtk.Application): self._current_font = self._settings.list_font if self._picons_size != self._settings.list_picon_size: - self.update_picons_size() + self._picons.clear() if self._s_type is SettingsType.ENIGMA_2: self._use_colors = self._settings.use_colors @@ -742,19 +747,6 @@ class Application(Gtk.Application): paned.set_position(main_position) self._fav_paned.set_position(fav_position) - @run_task - def update_picons_size(self): - self._picons_size = self._settings.list_picon_size - update_picons_data(self._settings.profile_picons_path, self._picons, self._picons_size) - self.update_picons_pixbufs() - - @run_idle - def update_picons_pixbufs(self): - self._fav_model.foreach(lambda m, p, itr: m.set_value(itr, Column.FAV_PICON, self._picons.get( - self._services.get(m.get_value(itr, Column.FAV_ID)).picon_id, None))) - self._services_model.foreach(lambda m, p, itr: m.set_value(itr, Column.SRV_PICON, self._picons.get( - m.get_value(itr, Column.SRV_PICON_ID), None))) - def update_background_colors(self, new_color, extra_color): if extra_color != self._EXTRA_COLOR: for row in self._fav_model: @@ -2003,11 +1995,11 @@ class Application(Gtk.Application): self.update_services_counts(len(self._services.values())) self._wait_dialog.hide() self._services_load_spinner.start() - factor = self.DEL_FACTOR + factor = self.DEL_FACTOR / 4 for index, srv in enumerate(services): background = self.get_new_background(srv.flags_cas) - s = srv._replace(picon=self._picons.get(srv.picon_id, None)) + (None, background) + s = srv + (None, background) self._services_model.append(s) if index % factor == 0: yield True @@ -2282,18 +2274,9 @@ class Application(Gtk.Application): if not is_marker: num += 1 - picon = self._picons.get(srv.picon_id, None) - # Alternatives - if srv.service_type == BqServiceType.ALT.name: - alt_servs = srv.transponder - if alt_servs: - alt_srv = self._services.get(alt_servs[0].data, None) - if alt_srv: - picon = self._picons.get(alt_srv.picon_id, None) if srv else None - self._fav_model.append((0 if is_marker else num, srv.coded, ex_srv_name if ex_srv_name else srv.service, srv.locked, srv.hide, srv_type, srv.pos, srv.fav_id, - picon, None, background)) + None, None, background)) yield True self._fav_view.set_model(self._fav_model) @@ -3253,15 +3236,12 @@ class Application(Gtk.Application): @run_with_delay(2) def on_filter_changed(self, item=None): self._services_load_spinner.start() - model = self._services_view.get_model() - self._services_view.set_model(None) self.update_filter_cache() - self.update_filter_state(model) + self.update_filter_state() @run_idle - def update_filter_state(self, model): + def update_filter_state(self): self._services_model_filter.refilter() - self._services_view.set_model(model) GLib.idle_add(self._services_load_spinner.stop) def update_filter_cache(self): @@ -3516,7 +3496,25 @@ class Application(Gtk.Application): self._services_load_spinner.stop() yield True - # ***************** Picons *********************# + # ***************** Picons ********************* # + + def picon_data_func(self, column, renderer, model, itr, data): + renderer.set_property("pixbuf", self._picons.get(model.get_value(itr, Column.SRV_PICON_ID))) + + def fav_picon_data_func(self, column, renderer, model, itr, data): + srv = self._services.get(model.get_value(itr, Column.FAV_ID), None) + if not srv: + return True + + picon = self._picons.get(srv.picon_id, None) + # Alternatives. + if srv.service_type == BqServiceType.ALT.name: + alt_servs = srv.transponder + if alt_servs: + alt_srv = self._services.get(alt_servs[0].data, None) + if alt_srv: + picon = self._picons.get(alt_srv.picon_id, None) if srv else None + renderer.set_property("pixbuf", picon) @run_task def update_picons(self): @@ -3524,7 +3522,7 @@ class Application(Gtk.Application): append_picons(self._picons, self._services_model) def get_picon(self, p_id): - return get_picon_pixbuf(f"{self._settings.profile_picons_path}{p_id}", self._settings.list_picon_size) + return get_picon_pixbuf(f"{self._settings.profile_picons_path}{p_id}", self._picons_size) def on_assign_picon(self, view, src_path=None, dst_path=None): self._stack.set_visible_child_name(Page.PICONS.value) diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py index 2d78b357..40bd8341 100644 --- a/app/ui/main_helper.py +++ b/app/ui/main_helper.py @@ -281,7 +281,7 @@ def set_lock(blacklist, services, model, paths, target, services_model): locked = has_locked_hide(model, paths, col_num) ids = [] - skip_type = {BqServiceType.MARKER.name, BqServiceType.SPACE.name} + skip_type = {BqServiceType.MARKER.name, BqServiceType.SPACE.name, BqServiceType.ALT.name} for path in paths: itr = model.get_iter(path) diff --git a/app/ui/picons.glade b/app/ui/picons.glade index 0f932086..9c0b2eae 100644 --- a/app/ui/picons.glade +++ b/app/ui/picons.glade @@ -3,7 +3,7 @@ The MIT License (MIT) -Copyright (c) 2018-2021 Dmitriy Yefremov +Copyright (c) 2018-2022 Dmitriy Yefremov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -708,6 +708,7 @@ Author: Dmitriy Yefremov True Drag the services to the desired picon or picon to the list of selected services. picons_src_sort_model + True horizontal 0 True @@ -723,11 +724,14 @@ Author: Dmitriy Yefremov + fixed 150 Picon 0.49000000953674316 - + + 5 + 0 @@ -736,6 +740,7 @@ Author: Dmitriy Yefremov + fixed Name 0.49000000953674316 @@ -751,6 +756,7 @@ Author: Dmitriy Yefremov False + fixed column @@ -836,6 +842,7 @@ Author: Dmitriy Yefremov True Drag the services to the desired picon or picon to the list of selected services. picons_dst_sort_model + True horizontal 0 True @@ -852,11 +859,14 @@ Author: Dmitriy Yefremov + fixed 150 Picon 0.49000000953674316 - + + 5 + 0 @@ -865,6 +875,7 @@ Author: Dmitriy Yefremov + fixed Name True 0.49000000953674316 @@ -881,6 +892,7 @@ Author: Dmitriy Yefremov False + fixed column diff --git a/app/ui/picons.py b/app/ui/picons.py index 23aad7ff..16674d23 100644 --- a/app/ui/picons.py +++ b/app/ui/picons.py @@ -197,6 +197,11 @@ class PiconManager(Gtk.Box): self._manager_button.bind_property("active", builder.get_object("add_menu_button"), "visible") # Init drag-and-drop self.init_drag_and_drop() + # Rendering. + column = builder.get_object("dest_picon_column") + column.set_cell_data_func(builder.get_object("picons_dest_renderer"), self.picon_data_func) + column = builder.get_object("src_picon_column") + column.set_cell_data_func(builder.get_object("picons_src_renderer"), self.picon_data_func) # Settings self._settings = settings self._s_type = settings.setting_type @@ -274,7 +279,7 @@ class PiconManager(Gtk.Box): def update_picons(self, path, view): p_model = view.get_model() model = get_base_model(p_model) - factor = self._app.DEL_FACTOR + factor = self._app.DEL_FACTOR * 2 for index, itr in enumerate([row.iter for row in model]): model.remove(itr) @@ -282,18 +287,11 @@ class PiconManager(Gtk.Box): yield True self._dst_count_label.set_text("0") - if not os.path.isdir(path): - return - for index, file in enumerate(os.listdir(path)): if self._terminate: return - p_path = f"{path}{SEP}{file}" - p = self.get_pixbuf_at_scale(p_path, 72, 48, True) - if p: - model.append((p, file, p_path)) - + model.append((None, file, f"{path}{SEP}{file}")) if index % factor == 0: self._dst_count_label.set_text(str(len(model))) yield True @@ -301,6 +299,9 @@ class PiconManager(Gtk.Box): self._dst_count_label.set_text(str(len(model))) yield True + def picon_data_func(self, column, renderer, model, itr, data): + renderer.set_property("pixbuf", self.get_pixbuf_at_scale(model.get_value(itr, 2), 72, 48, True)) + def update_picons_from_file(self, view, uri): """ Adds picons in the view on dragging from file system. """ path = Path(urlparse(unquote(uri)).path.strip()) diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index 175c0c1c..deb2d515 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -3,7 +3,7 @@ The MIT License (MIT) -Copyright (c) 2018-2021 Dmitriy Yefremov +Copyright (c) 2018-2022 Dmitriy Yefremov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1885,6 +1885,7 @@ Author: Dmitriy Yefremov 72 96 + 1 diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index 694e25c7..296a0592 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -2,7 +2,7 @@ # # The MIT License (MIT) # -# Copyright (c) 2018-2021 Dmitriy Yefremov +# Copyright (c) 2018-2022 Dmitriy Yefremov # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -69,6 +69,7 @@ class SettingsDialog: "on_add_picon_path": self.on_add_picon_path, "on_remove_picon_path": self.on_remove_picon_path, "on_lang_changed": self.on_lang_changed, + "on_picons_size_changed": self.on_picons_size_changed, "on_main_settings_visible": self.on_main_settings_visible, "on_http_use_ssl_toggled": self.on_http_use_ssl_toggled, "on_click_mode_togged": self.on_click_mode_togged, @@ -91,6 +92,7 @@ class SettingsDialog: self._profiles = self._settings.profiles self._s_type = self._settings.setting_type self._updated = False + self._current_page = None builder = get_builder(UI_RESOURCES_PATH + "settings_dialog.glade", handlers) @@ -624,10 +626,14 @@ class SettingsDialog: if box.get_active_id() != self._settings.language: self.show_info_message("Save and restart the program to apply the settings.", Gtk.MessageType.WARNING) + def on_picons_size_changed(self, box): + if self._current_page == "appearance" and box.get_active_id() != self._settings.list_picon_size: + self.show_info_message("Save and restart the program to apply the settings.", Gtk.MessageType.WARNING) + def on_main_settings_visible(self, stack, param): - name = stack.get_visible_child_name() - self._apply_presets_button.set_visible(name == "streaming") - self._reset_button.set_visible(name == "profiles") + self._current_page = stack.get_visible_child_name() + self._apply_presets_button.set_visible(self._current_page == "streaming") + self._reset_button.set_visible(self._current_page == "profiles") def on_http_use_ssl_toggled(self, button): active = button.get_active()