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
You need to sign in or sign up before continuing.
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
Show 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
import
re
from
gi.repository
import
Gtk
,
Adw
from
gi.repository
import
Gtk
,
Adw
class
FlagRow
(
Adw
.
ActionRow
):
class
FlagRow
(
Adw
.
ActionRow
):
__gtype_name__
=
'FlagRow'
__gtype_name__
=
'FlagRow'
def
__init__
(
self
,
flag
,
flag_name
,
flag_description
):
def
__init__
(
self
,
flag
_data
):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
flag
=
flag
self
.
flag
=
flag_data
[
'flag'
]
self
.
flag_name
=
flag_name
self
.
flag_name
=
flag_data
[
'name'
]
self
.
set_title
(
self
.
flag_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_subtitle
(
self
.
flag_description
)
self
.
set_selectable
(
False
)
self
.
set_selectable
(
False
)
self
.
set_activatable
(
True
)
self
.
set_activatable
(
True
)
self
.
switch
=
Gtk
.
Switch
(
self
.
switch
=
Gtk
.
Switch
(
halign
=
Gtk
.
Align
.
CENTER
,
halign
=
Gtk
.
Align
.
CENTER
,
valign
=
Gtk
.
Align
.
CENTER
valign
=
Gtk
.
Align
.
CENTER
...
@@ -59,11 +59,11 @@ class FlagsDialog(Adw.Dialog):
...
@@ -59,11 +59,11 @@ class FlagsDialog(Adw.Dialog):
return
full_command
return
full_command
def
add_flags
(
self
,
flags
):
def
add_flags
(
self
,
flags
):
for
flag
in
flags
:
for
flag
_data
in
flags
:
if
len
(
flag
)
!=
3
:
if
not
isinstance
(
flag_data
,
dict
)
or
not
all
(
key
in
flag_data
for
key
in
[
'flag'
,
'name'
,
'description'
])
:
raise
ValueError
(
"
Only three values are expected
"
)
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
)
self
.
rows
.
append
(
row
)
...
...
src/window.py
View file @
e4e8dbbb
...
@@ -61,23 +61,25 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
...
@@ -61,23 +61,25 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self
.
flagsdialog
=
FlagsDialog
()
self
.
flagsdialog
=
FlagsDialog
()
self
.
flags_button
.
connect
(
"clicked"
,
lambda
_
:
self
.
flagsdialog
.
present
(
self
))
self
.
flags_button
.
connect
(
"clicked"
,
lambda
_
:
self
.
flagsdialog
.
present
(
self
))
self
.
flagsdialog
.
add_flags
(
[
self
.
flagsdialog
.
add_flags
(
[
[
"--force"
,
{
"Force"
,
"flag"
:
"--force"
,
_
(
"Sometimes it helps to get the latest version of the program. (Not recommended)"
)
"name"
:
"Force"
,
],
"description"
:
_
(
"Sometimes it helps to get the latest version of the program. (Not recommended)"
),
[
},
"--auto"
,
{
"Auto"
,
"flag"
:
"--ipfs"
,
_
(
"The user will not be asked any questions"
)
"name"
:
"IPFS"
,
],
"description"
:
_
(
"It helps to get resources that are unavailable from your network"
),
[
},
"--ipfs"
,
{
"IPFS"
,
"flag"
:
"--auto"
,
_
(
"It helps to get resources that are unavailable from your network"
)
"name"
:
"Auto"
,
],
"description"
:
_
(
"The user will not be asked any questions"
),
])
},
]
)
self
.
connect
(
"notify::is-loading"
,
self
.
on_is_loading_changed
)
self
.
connect
(
"notify::is-loading"
,
self
.
on_is_loading_changed
)
self
.
search_bar
.
connect_entry
(
self
.
search_entry
)
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