From 2b63a59c915d7be0d8c5de5043106cd55749db2d Mon Sep 17 00:00:00 2001 From: DYefremov Date: Thu, 20 Dec 2018 18:14:19 +0300 Subject: [PATCH] added prototype of backup tool gui --- app/ui/backup.py | 41 ++++++++++++++ app/ui/backup_dialog.glade | 106 +++++++++++++++++++++++++++++++++++++ app/ui/main_app_window.py | 8 +++ app/ui/main_window.glade | 79 +++++++++++++++++++-------- 4 files changed, 212 insertions(+), 22 deletions(-) create mode 100644 app/ui/backup.py create mode 100644 app/ui/backup_dialog.glade diff --git a/app/ui/backup.py b/app/ui/backup.py new file mode 100644 index 00000000..45ef8f37 --- /dev/null +++ b/app/ui/backup.py @@ -0,0 +1,41 @@ +import os + +from .uicommons import Gtk, UI_RESOURCES_PATH + + +class BackupDialog: + def __init__(self, transient, backup_path): + handlers = {"on_extract": self.on_extract, "on_remove": self.on_remove} + + builder = Gtk.Builder() + builder.set_translation_domain("demon-editor") + builder.add_from_file(UI_RESOURCES_PATH + "backup_dialog.glade") + builder.connect_signals(handlers) + + self._dialog_window = builder.get_object("dialog_window") + self._dialog_window.set_transient_for(transient) + self._model = builder.get_object("main_list_store") + self._backup_path = backup_path + self.init_data() + + def show(self): + self._dialog_window.show() + + def init_data(self): + try: + files = os.listdir(self._backup_path) + except FileNotFoundError as e: + print(e) + else: + for file in filter(lambda x: x.endswith(".zip"), files): + self._model.append((file.rstrip(".zip"), False)) + + def on_extract(self, item): + pass + + def on_remove(self, item): + pass + + +if __name__ == "__main__": + pass diff --git a/app/ui/backup_dialog.glade b/app/ui/backup_dialog.glade new file mode 100644 index 00000000..ecacb3bf --- /dev/null +++ b/app/ui/backup_dialog.glade @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + 480 + 320 + False + True + True + extract-archive + + + True + False + Backup tool + 2 + True + + + True + True + True + Extract + + + + True + False + extract-archive-symbolic + + + + + 1 + + + + + True + True + True + Remove + + + + True + False + user-trash-symbolic + + + + + 1 + + + + + + + 480 + True + True + in + + + True + True + main_list_store + False + 0 + True + + + + + + Backup + True + 0.5 + True + 0 + + + 10 + + + 0 + + + + + + + + + + diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index e05cc1c0..29e70571 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -17,6 +17,7 @@ from app.eparser.enigma.bouquets import BqServiceType from app.eparser.neutrino.bouquets import BqType from app.properties import get_config, write_config, Profile from app.tools.media import Player +from app.ui.backup import BackupDialog from .download_dialog import DownloadDialog from .iptv import IptvDialog, SearchUnavailableDialog, IptvListConfigurationDialog from .search import SearchProvider @@ -104,6 +105,7 @@ class Application(Gtk.Application): "on_locked": self.on_locked, "on_model_changed": self.on_model_changed, "on_import_m3u": self.on_import_m3u, + "on_backup_tool_show": self.on_backup_tool_show, "on_insert_marker": self.on_insert_marker, "on_fav_press": self.on_fav_press, "on_locate_in_services": self.on_locate_in_services, @@ -1248,6 +1250,12 @@ class Application(Gtk.Application): bq_services.append(ch.fav_id) next(self.update_bouquet_services(self._fav_model, None, self._bq_selected), False) + # ***************** Backup tool ****************# + + def on_backup_tool_show(self, item): + """ Shows backup tool dialog """ + BackupDialog(self._main_window, self._options.get(self._profile).get("data_dir_path", "") + "backup/").show() + # ***************** Player *********************# def on_play_stream(self, item=None): diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade index 75c73c8a..962f4868 100644 --- a/app/ui/main_window.glade +++ b/app/ui/main_window.glade @@ -735,7 +735,7 @@ Author: Dmitriy Yefremov vertical 2 - + True True True @@ -749,7 +749,7 @@ Author: Dmitriy Yefremov - + True True True @@ -763,7 +763,7 @@ Author: Dmitriy Yefremov - + True True True @@ -777,7 +777,21 @@ Author: Dmitriy Yefremov - + + True + True + True + Backup + + + + False + True + 3 + + + + True False @@ -788,7 +802,7 @@ Author: Dmitriy Yefremov - + True True True @@ -802,7 +816,7 @@ Author: Dmitriy Yefremov - + True False 5 @@ -815,7 +829,7 @@ Author: Dmitriy Yefremov - + True True True @@ -980,7 +994,7 @@ Author: Dmitriy Yefremov True False - network-transmit-receive + network-transmit-receive-symbolic @@ -1001,7 +1015,7 @@ Author: Dmitriy Yefremov True False - gtk-save + document-save-symbolic @@ -1034,7 +1048,7 @@ Author: Dmitriy Yefremov True False - gtk-spell-check + tools-check-spelling-symbolic @@ -1055,7 +1069,7 @@ Author: Dmitriy Yefremov True False - gtk-find + system-search-symbolic @@ -1111,7 +1125,7 @@ Author: Dmitriy Yefremov True False - go-jump + go-jump-symbolic @@ -1139,7 +1153,7 @@ Author: Dmitriy Yefremov True False - gtk-edit + document-edit-symbolic @@ -1161,7 +1175,7 @@ Author: Dmitriy Yefremov True False - gtk-new + document-new-symbolic @@ -1193,14 +1207,14 @@ Author: Dmitriy Yefremov True False - gtk-select-all + edit-select-all-symbolic False True - 5 + 3 @@ -1214,14 +1228,14 @@ Author: Dmitriy Yefremov True False - insert-image + insert-image-symbolic False True - 6 + 4 @@ -1235,14 +1249,35 @@ Author: Dmitriy Yefremov True False - insert-link + insert-link-symbolic False True - 7 + 5 + + + + + True + True + True + Backup + + + + True + False + extract-archive-symbolic + + + + + False + True + 6 @@ -1446,7 +1481,7 @@ Author: Dmitriy Yefremov 32 True True - edit-find-symbolic + system-search-symbolic False False @@ -1539,7 +1574,7 @@ Author: Dmitriy Yefremov 32 True True - tools-check-spelling + tools-check-spelling-symbolic False False