Commit 0811624c authored by Roman Alifanov's avatar Roman Alifanov

applications updating and more!

parent 896012d5
msgid ""
msgstr ""
"Project-Id-Version: ru.eepm.PlayGUI\n"
"POT-Creation-Date: 2024-09-30 20:54+0300\n"
"PO-Revision-Date: 2024-09-30 20:54+0300\n"
"POT-Creation-Date: 2024-10-03 01:52+0300\n"
"PO-Revision-Date: 2024-10-03 01:52+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ru\n"
......@@ -28,6 +28,22 @@ msgctxt "shortcut window"
msgid "Quit"
msgstr "Выйти"
#: window.py:160
msgid "Remove and install applications"
msgstr "Удалить и установить программы"
#: window.py:163
msgid "Install applications"
msgstr "Установить программы"
#: window.py:166
msgid "Remove applications"
msgstr "Удалить программы"
#: window.py:169 window.ui:99
msgid "Update applications"
msgstr "Обновить программы"
#: window.ui:20
msgid "Menu"
msgstr ""
......@@ -44,10 +60,9 @@ msgstr "Установленные"
msgid "Uninstalled"
msgstr "Неустановленные"
#: window.ui:98
msgid "Apply"
msgstr "Применить"
#: window.ui:120
#: window.ui:121
msgid "_About Eepm-play-gui"
msgstr "О программе"
#~ msgid "Apply"
#~ msgstr "Применить"
......@@ -63,7 +63,7 @@
(1,14,"GtkWidget","margin-top","12",0,None,None,None,None,None,None,None,None),
(1,21,"(item)","action","app.about",0,None,None,None,None,None,None,None,None),
(1,21,"(item)","label","_About Eepm-play-gui",1,None,None,None,None,None,None,None,None),
(1,22,"AdwPreferencesRow","title","Apply",1,None,None,None,None,None,None,None,None),
(1,22,"AdwPreferencesRow","title","Update applications",1,None,None,None,None,None,None,None,None),
(1,22,"GtkWidget","margin-start","1",None,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
......
......@@ -19,10 +19,13 @@
from gi.repository import Gtk, Adw
import gettext
gettext.textdomain('eepm-play-gui')
_ = gettext.gettext
from .appsmanager import ApplicationManager
from .command_runner import CommandRunner
class LogDialog(Adw.Dialog):
def __init__(self, win, **kwargs):
super().__init__(**kwargs)
......@@ -74,6 +77,8 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow, LogDialog):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.checkboxes = None
self.apply_button.connect("activated", self.on_apply_clicked)
self.search_entry.connect("search-changed", self.on_search_changed)
......@@ -101,8 +106,12 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow, LogDialog):
def update_ui(self):
self.show_loading_spinner() # Show loading again for installed apps
self.update_button_status()
ApplicationManager.get_available_applications(self.on_applications_loaded)
ApplicationManager.get_installed_applications(self.on_installed_apps_loaded)
self.choice_listbox.invalidate_filter()
def on_installed_apps_loaded(self, installed_apps, error=None):
......@@ -140,7 +149,25 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow, LogDialog):
def on_checkbox_toggled(self, checkbox, app_name):
active = checkbox.get_active()
print(f"{app_name} {'установлен' if active else 'снят'}")
self.update_button_status()
def update_button_status(self):
to_install, to_remove = self.get_install_remove_lists()
self.apply_button.remove_css_class("suggested-action")
self.apply_button.remove_css_class("destructive-action")
if to_install and to_remove:
self.apply_button.add_css_class("suggested-action")
self.apply_button.set_title(_("Remove and install applications"))
elif to_install:
self.apply_button.add_css_class("suggested-action")
self.apply_button.set_title(_("Install applications"))
elif to_remove:
self.apply_button.add_css_class("destructive-action")
self.apply_button.set_title(_("Remove applications"))
else:
self.apply_button.add_css_class("suggested-action")
self.apply_button.set_title(_("Update applications"))
def on_search_changed(self, search_entry):
self.choice_listbox.invalidate_filter() # Обновление фильтра при изменении поиска
......@@ -179,12 +206,17 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow, LogDialog):
full_command = " && ".join(commands)
pkexec_command = f'pkexec sh -c "{full_command}"'
self.dialog.run(pkexec_command, on_done=self.update_ui)
else:
self.dialog.run("pkexec epm play --update all", 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]
to_remove = [app_name for app_name, checkbox in self.checkboxes.items() if not checkbox.get_active() and app_name in self.installed_apps]
return to_install, to_remove
def get_install_remove_lists(self):
if self.checkboxes:
to_install = [app_name for app_name, checkbox in self.checkboxes.items() if checkbox.get_active() and app_name not in self.installed_apps]
to_remove = [app_name for app_name, checkbox in self.checkboxes.items() if not checkbox.get_active() and app_name in self.installed_apps]
return to_install, to_remove
else:
return False, False
def build_commands(self, to_install, to_remove):
commands = []
if to_install:
......
......@@ -96,7 +96,7 @@
<child>
<object class="AdwButtonRow" id="apply_button">
<property name="margin-start">1</property>
<property name="title" translatable="yes">Apply</property>
<property name="title" translatable="yes">Update applications</property>
<style>
<class name="suggested-action"/>
</style>
......
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