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
3befd602
Commit
3befd602
authored
4 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Settings: Allow bind_signal() to be inverted
parent
7cfe520a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/common/settings.py
+16
-6
16 additions, 6 deletions
gajim/common/settings.py
gajim/gtk/settings.py
+10
-9
10 additions, 9 deletions
gajim/gtk/settings.py
with
26 additions
and
15 deletions
gajim/common/settings.py
+
16
−
6
View file @
3befd602
...
...
@@ -27,7 +27,6 @@
from
collections
import
namedtuple
from
collections
import
defaultdict
from
gi.module
import
FunctionInfo
from
gi.repository
import
GLib
from
gajim
import
IS_PORTABLE
...
...
@@ -93,19 +92,26 @@ def connect_signal(self, setting, func, account=None, jid=None):
def
disconnect_signals
(
self
,
object_
):
for
_
,
handlers
in
self
.
_callbacks
.
items
():
for
handler
in
list
(
handlers
):
if
isinstance
(
handler
,
FunctionInfo
):
if
isinstance
(
handler
,
tuple
):
continue
func
=
handler
()
if
func
is
None
or
func
.
__self__
is
object_
:
handlers
.
remove
(
handler
)
def
bind_signal
(
self
,
setting
,
widget
,
func_name
,
account
=
None
,
jid
=
None
):
def
bind_signal
(
self
,
setting
,
widget
,
func_name
,
account
=
None
,
jid
=
None
,
inverted
=
False
):
callbacks
=
self
.
_callbacks
[(
setting
,
account
,
jid
)]
func
=
getattr
(
widget
,
func_name
)
callbacks
.
append
(
func
)
callbacks
.
append
(
(
func
,
inverted
)
)
def
_on_destroy
(
*
args
):
callbacks
.
remove
(
func
)
callbacks
.
remove
(
(
func
,
inverted
)
)
widget
.
connect
(
'
destroy
'
,
_on_destroy
)
...
...
@@ -114,7 +120,11 @@ def _notify(self, value, setting, account=None, jid=None):
callbacks
=
self
.
_callbacks
[(
setting
,
account
,
jid
)]
for
func
in
list
(
callbacks
):
if
isinstance
(
func
,
FunctionInfo
):
if
isinstance
(
func
,
tuple
):
func
,
inverted
=
func
if
inverted
:
value
=
not
value
try
:
func
(
value
)
except
Exception
:
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/settings.py
+
10
−
9
View file @
3befd602
...
...
@@ -195,16 +195,17 @@ def _bind_sensitive_state(self):
if
self
.
bind
is
None
:
return
app
.
settings
.
connect_signal
(
self
.
bind
,
self
.
_on_setting_changed
,
account
=
self
.
account
)
value
=
app
.
settings
.
get_account_setting
(
self
.
account
,
self
.
bind
)
if
self
.
inverted
:
value
=
not
value
self
.
set_sensitive
(
value
)
app
.
settings
.
bind_signal
(
self
.
bind
,
self
,
'
set_sensitive
'
,
account
=
self
.
account
,
inverted
=
self
.
inverted
)
if
self
.
account
is
not
None
:
value
=
app
.
settings
.
get_account_setting
(
self
.
account
,
self
.
bind
)
else
:
value
=
app
.
settings
.
get
(
self
.
bind
)
def
_on_setting_changed
(
self
,
value
,
*
args
):
if
self
.
inverted
:
value
=
not
value
self
.
set_sensitive
(
value
)
...
...
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