From c274c9e91d7265cd48a2c60ba231598fd791cbe9 Mon Sep 17 00:00:00 2001 From: Dmitriy Yefremov Date: Wed, 10 Jan 2018 12:15:41 +0300 Subject: [PATCH] skeleton for picons dialog --- DemonEditor.desktop | 4 +- app/eparser/neutrino/bouquets.py | 11 ++- app/picons/__init__.py | 0 app/ui/dialogs.glade | 2 +- app/ui/main_app_window.py | 4 +- app/ui/picons_dialog.glade | 161 +++++++++++++++++++++++++++---- app/ui/picons_dialog.py | 51 +++++++++- app/ui/settings_dialog.py | 2 + 8 files changed, 208 insertions(+), 27 deletions(-) create mode 100644 app/picons/__init__.py diff --git a/DemonEditor.desktop b/DemonEditor.desktop index 7760f125..0e327276 100755 --- a/DemonEditor.desktop +++ b/DemonEditor.desktop @@ -1,8 +1,8 @@ [Desktop Entry] Version=1.0 Name=DemonEditor -Comment=Channels and satellites editor for Enigma2 -Comment[ru]=Редактор каналов и спутников для Enigma2 +Comment=Channels and satellites list editor for Enigma2 +Comment[ru]=Редактор списка каналов и спутников для Enigma2 Icon=accessories-text-editor Exec=bash -c 'cd $(dirname %k) && ./start.py' Terminal=false diff --git a/app/eparser/neutrino/bouquets.py b/app/eparser/neutrino/bouquets.py index 0f7897a9..e27e2fb1 100644 --- a/app/eparser/neutrino/bouquets.py +++ b/app/eparser/neutrino/bouquets.py @@ -4,7 +4,7 @@ from enum import Enum from xml.dom.minidom import parse, Document from app.ui import LOCKED_ICON, HIDE_ICON -from ..ecommons import Bouquets, Bouquet, BouquetService, BqServiceType +from ..ecommons import Bouquets, Bouquet, BouquetService, BqServiceType, PROVIDER _FILE = "bouquets.xml" _U_FILE = "ubouquets.xml" @@ -48,6 +48,15 @@ def parse_bouquets(file, name, bq_type): locked=LOCKED_ICON if locked == "1" else None, hidden=HIDE_ICON if hidden == "1" else None)) + if BqType(bq_type) is BqType.BOUQUET: + for bq in bouquets.bouquets: + if bq.services: + name = bq.name + name = name[name.index("]") + 1:] + key = int(bq.services[0].data.split(":")[0], 16) + if key not in PROVIDER: + PROVIDER[key] = name + return bouquets diff --git a/app/picons/__init__.py b/app/picons/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/ui/dialogs.glade b/app/ui/dialogs.glade index 61ed8db6..a5c70ae2 100644 --- a/app/ui/dialogs.glade +++ b/app/ui/dialogs.glade @@ -1005,8 +1005,8 @@ dmitry.v.yefremov@gmail.com True - False True + False /usr/share/enigma2/picon diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index c80462f9..5ed7035b 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -465,8 +465,8 @@ class MainAppWindow: data_path = self.__options.get(self.__profile).get("data_dir_path") if data_path is None else data_path try: self.append_blacklist(data_path) - self.append_services(data_path) self.append_bouquets(data_path) + self.append_services(data_path) self.update_services_counts(len(self.__services_model)) except FileNotFoundError as e: show_dialog(DialogType.ERROR, self.__main_window, getattr(e, "message", str(e)) + @@ -805,7 +805,7 @@ class MainAppWindow: locate_in_services(view, self.__services_view, self.__main_window) def on_picons_loader_show(self, item): - dialog = PiconsDialog(self.__main_window, self.__options.get(self.__profile).get("data_dir_path")) + dialog = PiconsDialog(self.__main_window, self.__options.get(self.__profile).get("data_dir_path") + "picons") dialog.show() diff --git a/app/ui/picons_dialog.glade b/app/ui/picons_dialog.glade index 30d75df0..60d32017 100644 --- a/app/ui/picons_dialog.glade +++ b/app/ui/picons_dialog.glade @@ -2,11 +2,6 @@ - - True - False - gtk-goto-bottom - False Picons download tool @@ -31,12 +26,13 @@ spread - gtk-cancel + gtk-close True True True True True + True @@ -112,33 +108,165 @@ True False - 2 False True + 2 4 - - Recive + True - True - True - recive_image - True - True + False + + + True + False + True + Cancel + True + gtk-cancel + + + + True + True + + + + + True + False + True + Receive + True + insert-image + + + + True + True + + + + + True + False + + + False + False + + + + + True + False + True + Send + True + go-top + + + + True + True + + False - False + True 5 + + + True + True + True + + + 100 + True + True + + + + + True + False + Info + + + + + False + True + 7 + + + + + True + True + False + + + False + 6 + end + + + + + + + + + + + + False + False + 0 + + + + + False + 16 + + + + + + + + + + + + False + False + 0 + + + + + + + + False + True + 8 + + True @@ -148,8 +276,5 @@ - - cancel_button - diff --git a/app/ui/picons_dialog.py b/app/ui/picons_dialog.py index b24188e0..afb51815 100644 --- a/app/ui/picons_dialog.py +++ b/app/ui/picons_dialog.py @@ -1,20 +1,65 @@ -from . import Gtk, Gdk, UI_RESOURCES_PATH +import subprocess +import time + +from gi.repository import GLib + +from app.commons import run_idle, run_task +from . import Gtk, UI_RESOURCES_PATH class PiconsDialog: def __init__(self, transient, path): - handlers = {} + self._current_process = None + + handlers = {"on_receive": self.on_receive, + "on_cancel": self.on_cancel, + "on_close": self.on_close, + "on_send": self.on_send} builder = Gtk.Builder() - builder.add_objects_from_file(UI_RESOURCES_PATH + "picons_dialog.glade", ("picons_dialog", "recive_image")) + builder.add_objects_from_file(UI_RESOURCES_PATH + "picons_dialog.glade", + ("picons_dialog", "receive_image", "text_buffer")) builder.connect_signals(handlers) self._dialog = builder.get_object("picons_dialog") self._dialog.set_transient_for(transient) + self._expander = builder.get_object("expander") + self._text_view = builder.get_object("text_view") + self._info_bar = builder.get_object("info_bar") def show(self): self._dialog.run() self._dialog.destroy() + def on_receive(self, item): + self._current_process = subprocess.Popen("ls", stdout=subprocess.PIPE) + GLib.io_add_watch(self._current_process.stdout, # file descriptor + GLib.IO_IN, # condition + self.write_to_buffer) # callback + + def write_to_buffer(self, fd, condition): + """https://pygabriel.wordpress.com/2009/07/27/redirecting-the-stdout-on-a-gtk-textview/""" + if condition == GLib.IO_IN: + char = fd.read(1) # we read one byte per time, to avoid blocking + buf = self._text_view.get_buffer() + buf.insert_at_cursor(str(char)) + return True + else: + return False + + @run_task + def on_cancel(self, item): + if self._current_process: + self._current_process.kill() + time.sleep(1) + + @run_idle + def on_close(self, item): + self.on_cancel(item) + self._dialog.destroy() + + def on_send(self, item): + pass + if __name__ == "__main__": pass diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index c0f102f3..eb06cf73 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -26,6 +26,7 @@ class SettingsDialog: self._user_bouquet_field = builder.get_object("user_bouquet_field") self._satellites_xml_field = builder.get_object("satellites_xml_field") self._data_dir_field = builder.get_object("data_dir_field") + self._picons_dir_field = builder.get_object("picons_dir_field") self._enigma_radio_button = builder.get_object("enigma_radio_button") self._neutrino_radio_button = builder.get_object("neutrino_radio_button") @@ -77,6 +78,7 @@ class SettingsDialog: self._user_bouquet_field.set_text(options.get("user_bouquet_path")) self._satellites_xml_field.set_text(options.get("satellites_xml_path")) self._data_dir_field.set_text(options.get("data_dir_path")) + self._picons_dir_field.set_text(options.get("data_dir_path") + "picons") def apply_settings(self): profile = Profile.ENIGMA_2.value if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP.value