Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
5002bfaf
Commit
5002bfaf
authored
1 year ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add file choosers to configuration editor
parent
1d608bca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tst/config_editor/config_editor.py
+21
-7
21 additions, 7 deletions
Tst/config_editor/config_editor.py
with
21 additions
and
7 deletions
Tst/config_editor/config_editor.py
+
21
−
7
View file @
5002bfaf
...
...
@@ -73,6 +73,8 @@ module_logger.setLevel(level=logging.WARNING)
SHOW_MERGE_PAGE
=
confignator
.
get_bool_option
(
'
config-editor-general
'
,
'
show-merge-page
'
)
FILE_CHOOSER_OPTIONS
=
[
'
basic-cfg
'
,
'
docu
'
,
'
log-file
'
,
'
datapool-items
'
]
def
create_console_handler
(
frmt
=
logging_format
):
"""
...
...
@@ -612,10 +614,17 @@ class OptionLine:
self
.
set_data
()
self
.
option_entry
.
connect
(
'
changed
'
,
self
.
on_entry_edited
)
if
section
==
'
paths
'
:
# add file chooser buttons for selected options
if
'
paths
'
in
section
and
option
not
in
FILE_CHOOSER_OPTIONS
:
self
.
btn_choose_dir
=
Gtk
.
Button
.
new_from_icon_name
(
'
document-open-symbolic
'
,
Gtk
.
IconSize
.
BUTTON
)
self
.
btn_choose_dir
.
set_tooltip_text
(
'
Choose a path
'
)
self
.
btn_choose_dir
.
connect
(
'
clicked
'
,
self
.
on_choose_dir
,
True
)
elif
option
in
FILE_CHOOSER_OPTIONS
:
self
.
btn_choose_dir
=
Gtk
.
Button
.
new_from_icon_name
(
'
document-open-symbolic
'
,
Gtk
.
IconSize
.
BUTTON
)
self
.
btn_choose_dir
.
set_tooltip_text
(
'
Choose a path
'
)
self
.
btn_choose_dir
.
connect
(
'
clicked
'
,
self
.
on_choose_dir
)
self
.
btn_choose_dir
.
connect
(
'
clicked
'
,
self
.
on_choose_dir
,
False
)
def
get_entry_text
(
self
):
"""
Get the current text of the entry field
"""
...
...
@@ -644,12 +653,17 @@ class OptionLine:
self
.
set_label_text
()
self
.
set_entry_text
()
def
on_choose_dir
(
self
,
button
):
def
on_choose_dir
(
self
,
button
,
choose_dir
):
"""
Event when the button to open a FileChooserDialog was clicked
"""
dialog
=
Gtk
.
FileChooserDialog
(
'
Please choose a file
'
,
None
,
Gtk
.
FileChooserAction
.
SELECT_FOLDER
,
(
Gtk
.
STOCK_CANCEL
,
Gtk
.
ResponseType
.
CANCEL
,
Gtk
.
STOCK_OPEN
,
Gtk
.
ResponseType
.
OK
))
if
choose_dir
:
dialog
=
Gtk
.
FileChooserDialog
(
'
Please choose a directory
'
,
None
,
Gtk
.
FileChooserAction
.
SELECT_FOLDER
,
(
Gtk
.
STOCK_CANCEL
,
Gtk
.
ResponseType
.
CANCEL
,
Gtk
.
STOCK_OPEN
,
Gtk
.
ResponseType
.
OK
))
else
:
dialog
=
Gtk
.
FileChooserDialog
(
'
Please choose a file
'
,
None
,
0
,
(
Gtk
.
STOCK_CANCEL
,
Gtk
.
ResponseType
.
CANCEL
,
Gtk
.
STOCK_OPEN
,
Gtk
.
ResponseType
.
OK
))
response
=
dialog
.
run
()
if
response
==
Gtk
.
ResponseType
.
OK
:
path
=
dialog
.
get_filename
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment