From 73ae57d07bdb8df48ed486ed11506962f412c632 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Thu, 23 Apr 2020 18:43:22 +0300 Subject: [PATCH] extracting themes with tar --- app/ui/dialogs.glade | 6 +++--- app/ui/settings_dialog.py | 34 +++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/ui/dialogs.glade b/app/ui/dialogs.glade index 768df7f6..7542d7bb 100644 --- a/app/ui/dialogs.glade +++ b/app/ui/dialogs.glade @@ -3,7 +3,7 @@ The MIT License (MIT) -Copyright (c) 2018 Dmitriy Yefremov +Copyright (c) 2018-2020 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 @@ -31,7 +31,7 @@ Author: Dmitriy Yefremov - + False @@ -45,7 +45,7 @@ Author: Dmitriy Yefremov Enigma2 channel and satellites list editor for MacOS. (Experimental) - https://dyefremov.github.io/DemonEditor/ + https://github.com/DYefremov/DemonEditor/tree/experimental-mac Это приложение распространяется без каких-либо гарантий. Подробнее в <a href="http://opensource.org/licenses/mit-license.php">The MIT License (MIT)</a>. Dmitriy Yefremov diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index 78e465ae..d15ad1e9 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -674,7 +674,9 @@ class SettingsDialog: self.add_theme(self._ext_settings.themes_path, self._theme_combo_box) def on_theme_remove(self, button): - self.remove_theme(self._theme_combo_box, self._ext_settings.themes_path) + if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.OK: + Gtk.Settings().get_default().set_property("gtk-theme-name", "") + self.remove_theme(self._theme_combo_box, self._ext_settings.themes_path) def on_icon_theme_changed(self, button, state=False): if self._main_stack.get_visible_child_name() != "appearance": @@ -685,7 +687,9 @@ class SettingsDialog: self.add_theme(self._ext_settings.icon_themes_path, self._icon_theme_combo_box) def on_icon_theme_remove(self, button): - self.remove_theme(self._icon_theme_combo_box, self._ext_settings.icon_themes_path) + if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.OK: + Gtk.Settings().get_default().set_property("gtk-icon-theme-name", "") + self.remove_theme(self._icon_theme_combo_box, self._ext_settings.icon_themes_path) @run_idle def add_theme(self, path, button): @@ -698,14 +702,17 @@ class SettingsDialog: @run_task def unpack_theme(self, src, dst, button): try: - from shutil import unpack_archive + os.makedirs(os.path.dirname(dst), exist_ok=True) - unpack_archive(src, dst) - except (KeyError, OSError) as e: - self.show_info_message(str(e), Gtk.MessageType.ERROR) - else: - self.update_theme_button(button, dst) + import subprocess + log("Unpacking '{}' started...".format(src)) + p = subprocess.Popen(["tar", "-xvf", src, "-C", dst], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + p.communicate() + log("Unpacking end.") finally: + self.update_theme_button(button, dst) self._appearance_box.set_sensitive(True) @run_idle @@ -727,9 +734,6 @@ class SettingsDialog: self.show_info_message("No selected item!", Gtk.MessageType.ERROR) return - if show_dialog(DialogType.QUESTION, self._dialog) != Gtk.ResponseType.OK: - return - from shutil import rmtree try: @@ -737,8 +741,12 @@ class SettingsDialog: except OSError as e: self.show_info_message(str(e), Gtk.MessageType.ERROR) else: - button.remove(button.get_active()) - button.set_active(0) + self.theme_button_remove_active(button) + + @run_idle + def theme_button_remove_active(self, button): + button.remove(button.get_active()) + button.set_active(0) @run_idle def init_appearance(self):