Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
028a2abf
Commit
028a2abf
authored
4 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
AdHoc: Show default action
parent
8645a286
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/gtk/adhoc.py
+30
-12
30 additions, 12 deletions
gajim/gtk/adhoc.py
with
30 additions
and
12 deletions
gajim/gtk/adhoc.py
+
30
−
12
View file @
028a2abf
...
...
@@ -83,14 +83,12 @@ def _add_custom_buttons(self):
for
button
in
list
(
action_area
.
get_children
()):
self
.
remove_action_widget
(
button
)
cancel
=
Gtk
.
Button
(
label
=
_
(
'
Cancel
'
))
cancel
=
Action
Button
(
_
(
'
Cancel
'
)
,
AdHocAction
.
CANCEL
)
cancel
.
connect
(
'
clicked
'
,
self
.
_abort
)
cancel
.
get_style_context
().
add_class
(
'
destructive-action
'
)
self
.
_buttons
[
'
cancel
'
]
=
cancel
self
.
add_action_widget
(
cancel
)
complete
=
Gtk
.
Button
(
label
=
_
(
'
Finish
'
))
complete
.
action
=
AdHocAction
.
COMPLETE
complete
=
ActionButton
(
_
(
'
Finish
'
),
AdHocAction
.
COMPLETE
)
complete
.
connect
(
'
clicked
'
,
self
.
_execute_action
)
self
.
_buttons
[
'
complete
'
]
=
complete
self
.
add_action_widget
(
complete
)
...
...
@@ -101,28 +99,26 @@ def _add_custom_buttons(self):
self
.
_buttons
[
'
commands
'
]
=
commands
self
.
add_action_widget
(
commands
)
next_
=
Gtk
.
Button
(
label
=
_
(
'
Next
'
))
next_
.
action
=
AdHocAction
.
NEXT
next_
=
ActionButton
(
_
(
'
Next
'
),
AdHocAction
.
NEXT
)
next_
.
connect
(
'
clicked
'
,
self
.
_execute_action
)
self
.
_buttons
[
'
next
'
]
=
next_
self
.
add_action_widget
(
next_
)
prev
=
Gtk
.
Button
(
label
=
_
(
'
Previous
'
))
prev
.
action
=
AdHocAction
.
PREV
prev
=
ActionButton
(
_
(
'
Previous
'
),
AdHocAction
.
PREV
)
prev
.
connect
(
'
clicked
'
,
self
.
_execute_action
)
self
.
_buttons
[
'
prev
'
]
=
prev
self
.
add_action_widget
(
prev
)
execute
=
Gtk
.
Button
(
label
=
_
(
'
Execute
'
))
execute
.
action
=
AdHocAction
.
EXECUTE
execute
.
get_style_context
().
add_class
(
'
suggested-action
'
)
execute
=
ActionButton
(
_
(
'
Execute
'
),
AdHocAction
.
EXECUTE
)
execute
.
connect
(
'
clicked
'
,
self
.
_execute_action
)
self
.
_buttons
[
'
execute
'
]
=
execute
self
.
add_action_widget
(
execute
)
def
_set_button_visibility
(
self
,
page
):
for
button
in
self
.
_buttons
.
value
s
():
for
action
,
button
in
self
.
_buttons
.
item
s
():
button
.
hide
()
if
action
in
(
'
next
'
,
'
prev
'
,
'
complete
'
):
button
.
remove_default
()
if
page
==
Page
.
COMMANDS
:
self
.
_buttons
[
'
execute
'
].
show
()
...
...
@@ -132,10 +128,13 @@ def _set_button_visibility(self, page):
stage_page
=
self
.
get_nth_page
(
page
)
if
not
stage_page
.
actions
:
self
.
_buttons
[
'
complete
'
].
show
()
self
.
_buttons
[
'
complete
'
].
make_default
()
else
:
for
action
in
stage_page
.
actions
:
button
=
self
.
_buttons
.
get
(
action
.
value
)
if
button
is
not
None
:
if
button
.
action
==
stage_page
.
default
:
button
.
make_default
()
button
.
show
()
elif
page
==
Page
.
ERROR
:
...
...
@@ -328,6 +327,7 @@ def __init__(self):
self
.
_dataform_widget
=
None
self
.
_notes
=
[]
self
.
_last_stage_data
=
None
self
.
default
=
None
self
.
show_all
()
@property
...
...
@@ -347,6 +347,7 @@ def process_stage(self, stage_data):
self
.
_last_stage_data
=
stage_data
self
.
_show_notes
(
stage_data
.
notes
)
self
.
_show_form
(
stage_data
.
data
)
self
.
default
=
stage_data
.
default
def
_show_form
(
self
,
form
):
if
self
.
_dataform_widget
is
not
None
:
...
...
@@ -482,3 +483,20 @@ def show_command_button(self):
@show_command_button.setter
def
show_command_button
(
self
,
value
):
self
.
_show_command_button
=
value
class
ActionButton
(
Gtk
.
Button
):
def
__init__
(
self
,
label
,
action
):
Gtk
.
Button
.
__init__
(
self
,
label
=
label
)
self
.
action
=
action
if
action
==
AdHocAction
.
CANCEL
:
self
.
get_style_context
().
add_class
(
'
destructive-action
'
)
if
action
==
AdHocAction
.
EXECUTE
:
self
.
get_style_context
().
add_class
(
'
suggested-action
'
)
def
make_default
(
self
):
self
.
get_style_context
().
add_class
(
'
suggested-action
'
)
def
remove_default
(
self
):
self
.
get_style_context
().
remove_class
(
'
suggested-action
'
)
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