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
e4e8dbbb
Commit
e4e8dbbb
authored
Oct 23, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flagsdialog: switch from lists to dictionaries
parent
9c6c9bb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
26 deletions
+28
-26
flagsdialog.py
src/widgets/flagsdialog.py
+10
-10
window.py
src/window.py
+18
-16
No files found.
src/widgets/flagsdialog.py
View file @
e4e8dbbb
import
re
from
gi.repository
import
Gtk
,
Adw
class
FlagRow
(
Adw
.
ActionRow
):
__gtype_name__
=
'FlagRow'
def
__init__
(
self
,
flag
,
flag_name
,
flag_description
):
def
__init__
(
self
,
flag
_data
):
super
()
.
__init__
()
self
.
flag
=
flag
self
.
flag_name
=
flag_name
self
.
flag
=
flag_data
[
'flag'
]
self
.
flag_name
=
flag_data
[
'name'
]
self
.
set_title
(
self
.
flag_name
)
self
.
flag_description
=
flag_d
escription
self
.
flag_description
=
flag_d
ata
[
'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
...
...
@@ -59,11 +59,11 @@ class FlagsDialog(Adw.Dialog):
return
full_command
def
add_flags
(
self
,
flags
):
for
flag
in
flags
:
if
len
(
flag
)
!=
3
:
raise
ValueError
(
"
Only three values are expected
"
)
for
flag
_data
in
flags
:
if
not
isinstance
(
flag_data
,
dict
)
or
not
all
(
key
in
flag_data
for
key
in
[
'flag'
,
'name'
,
'description'
])
:
raise
ValueError
(
"
Each flag must be a dictionary with 'flag', 'name', and 'description' keys
"
)
row
=
FlagRow
(
*
flag
)
row
=
FlagRow
(
flag_data
)
self
.
rows
.
append
(
row
)
...
...
src/window.py
View file @
e4e8dbbb
...
...
@@ -61,23 +61,25 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self
.
flagsdialog
=
FlagsDialog
()
self
.
flags_button
.
connect
(
"clicked"
,
lambda
_
:
self
.
flagsdialog
.
present
(
self
))
self
.
flagsdialog
.
add_flags
(
[
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"
)
],
])
{
"flag"
:
"--force"
,
"name"
:
"Force"
,
"description"
:
_
(
"Sometimes it helps to get the latest version of the program. (Not recommended)"
),
},
{
"flag"
:
"--ipfs"
,
"name"
:
"IPFS"
,
"description"
:
_
(
"It helps to get resources that are unavailable from your network"
),
},
{
"flag"
:
"--auto"
,
"name"
:
"Auto"
,
"description"
:
_
(
"The user will not be asked any questions"
),
},
]
)
self
.
connect
(
"notify::is-loading"
,
self
.
on_is_loading_changed
)
self
.
search_bar
.
connect_entry
(
self
.
search_entry
)
...
...
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