Commit 896012d5 authored by Roman Alifanov's avatar Roman Alifanov

log dialog in a separate class

parent ecdfb77e
......@@ -23,8 +23,47 @@ from .appsmanager import ApplicationManager
from .command_runner import CommandRunner
class LogDialog(Adw.Dialog):
def __init__(self, win, **kwargs):
super().__init__(**kwargs)
self.set_title("Лог выполнения")
self.set_can_close(False)
self.set_follows_content_size(True)
self.win = win
dialog_clamp = Adw.Clamp(
margin_bottom=12,
margin_end=12,
margin_top=12,
margin_start=12,
maximum_size=500
)
textview = Gtk.TextView()
textview.set_editable(False)
textbuffer = textview.get_buffer()
scrolled_window = Gtk.ScrolledWindow(
width_request=304,
height_request=259
)
scrolled_window.set_child(textview)
scrolled_window.set_vexpand(True)
dialog_clamp.set_child(scrolled_window)
self.set_child(dialog_clamp)
def run(self, command, on_done):
self.present(self.win)
# Создание и передача функции обратного вызова для обновления UI
runner = CommandRunner(on_done=on_done)
runner.run_command(command, self)
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/window.ui')
class EepmPlayGuiWindow(Adw.ApplicationWindow):
class EepmPlayGuiWindow(Adw.ApplicationWindow, LogDialog):
__gtype_name__ = 'EepmPlayGuiWindow'
search_entry = Gtk.Template.Child()
search_dropdown = Gtk.Template.Child()
......@@ -42,6 +81,8 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.choice_listbox.set_filter_func(self.listbox_filter_func)
self.dialog = LogDialog(win=self)
self.update_ui()
def show_loading_spinner(self):
......@@ -137,7 +178,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
if commands:
full_command = " && ".join(commands)
pkexec_command = f'pkexec sh -c "{full_command}"'
self.show_log_dialog(pkexec_command)
self.dialog.run(pkexec_command, on_done=self.update_ui)
def get_install_remove_lists(self):
to_install = [app_name for app_name, checkbox in self.checkboxes.items() if checkbox.get_active() and app_name not in self.installed_apps]
......@@ -152,35 +193,3 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
commands.append(f"epm play --auto --remove {' '.join(to_remove)}")
return commands
def show_log_dialog(self, command):
dialog = Adw.Dialog(title="Лог выполнения")
dialog.set_follows_content_size(True)
dialog_clamp = Adw.Clamp(
margin_bottom=12,
margin_end=12,
margin_top=12,
margin_start=12,
maximum_size=500
)
textview = Gtk.TextView()
textview.set_editable(False)
textbuffer = textview.get_buffer()
scrolled_window = Gtk.ScrolledWindow(
width_request=304,
height_request=259
)
scrolled_window.set_child(textview)
scrolled_window.set_vexpand(True)
dialog_clamp.set_child(scrolled_window)
dialog.set_child(dialog_clamp)
dialog.present(self)
# Создание и передача функции обратного вызова для обновления UI
runner = CommandRunner(on_done=self.update_ui)
runner.run_command(command, dialog)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment