Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm-play-gui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roman Alifanov
eepm-play-gui
Commits
9c6c9bb6
Commit
9c6c9bb6
authored
Oct 19, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
major flagsdialog update: don't hardcode rows
parent
428a77f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
83 deletions
+112
-83
flagsdialog.cmb
src/widgets/flagsdialog.cmb
+2
-17
flagsdialog.py
src/widgets/flagsdialog.py
+71
-23
flagsdialog.ui
src/widgets/flagsdialog.ui
+1
-25
window.py
src/window.py
+38
-18
No files found.
src/widgets/flagsdialog.cmb
View file @
9c6c9bb6
...
...
@@ -12,10 +12,7 @@
(1,5,"AdwClamp",None,2,None,None,None,1,None,None),
(1,11,"GtkScrolledWindow",None,5,None,None,None,0,None,None),
(1,12,"GtkBox",None,11,None,None,None,0,None,None),
(1,13,"GtkListBox",None,12,None,None,None,0,None,None),
(1,14,"AdwSwitchRow","auto_row",13,None,None,None,0,None,None),
(1,15,"AdwSwitchRow","ipfs_row",13,None,None,None,1,None,None),
(1,16,"AdwSwitchRow","force_row",13,None,None,None,2,None,None)
(1,13,"GtkListBox","main_listbox",12,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),
...
...
@@ -32,19 +29,7 @@
(1,12,"GtkBox","spacing","12",0,None,None,None,None,None,None,None,None),
(1,12,"GtkOrientable","orientation","vertical",0,None,None,None,None,None,None,None,None),
(1,12,"GtkWidget","vexpand","True",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","vexpand","True",0,None,None,None,None,None,None,None,None),
(1,14,"AdwActionRow","subtitle","The user will not be asked any questions",1,None,None,None,None,None,None,None,None),
(1,14,"AdwActionRow","subtitle-lines","3",0,None,None,None,None,None,None,None,None),
(1,14,"AdwPreferencesRow","title","Auto",0,None,None,None,None,None,None,None,None),
(1,14,"GtkListBoxRow","selectable","False",0,None,None,None,None,None,None,None,None),
(1,15,"AdwActionRow","subtitle","It helps to get resources that are unavailable from your network",1,None,None,None,None,None,None,None,None),
(1,15,"AdwActionRow","subtitle-lines","3",0,None,None,None,None,None,None,None,None),
(1,15,"AdwPreferencesRow","title","IPFS",0,None,None,None,None,None,None,None,None),
(1,15,"GtkListBoxRow","selectable","False",0,None,None,None,None,None,None,None,None),
(1,16,"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,16,"AdwActionRow","subtitle-lines","3",0,None,None,None,None,None,None,None,None),
(1,16,"AdwPreferencesRow","title","Force",0,None,None,None,None,None,None,None,None),
(1,16,"GtkListBoxRow","selectable","False",0,None,None,None,None,None,None,None,None)
(1,13,"GtkWidget","vexpand","True",0,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,13,"GtkWidget",1,1,None,None,None,None,None,None),
...
...
src/widgets/flagsdialog.py
View file @
9c6c9bb6
...
...
@@ -2,35 +2,83 @@ import re
from
gi.repository
import
Gtk
,
Adw
class
FlagRow
(
Adw
.
ActionRow
):
__gtype_name__
=
'FlagRow'
def
__init__
(
self
,
flag
,
flag_name
,
flag_description
):
super
()
.
__init__
()
self
.
flag
=
flag
self
.
flag_name
=
flag_name
self
.
set_title
(
self
.
flag_name
)
self
.
flag_description
=
flag_description
self
.
set_subtitle
(
self
.
flag_description
)
self
.
set_selectable
(
False
)
self
.
set_activatable
(
True
)
self
.
switch
=
Gtk
.
Switch
(
halign
=
Gtk
.
Align
.
CENTER
,
valign
=
Gtk
.
Align
.
CENTER
)
self
.
add_suffix
(
self
.
switch
)
self
.
connect
(
"activated"
,
lambda
_
:
self
.
switch
.
activate
())
def
get_active
(
self
):
return
self
.
switch
.
get_active
()
@Gtk.Template
(
resource_path
=
'/ru/eepm/PlayGUI/widgets/flagsdialog.ui'
)
class
FlagsDialog
(
Adw
.
Dialog
):
__gtype_name__
=
'FlagsDialog'
auto_row
=
Gtk
.
Template
.
Child
()
ipfs_row
=
Gtk
.
Template
.
Child
()
force_row
=
Gtk
.
Template
.
Child
()
main_listbox
=
Gtk
.
Template
.
Child
()
def
__init__
(
self
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
rows
=
[]
def
apply_flags
(
self
,
tool
,
full_command
,
ignored_flags
=
None
):
# Debug: Print initial command and tool
print
(
f
"Initial command: {full_command}"
)
print
(
f
"Tool: {tool}"
)
for
row
in
self
.
rows
:
# Debug: Print each flag's active state
print
(
f
"Checking flag {row.flag}: {row.get_active()}"
)
if
row
.
get_active
():
if
ignored_flags
is
None
or
row
.
flag
not
in
ignored_flags
:
# Debug: Print flag to be applied
print
(
f
"Applying flag: {row.flag}"
)
# Append flag to the command
full_command
=
full_command
.
replace
(
tool
,
f
"{tool} {row.flag}"
)
# Debug: Print the final command after applying flags
print
(
f
"Final command: {full_command}"
)
def
apply_flags
(
self
,
tool
,
flags
,
full_command
):
for
flag
in
flags
:
full_command
=
re
.
sub
(
rf
"
\b
{tool}
\b
"
,
f
"{tool} {flag}"
,
full_command
)
return
full_command
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
""
def
auto
(
self
):
if
self
.
auto_row
.
get_active
():
return
"--auto"
else
:
return
""
def
add_flags
(
self
,
flags
):
for
flag
in
flags
:
if
len
(
flag
)
!=
3
:
raise
ValueError
(
"Only three values are expected"
)
row
=
FlagRow
(
*
flag
)
self
.
rows
.
append
(
row
)
self
.
update_listbox
()
def
remove_flag_row
(
self
,
flag
):
self
.
rows
=
[
row
for
row
in
self
.
rows
if
row
.
flag
!=
flag
]
self
.
update_listbox
()
def
update_listbox
(
self
):
self
.
main_listbox
.
remove_all
()
for
row
in
self
.
rows
:
self
.
main_listbox
.
append
(
row
)
def
clear
(
self
):
self
.
main_listbox
.
remove_all
()
self
.
rows
.
clear
()
src/widgets/flagsdialog.ui
View file @
9c6c9bb6
...
...
@@ -35,32 +35,8 @@
<property
name=
"spacing"
>
12
</property>
<property
name=
"vexpand"
>
True
</property>
<child>
<object
class=
"GtkListBox"
>
<object
class=
"GtkListBox"
id=
"main_listbox"
>
<property
name=
"vexpand"
>
True
</property>
<child>
<object
class=
"AdwSwitchRow"
id=
"auto_row"
>
<property
name=
"selectable"
>
False
</property>
<property
name=
"subtitle"
translatable=
"yes"
>
The user will not be asked any questions
</property>
<property
name=
"subtitle-lines"
>
3
</property>
<property
name=
"title"
>
Auto
</property>
</object>
</child>
<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>
...
...
src/window.py
View file @
9c6c9bb6
...
...
@@ -18,7 +18,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from
gi.repository
import
Gtk
,
Adw
,
GObject
import
re
import
gettext
from
.widgets.applicationrow
import
ApplicationRow
...
...
@@ -62,6 +61,24 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self
.
flagsdialog
=
FlagsDialog
()
self
.
flags_button
.
connect
(
"clicked"
,
lambda
_
:
self
.
flagsdialog
.
present
(
self
))
self
.
flagsdialog
.
add_flags
([
[
"--force"
,
"Force"
,
_
(
"Sometimes it helps to get the latest version of the program. (Not recommended)"
)
],
[
"--auto"
,
"Auto"
,
_
(
"The user will not be asked any questions"
)
],
[
"--ipfs"
,
"IPFS"
,
_
(
"It helps to get resources that are unavailable from your network"
)
],
])
self
.
connect
(
"notify::is-loading"
,
self
.
on_is_loading_changed
)
self
.
search_bar
.
connect_entry
(
self
.
search_entry
)
...
...
@@ -189,12 +206,15 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
pkexec_command
=
f
'pkexec sh -c "{full_command}"'
self
.
logdialog
.
run
(
pkexec_command
,
on_done
=
self
.
update_ui
)
else
:
self
.
logdialog
.
run
(
self
.
apply_flags
(
[
self
.
flagsdialog
.
auto
(),
self
.
flagsdialog
.
ipfs
()
],
"pkexec epm play --update all"
),
on_done
=
self
.
update_ui
)
self
.
logdialog
.
run
(
self
.
flagsdialog
.
apply_flags
(
"epm play"
,
"pkexec epm play --update all"
,
ignored_flags
=
[
"--force"
,
]
),
on_done
=
self
.
update_ui
)
def
get_install_remove_lists
(
self
):
if
not
(
self
.
installed_apps
and
self
.
rows
):
...
...
@@ -215,21 +235,21 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def
build_commands
(
self
,
to_install
,
to_remove
):
commands
=
[]
if
to_install
:
commands
.
append
(
f
"epm play {' '.join(to_install)}"
)
commands
.
append
(
self
.
flagsdialog
.
apply_flags
(
"epm play"
,
f
"epm play {' '.join(to_install)}"
)
)
if
to_remove
:
commands
.
append
(
f
"epm play --remove {' '.join(to_remove)}"
)
commands
.
append
(
self
.
flagsdialog
.
apply_flags
(
"epm play"
,
f
"epm play --remove {' '.join(to_remove)}"
,
ignored_flags
=
[
"--force"
,
"--ipfs"
]
)
)
if
not
commands
:
return
None
full_command
=
" && "
.
join
(
commands
)
# Apply flags to the command
full_command
=
self
.
flagsdialog
.
apply_flags
(
"epn play"
,
[
self
.
flagsdialog
.
force
(),
self
.
flagsdialog
.
ipfs
(),
self
.
flagsdialog
.
auto
()
],
full_command
)
return
full_command
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment