Commit e41d7d27 authored by Roman Alifanov's avatar Roman Alifanov

added flags dialog

parent cb09107a
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: ru.eepm.PlayGUI\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-08 12:09+0300\n"
"PO-Revision-Date: 2024-10-07 19:17+0300\n"
"POT-Creation-Date: 2024-10-13 19:22+0300\n"
"PO-Revision-Date: 2024-10-13 19:23+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ru\n"
......@@ -14,77 +14,91 @@ msgstr ""
"X-Poedit-Basepath: ../src\n"
"X-Poedit-SearchPath-0: .\n"
#: data/ru.eepm.PlayGUI.desktop.in:3
msgid "eepm play"
msgstr ""
#: data/ru.eepm.PlayGUI.desktop.in:7
#, fuzzy
msgid "Install applications from official sites"
msgstr "Установить программы"
#: data/ru.eepm.PlayGUI.metainfo.xml.in:7
msgid "No description"
msgstr ""
#: data/ui/help-overlay.ui:11
#: gtk/help-overlay.ui:11
msgctxt "shortcut window"
msgid "General"
msgstr ""
#: data/ui/help-overlay.ui:14
#: gtk/help-overlay.ui:14
msgctxt "shortcut window"
msgid "Show Shortcuts"
msgstr ""
#: data/ui/help-overlay.ui:20
#: gtk/help-overlay.ui:20
msgctxt "shortcut window"
msgid "Quit"
msgstr "Выйти"
#: data/ui/window.ui:46
msgid "Getting packages list…"
msgstr "Получение списка пакетов…"
#: widgets/flagsdialog.ui:15
msgid "select the flags"
msgstr "выберите нужные флаги"
#: widgets/flagsdialog.ui:16
msgid "Flags"
msgstr "Флаги"
#: widgets/flagsdialog.ui:40
msgid "It helps to get resources that are unavailable from your network"
msgstr "Помогает получить доступ к ресурсам, которые недоступны в вашей сети"
#: widgets/flagsdialog.ui:48
msgid ""
"Sometimes it helps to get the latest version of the program. (Not "
"recommended)"
msgstr ""
"Иногда помогает получить последнюю версию программы. (Не рекомендуется)"
#: window.py:129
msgid "Remove and install applications"
msgstr "Удалить и установить программы"
#: window.py:130
msgid "Install applications"
msgstr "Установить программы"
#: data/ui/window.ui:47
#: window.py:131
msgid "Remove applications"
msgstr "Удалить программы"
#: window.py:132 window.ui:117
msgid "Update applications"
msgstr "Обновить программы"
#: window.ui:30
msgid "It could take a while"
msgstr "Это может занять некоторое время"
#: data/ui/window.ui:79
#: window.ui:31
msgid "Getting packages list…"
msgstr "Получение списка пакетов…"
#: window.ui:64
msgid "All"
msgstr "Все"
#: data/ui/window.ui:80
#: window.ui:65
msgid "Installed"
msgstr "Установленные"
#: data/ui/window.ui:81
#: window.ui:66
msgid "Uninstalled"
msgstr "Неустановленные"
#: data/ui/window.ui:82
#: window.ui:67
msgid "Changed"
msgstr "Изменённые"
#: data/ui/window.ui:132 src/window.py:180
msgid "Update applications"
msgstr "Обновить программы"
#: window.ui:138
msgid "Flag Selection dialog"
msgstr "Диалог выбора флагов"
#: data/ui/window.ui:158
#: window.ui:174
msgid "_About Eepm-play-gui"
msgstr "_О программе"
#: src/window.py:177
msgid "Remove and install applications"
msgstr "Удалить и установить программы"
#: src/window.py:178
msgid "Install applications"
msgstr "Установить программы"
#: src/window.py:179
msgid "Remove applications"
msgstr "Удалить программы"
#, fuzzy
#~ msgid "Install applications from official sites"
#~ msgstr "Установить программы"
#~ msgid "Apply"
#~ msgstr "Применить"
......@@ -4,6 +4,7 @@
<file>style.css</file>
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">widgets/logdialog.ui</file>
<file preprocess="xml-stripblanks">widgets/flagsdialog.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
</gresources>
......@@ -28,6 +28,7 @@ eepm_play_gui_main = [
eepm_play_gui_widgets = [
'__init__.py',
'widgets/logdialog.py',
'widgets/flagsdialog.py',
'widgets/applicationrow.py',
]
eepm_play_gui_tools = [
......
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!DOCTYPE cambalache-project SYSTEM "cambalache-project.dtd">
<cambalache-project version="0.92.0" target_tk="gtk-4.0">
<ui>
(1,1,"preferences.ui","flagsdialog.ui",None,None,None,None,None,None,None)
</ui>
<object>
(1,1,"AdwDialog","FlagsDialog",None,None,None,None,0,None,None),
(1,2,"AdwToolbarView",None,1,None,None,None,0,None,None),
(1,3,"AdwHeaderBar",None,2,None,"top",None,0,None,None),
(1,4,"AdwWindowTitle",None,3,None,None,None,0,None,None),
(1,5,"AdwClamp",None,2,None,None,None,1,None,None),
(1,6,"GtkBox",None,5,None,None,None,0,None,None),
(1,7,"GtkListBox",None,6,None,None,None,0,None,None),
(1,8,"AdwSwitchRow","force_row",7,None,None,None,1,None,None),
(1,9,"AdwSwitchRow","ipfs_row",7,None,None,None,0,None,None)
</object>
<object_property>
(1,1,"AdwDialog","presentation-mode","bottom-sheet",None,None,None,None,None,None,None,None,None),
(1,3,"AdwHeaderBar","title-widget",None,None,None,None,None,4,None,None,None,None),
(1,4,"AdwWindowTitle","subtitle","select the flags",1,None,None,None,None,None,None,None,None),
(1,4,"AdwWindowTitle","title","Flags",1,None,None,None,None,None,None,None,None),
(1,5,"AdwClamp","maximum-size","500",None,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-bottom","12",None,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-end","12",None,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-start","12",None,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-top","12",None,None,None,None,None,None,None,None,None),
(1,6,"GtkBox","spacing","12",None,None,None,None,None,None,None,None,None),
(1,6,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None),
(1,6,"GtkWidget","vexpand","True",None,None,None,None,None,None,None,None,None),
(1,7,"GtkWidget","height-request","198",None,None,None,None,None,None,None,None,None),
(1,7,"GtkWidget","vexpand","True",None,None,None,None,None,None,None,None,None),
(1,8,"AdwActionRow","subtitle","Sometimes it helps to get the latest version of the program. (Not recommended)",1,None,None,None,None,None,None,None,None),
(1,8,"AdwActionRow","subtitle-lines","3",None,None,None,None,None,None,None,None,None),
(1,8,"AdwPreferencesRow","title","Force",None,None,None,None,None,None,None,None,None),
(1,8,"GtkListBoxRow","selectable","False",None,None,None,None,None,None,None,None,None),
(1,9,"AdwActionRow","subtitle","It helps to get resources that are unavailable from your network",1,None,None,None,None,None,None,None,None),
(1,9,"AdwActionRow","subtitle-lines","3",None,None,None,None,None,None,None,None,None),
(1,9,"AdwPreferencesRow","title","IPFS",None,None,None,None,None,None,None,None,None),
(1,9,"GtkListBoxRow","selectable","False",None,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,7,"GtkWidget",1,1,None,None,None,None,None,None),
(1,7,"GtkWidget",2,2,None,1,None,None,None,None)
</object_data>
<object_data_arg>
(1,7,"GtkWidget",2,2,"name","boxed-list-separate")
</object_data_arg>
</cambalache-project>
from gi.repository import Gtk, Adw
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/widgets/flagsdialog.ui')
class FlagsDialog(Adw.Dialog):
__gtype_name__ = 'FlagsDialog'
ipfs_row = Gtk.Template.Child()
force_row = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
def ipfs(self):
if self.ipfs_row.get_active():
return "--ipfs"
else:
return ""
def force(self):
if self.force_row.get_active():
return "--force"
else:
return ""
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.92.0 -->
<interface>
<!-- interface-name preferences.ui -->
<requires lib="gtk" version="4.12"/>
<requires lib="libadwaita" version="1.5"/>
<template class="FlagsDialog" parent="AdwDialog">
<property name="presentation-mode">bottom-sheet</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<property name="title-widget">
<object class="AdwWindowTitle">
<property name="subtitle" translatable="yes">select the flags</property>
<property name="title" translatable="yes">Flags</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwClamp">
<property name="margin-bottom">12</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">12</property>
<property name="maximum-size">500</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="vexpand">True</property>
<child>
<object class="GtkListBox">
<property name="height-request">198</property>
<property name="vexpand">True</property>
<child>
<object class="AdwSwitchRow" id="ipfs_row">
<property name="selectable">False</property>
<property name="subtitle" translatable="yes">It helps to get resources that are unavailable from your network</property>
<property name="subtitle-lines">3</property>
<property name="title">IPFS</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="force_row">
<property name="selectable">False</property>
<property name="subtitle" translatable="yes">Sometimes it helps to get the latest version of the program. (Not recommended)</property>
<property name="subtitle-lines">3</property>
<property name="title">Force</property>
</object>
</child>
<style>
<class name="boxed-list-separate"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
......@@ -17,7 +17,7 @@
(1,5,"AdwStatusPage","status_page",4,None,None,None,0,None,None),
(1,6,"GtkStackPage",None,3,None,None,None,1,None,None),
(1,7,"AdwToolbarView",None,6,None,None,None,0,None,None),
(1,8,"GtkBox",None,7,None,None,None,0,None,None),
(1,8,"GtkBox",None,7,None,None,None,1,None,None),
(1,9,"GtkSearchBar","search_bar",8,None,None,None,0,None,None),
(1,10,"AdwClamp",None,9,None,None,None,0,None,None),
(1,11,"GtkBox",None,10,None,None,None,0,None,None),
......@@ -27,16 +27,18 @@
(1,15,"GtkScrolledWindow",None,8,None,None,None,1,None,None),
(1,16,"AdwClamp",None,15,None,None,None,0,None,None),
(1,17,"GtkListBox","choice_listbox",16,None,None,None,0,None,None),
(1,18,"AdwClamp",None,7,None,"bottom",None,1,None,None),
(1,19,"GtkListBox",None,18,None,"center",None,0,None,None),
(1,20,"AdwButtonRow","apply_button",19,None,None,None,0,None,None),
(1,21,"AdwHeaderBar","header_bar",2,None,"top",None,1,None,None),
(1,22,"GtkToggleButton","search_toggle_button",21,None,"start",None,0,None,None),
(1,23,"GtkButton",None,21,None,"end",None,1,None,None),
(1,24,"(menu)","primary_menu",None,None,None,None,1,None,None),
(1,25,"(section)",None,24,None,None,None,0,None,None),
(1,26,"(item)",None,25,None,None,None,0,None,None),
(1,27,"AdwSpinner",None,5,None,None,None,0,None,None)
(1,27,"AdwSpinner",None,5,None,None,None,0,None,None),
(1,28,"GtkCenterBox",None,7,None,"bottom",None,0,None,None),
(1,29,"AdwClamp",None,28,None,None,None,0,None,None),
(1,30,"GtkListBox",None,29,None,None,None,0,None,None),
(1,31,"AdwButtonRow","apply_button",30,None,None,None,0,None,None),
(1,32,"GtkButton","flags_button",28,None,"end",None,1,None,None)
</object>
<object_property>
(1,1,"GtkWidget","height-request","294",0,None,None,None,None,None,None,None,None),
......@@ -68,13 +70,6 @@
(1,16,"GtkWidget","margin-start","12",0,None,None,None,None,None,None,None,None),
(1,16,"GtkWidget","margin-top","12",0,None,None,None,None,None,None,None,None),
(1,17,"GtkListBox","selection-mode","none",0,None,None,None,None,None,None,None,None),
(1,18,"AdwClamp","maximum-size","360",0,None,None,None,None,None,None,None,None),
(1,18,"GtkWidget","margin-bottom","12",0,None,None,None,None,None,None,None,None),
(1,18,"GtkWidget","margin-end","12",0,None,None,None,None,None,None,None,None),
(1,18,"GtkWidget","margin-start","12",0,None,None,None,None,None,None,None,None),
(1,18,"GtkWidget","margin-top","12",0,None,None,None,None,None,None,None,None),
(1,19,"GtkListBox","selection-mode","none",0,None,None,None,None,None,None,None,None),
(1,20,"AdwPreferencesRow","title","Update applications",1,None,None,None,None,None,None,None,None),
(1,22,"GtkButton","icon-name","system-search-symbolic",0,None,None,None,None,None,None,None,None),
(1,22,"GtkWidget","sensitive",None,0,None,None,None,None,1,"AdwApplicationWindow","is-loading","sync-create|invert-boolean"),
(1,23,"GtkActionable","action-name","app.about",0,None,None,None,None,None,None,None,None),
......@@ -84,7 +79,19 @@
(1,27,"GtkWidget","halign","center",None,None,None,None,None,None,None,None,None),
(1,27,"GtkWidget","height-request","80",None,None,None,None,None,None,None,None,None),
(1,27,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(1,27,"GtkWidget","width-request","80",None,None,None,None,None,None,None,None,None)
(1,27,"GtkWidget","width-request","80",None,None,None,None,None,None,None,None,None),
(1,28,"GtkCenterBox","center-widget",None,None,None,None,None,29,None,None,None,None),
(1,28,"GtkWidget","halign","center",None,None,None,None,None,None,None,None,None),
(1,28,"GtkWidget","margin-bottom","12",None,None,None,None,None,None,None,None,None),
(1,28,"GtkWidget","margin-end","12",None,None,None,None,None,None,None,None,None),
(1,28,"GtkWidget","margin-start","12",None,None,None,None,None,None,None,None,None),
(1,28,"GtkWidget","margin-top","12",None,None,None,None,None,None,None,None,None),
(1,29,"AdwClamp","maximum-size","500",None,None,None,None,None,None,None,None,None),
(1,29,"GtkWidget","margin-end","12",None,None,None,None,None,None,None,None,None),
(1,29,"GtkWidget","margin-start","12",None,None,None,None,None,None,None,None,None),
(1,31,"AdwPreferencesRow","title","Update applications",1,None,None,None,None,None,None,None,None),
(1,32,"GtkButton","icon-name","emoji-flags-symbolic",None,None,None,None,None,None,None,None,None),
(1,32,"GtkWidget","tooltip-text","Flag Selection dialog",1,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,14,"GtkStringList",1,1,None,None,None,None,None,None),
......@@ -96,15 +103,15 @@
(1,11,"GtkWidget",2,2,None,1,None,None,None,None),
(1,17,"GtkWidget",1,1,None,None,None,None,None,None),
(1,17,"GtkWidget",2,2,None,1,None,None,None,None),
(1,20,"GtkWidget",1,1,None,None,None,None,None,None),
(1,20,"GtkWidget",2,2,None,1,None,None,None,None),
(1,19,"GtkWidget",1,1,None,None,None,None,None,None),
(1,19,"GtkWidget",2,2,None,1,None,None,None,None)
(1,30,"GtkWidget",1,1,None,None,None,None,None,None),
(1,30,"GtkWidget",2,2,None,1,None,None,None,None),
(1,31,"GtkWidget",1,1,None,None,None,None,None,None),
(1,31,"GtkWidget",2,2,None,1,None,None,None,None)
</object_data>
<object_data_arg>
(1,11,"GtkWidget",2,2,"name","linked"),
(1,17,"GtkWidget",2,2,"name","boxed-list-separate"),
(1,20,"GtkWidget",2,2,"name","suggested-action"),
(1,19,"GtkWidget",2,2,"name","boxed-list")
(1,30,"GtkWidget",2,2,"name","boxed-list"),
(1,31,"GtkWidget",2,2,"name","suggested-action")
</object_data_arg>
</cambalache-project>
......@@ -16,13 +16,15 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
from gi.repository import Gtk, Adw, GObject
import re
import gettext
from .widgets.applicationrow import ApplicationRow
from .widgets.logdialog import LogDialog
from .widgets.flagsdialog import FlagsDialog
gettext.textdomain('eepm-play-gui')
_ = gettext.gettext
......@@ -43,6 +45,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
search_dropdown = Gtk.Template.Child()
choice_listbox = Gtk.Template.Child()
apply_button = Gtk.Template.Child()
flags_button = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
......@@ -50,7 +53,10 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.checkboxes = None
self.apply_button.connect("activated", self.on_apply_clicked)
self.flagsdialog = FlagsDialog()
self.flags_button.connect("clicked", lambda _: self.flagsdialog.present(self))
self.connect("notify::is-loading", self.on_is_loading_changed)
self.search_bar.connect_entry(self.search_entry)
......@@ -59,7 +65,8 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.choice_listbox.set_filter_func(self.listbox_filter_func)
self.dialog = LogDialog(win=self)
self.logdialog = LogDialog(win=self)
self.update_ui()
......@@ -168,18 +175,16 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
return matches_search # All
def on_apply_clicked(self, button):
commands = None
self.props.is_loading = True # Show loading message before command execution
self.props.is_loading = True # Показать сообщение о загрузке перед выполнением команды
to_install, to_remove = self.get_install_remove_lists()
commands = self.build_commands(to_install, to_remove)
full_command = self.build_commands(to_install, to_remove)
if commands:
full_command = " && ".join(commands)
if full_command:
pkexec_command = f'pkexec sh -c "{full_command}"'
self.dialog.run(pkexec_command, on_done=self.update_ui)
self.logdialog.run(pkexec_command, on_done=self.update_ui)
else:
self.dialog.run("pkexec epm play --update all", on_done=self.update_ui)
self.logdialog.run("pkexec epm play --update all", on_done=self.update_ui)
def get_install_remove_lists(self):
if self.installed_apps and self.checkboxes:
......@@ -195,4 +200,16 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
commands.append(f"epm play --auto {' '.join(to_install)}")
if to_remove:
commands.append(f"epm play --auto --remove {' '.join(to_remove)}")
return commands
if not commands:
return None
full_command = " && ".join(commands)
# Apply flags to the command
flags = [self.flagsdialog.force(), self.flagsdialog.ipfs()]
for flag in flags:
full_command = re.sub(r"\bepm play\b", f"epm play {flag}", full_command)
return full_command
......@@ -104,26 +104,38 @@
</object>
</property>
<child type="bottom">
<object class="AdwClamp">
<property name="margin-bottom">12</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">12</property>
<property name="maximum-size">360</property>
<child type="center">
<object class="GtkListBox">
<property name="selection-mode">none</property>
<object class="GtkCenterBox">
<property name="center-widget">
<object class="AdwClamp">
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="maximum-size">500</property>
<child>
<object class="AdwButtonRow" id="apply_button">
<property name="title" translatable="yes">Update applications</property>
<object class="GtkListBox">
<child>
<object class="AdwButtonRow" id="apply_button">
<property name="title" translatable="yes">Update applications</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
<style>
<class name="suggested-action"/>
<class name="boxed-list"/>
</style>
</object>
</child>
<style>
<class name="boxed-list"/>
</style>
</object>
</property>
<property name="halign">center</property>
<property name="margin-bottom">12</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">12</property>
<child type="end">
<object class="GtkButton" id="flags_button">
<property name="icon-name">emoji-flags-symbolic</property>
<property name="tooltip-text" translatable="yes">Flag Selection dialog</property>
</object>
</child>
</object>
......
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