From dc76a7801e0ac008dd27fc6633d88a398c9ce89f Mon Sep 17 00:00:00 2001 From: DYefremov Date: Mon, 2 Apr 2018 23:55:41 +0300 Subject: [PATCH] Skeleton of the bouquets auto-generation feature --- app/ui/dialogs.glade | 6 +- app/ui/main_app_window.py | 76 ++++-- app/ui/main_helper.py | 13 + app/ui/main_window.glade | 489 ++++++++++++++++++++++---------------- 4 files changed, 357 insertions(+), 227 deletions(-) diff --git a/app/ui/dialogs.glade b/app/ui/dialogs.glade index 622295b8..a4426006 100644 --- a/app/ui/dialogs.glade +++ b/app/ui/dialogs.glade @@ -9,7 +9,7 @@ system-help normal DemonEditor - 0.3.0 Pre-alpha + 0.3.1 Pre-alpha 2018 Dmitriy Yefremov dmitry.v.yefremov@gmail.com @@ -22,12 +22,12 @@ dmitry.v.yefremov@gmail.com True mit-x11 - + False vertical 2 - + False end diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index e38f9f69..f5e7ccd7 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -7,7 +7,7 @@ import shutil from app.commons import run_idle, log from app.eparser import get_blacklist, write_blacklist, parse_m3u from app.eparser import get_services, get_bouquets, write_bouquets, write_services, Bouquets, Bouquet, Service -from app.eparser.ecommons import CAS, Flag +from app.eparser.ecommons import CAS, Flag, BouquetService from app.eparser.enigma.bouquets import BqServiceType from app.eparser.neutrino.bouquets import BqType from app.properties import get_config, write_config, Profile @@ -18,7 +18,7 @@ from .dialogs import show_dialog, DialogType, get_chooser_dialog, WaitDialog, ge from .download_dialog import show_download_dialog from .main_helper import edit_marker, insert_marker, move_items, rename, ViewTarget, set_flags, locate_in_services, \ scroll_to, get_base_model, update_picons, copy_picon_reference, assign_picon, remove_picon, \ - is_only_one_item_selected + is_only_one_item_selected, get_bouquets_names from .picons_dialog import PiconsDialog from .satellites_dialog import show_satellites_dialog from .settings_dialog import show_settings_dialog @@ -36,7 +36,8 @@ class MainAppWindow: # dynamically active elements depending on the selected view _SERVICE_ELEMENTS = ("copy_tool_button", "to_fav_tool_button", "copy_menu_item", "services_to_fav_move_popup_item", - "services_edit_popup_item", "services_copy_popup_item", "services_picon_popup_item") + "services_edit_popup_item", "services_copy_popup_item", "services_picon_popup_item", + "services_create_bouquet_popup_item") _BOUQUET_ELEMENTS = ("edit_tool_button", "new_tool_button", "bouquets_new_popup_item", "bouquets_edit_popup_item") @@ -55,7 +56,7 @@ class MainAppWindow: _LOCK_HIDE_ELEMENTS = ("locked_tool_button", "hide_tool_button") - __DYNAMIC_ELEMENTS = ("up_tool_button", "down_tool_button", "cut_tool_button", "copy_tool_button", + __DYNAMIC_ELEMENTS = ("up_tool_button", "down_tool_button", "cut_tool_button", "services_create_bouquet_popup_item", "paste_tool_button", "to_fav_tool_button", "new_tool_button", "remove_tool_button", "cut_menu_item", "copy_menu_item", "paste_menu_item", "delete_menu_item", "edit_tool_button", "services_to_fav_move_popup_item", "services_edit_popup_item", "locked_tool_button", @@ -65,7 +66,7 @@ class MainAppWindow: "import_m3u_tool_button", "fav_import_m3u_popup_item", "fav_insert_marker_popup_item", "fav_edit_marker_popup_item", "fav_edit_popup_item", "fav_locate_popup_item", "services_copy_popup_item", "services_picon_popup_item", "fav_picon_popup_item", - "services_add_new_popup_item", "fav_add_iptv_popup_item") + "services_add_new_popup_item", "fav_add_iptv_popup_item", "copy_tool_button") def __init__(self): handlers = {"on_close_main_window": self.on_quit, @@ -87,8 +88,6 @@ class MainAppWindow: "on_paste": self.on_paste, "on_edit": self.on_rename, "on_delete": self.on_delete, - "on_new_bouquet": self.on_new_bouquet, - "on_bouquets_edit": self.on_bouquets_edit, "on_tool_edit": self.on_tool_edit, "on_to_fav_move": self.on_to_fav_move, "on_services_tree_view_drag_data_get": self.on_services_tree_view_drag_data_get, @@ -116,7 +115,13 @@ class MainAppWindow: "on_search": self.on_search, "on_service_edit": self.on_service_edit, "on_services_add_new": self.on_services_add_new, - "on_iptv": self.on_iptv} + "on_iptv": self.on_iptv, + "on_new_bouquet": self.on_new_bouquet, + "on_bouquets_edit": self.on_bouquets_edit, + "on_create_bouquet_for_current_satellite": self.on_create_bouquet_for_current_satellite, + "on_create_bouquet_for_each_satellite": self.on_create_bouquet_for_each_satellite, + "on_create_bouquet_for_current_package": self.on_create_bouquet_for_current_package, + "on_create_bouquet_for_each_package": self.on_create_bouquet_for_each_package} self.__options = get_config() self.__profile = self.__options.get("profile") @@ -543,21 +548,24 @@ class MainAppWindow: def append_bouquets(self, data_path): for bouquet in get_bouquets(data_path, Profile(self.__profile)): parent = self.__bouquets_model.append(None, [bouquet.name, None, None, bouquet.type]) - for bt in bouquet.bouquets: - name, bt_type, locked, hidden = bt.name, bt.type, bt.locked, bt.hidden - self.__bouquets_model.append(parent, [name, locked, hidden, bt_type]) - services = [] - agr = [None] * 9 - for srv in bt.services: - fav_id = srv.data - # IPTV and MARKER services - s_type = srv.type - if s_type is BqServiceType.MARKER or s_type is BqServiceType.IPTV: - icon = IPTV_ICON if s_type is BqServiceType.IPTV else None - srv = Service(*agr[0:2], icon, srv.name, *agr[0:3], s_type.name, *agr, srv.num, fav_id, None) - self.__services[fav_id] = srv - services.append(fav_id) - self.__bouquets["{}:{}".format(name, bt_type)] = services + for bq in bouquet.bouquets: + self.append_bouquet(bq, parent) + + def append_bouquet(self, bq, parent): + name, bt_type, locked, hidden = bq.name, bq.type, bq.locked, bq.hidden + self.__bouquets_model.append(parent, [name, locked, hidden, bt_type]) + services = [] + agr = [None] * 9 + for srv in bq.services: + fav_id = srv.data + # IPTV and MARKER services + s_type = srv.type + if s_type is BqServiceType.MARKER or s_type is BqServiceType.IPTV: + icon = IPTV_ICON if s_type is BqServiceType.IPTV else None + srv = Service(*agr[0:2], icon, srv.name, *agr[0:3], s_type.name, *agr, srv.num, fav_id, None) + self.__services[fav_id] = srv + services.append(fav_id) + self.__bouquets["{}:{}".format(name, bt_type)] = services def append_services(self, data_path): try: @@ -991,6 +999,28 @@ class MainAppWindow: def get_target_view(self, view): return ViewTarget.SERVICES if Gtk.Buildable.get_name(view) == "services_tree_view" else ViewTarget.FAV + def on_create_bouquet_for_current_satellite(self, item): + model, paths = self.__services_view.get_selection().get_selected_rows() + if is_only_one_item_selected(paths, self.__main_window): + name = model[paths][16] + bouquets_names = get_bouquets_names(self.__bouquets_model) + + if name not in bouquets_names: + services = [BouquetService(None, BqServiceType.DEFAULT, row[18], 0) + for row in self.__services_model if row[16] == name] + bq = Bouquet(name=name, type="tv", services=services, locked=None, hidden=None) + self.append_bouquet(bq, self.__bouquets_model.get_iter(0)) + self.__bouquets_view.expand_row(Gtk.TreePath(0), 0) + + def on_create_bouquet_for_each_satellite(self, item): + pass + + def on_create_bouquet_for_current_package(self, item): + pass + + def on_create_bouquet_for_each_package(self, item): + pass + def start_app(): MainAppWindow() diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py index 4cf8a99a..b94e6eb7 100644 --- a/app/ui/main_helper.py +++ b/app/ui/main_helper.py @@ -429,5 +429,18 @@ def get_base_model(model): return model +def get_bouquets_names(model): + """ Returns all current bouquets names """ + bouquets_names = [] + for row in model: + itr = row.iter + if model.iter_has_child(itr): + num_of_children = model.iter_n_children(itr) + for num in range(num_of_children): + child_itr = model.iter_nth_child(itr, num) + bouquets_names.append(model[child_itr][0]) + return bouquets_names + + if __name__ == "__main__": pass diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade index 6a6434a3..59f45362 100644 --- a/app/ui/main_window.glade +++ b/app/ui/main_window.glade @@ -53,6 +53,41 @@ + + True + False + gtk-clear + + + True + False + gtk-clear + + + True + False + gtk-copy + + + True + False + gtk-copy + + + True + False + emblem-downloads + + + True + False + gtk-edit + + + True + False + edit-select-all + @@ -77,70 +112,266 @@ + + True + False + gtk-find + True False - emblem-downloads - - - True - False - gtk-copy - - - True - False - insert-link - - - True - False - gtk-clear - - - True - False - insert-image - - - True - False - insert-link - - - True - False - gtk-clear - - - True - False - gtk-copy - - - True - False - network-transmit-receive + gtk-save True False - edit-select-all + gtk-select-all True False - insert-text + gtk-new True False - gtk-edit + gtk-save True False - gtk-find + gtk-select-all + + + True + False + insert-image + + + True + False + insert-image + + + True + False + insert-image + + + True + False + insert-link + + + True + False + + + gtk-go-forward + True + False + False + True + True + + + + + + True + False + + + + + Create bouquet + True + False + False + image5 + False + + + True + False + + + For current satellite + True + False + image1 + False + + + + + + For each satellite + True + False + image4 + False + + + + + + True + False + + + + + For current package + True + False + image6 + False + + + + + + For each package + True + False + image7 + False + + + + + + + + + + True + False + + + + + gtk-copy + True + False + False + True + True + + + + + + gtk-edit + True + False + False + immediate + True + True + + + + + + gtk-new + False + True + True + + + + + + True + False + + + + + Picon + True + False + False + insert_image_2 + False + + + True + False + + + Assign + True + False + insert_link_image + False + + + + + + Remove + True + False + clear_image + False + + + + + + True + False + + + + + Copy reference + True + False + copy_image + False + + + + + + + + + + True + False + + + + + gtk-remove + True + False + False + True + True + + + + + + True + False + insert-link + + + True + False + insert-text + + + True + False + network-transmit-receive True @@ -190,7 +421,7 @@ True False False - image7 + find_image False @@ -208,7 +439,7 @@ False False True - image5 + insert_text_image False @@ -220,7 +451,7 @@ False False True - image6 + edit_image False @@ -238,7 +469,7 @@ False False True - image1 + downloads_image False @@ -249,7 +480,7 @@ True False False - image17 + network_transmit_receive_image False @@ -266,7 +497,7 @@ True False False - image13 + insert_image False @@ -277,7 +508,7 @@ Assign True False - image14 + insert_link_image_2 False @@ -287,7 +518,7 @@ Remove True False - image15 + clearimage False @@ -303,7 +534,7 @@ Copy reference True False - image16 + copy_image_2 False @@ -330,150 +561,6 @@ - - True - False - insert-image - - - True - False - insert-image - - - True - False - - - gtk-go-forward - True - False - False - True - True - - - - - - True - False - - - - - gtk-copy - True - False - False - True - True - - - - - - True - False - - - - - gtk-edit - True - False - False - immediate - True - True - - - - - - gtk-new - False - True - True - - - - - - True - False - - - - - Picon - True - False - False - image9 - False - - - True - False - - - Assign - True - False - image11 - False - - - - - - Remove - True - False - image12 - False - - - - - - True - False - - - - - Copy reference - True - False - image10 - False - - - - - - - - - - True - False - - - - - gtk-remove - True - False - False - True - True - - - - True False @@ -671,7 +758,7 @@ Satellites editor True False - image4 + edit_select_all_image False @@ -682,7 +769,7 @@ True False True - image8 + insert_image_3 False @@ -2349,7 +2436,7 @@ True False - Ver. 0.3.0 Pre-alpha + Ver. 0.3.1 Pre-alpha 0.94999998807907104