| ... |
... |
@@ -17,7 +17,6 @@ |
|
17
|
17
|
from gi.repository import Gtk
|
|
18
|
18
|
from gi.repository import GLib
|
|
19
|
19
|
from gi.repository import Gdk
|
|
20
|
|
-from gi.repository import GObject
|
|
21
|
20
|
from gi.repository import Pango
|
|
22
|
21
|
|
|
23
|
22
|
from gajim.common import app
|
| ... |
... |
@@ -114,7 +113,7 @@ class SettingsBox(Gtk.ListBox): |
|
114
|
113
|
self.account, *setting[1:-1], **setting.props)
|
|
115
|
114
|
else:
|
|
116
|
115
|
listitem = self.map[setting.kind](self.account, *setting[1:-1])
|
|
117
|
|
- listitem.connect('notify::setting-value', self.on_setting_changed)
|
|
|
116
|
+
|
|
118
|
117
|
if setting.name is not None:
|
|
119
|
118
|
self.named_settings[setting.name] = listitem
|
|
120
|
119
|
self.add(listitem)
|
| ... |
... |
@@ -123,28 +122,23 @@ class SettingsBox(Gtk.ListBox): |
|
123
|
122
|
return self.named_settings[name]
|
|
124
|
123
|
|
|
125
|
124
|
def update_states(self):
|
|
126
|
|
- values = []
|
|
127
|
|
- values.append((None, None))
|
|
128
|
|
- for row in self.get_children():
|
|
129
|
|
- name = row.name
|
|
130
|
|
- if name is None:
|
|
131
|
|
- continue
|
|
132
|
|
- value = row.get_property('setting-value')
|
|
133
|
|
- values.append((name, value))
|
|
134
|
|
-
|
|
135
|
|
- for name, value in values:
|
|
136
|
|
- for row in self.get_children():
|
|
137
|
|
- row.update_activatable(name, value)
|
|
138
|
|
-
|
|
139
|
|
- def on_setting_changed(self, widget, *args):
|
|
140
|
|
- value = widget.get_property('setting-value')
|
|
141
|
125
|
for row in self.get_children():
|
|
142
|
|
- row.update_activatable(widget.name, value)
|
|
|
126
|
+ row.update_activatable()
|
|
143
|
127
|
|
|
144
|
128
|
|
|
145
|
129
|
class GenericSetting(Gtk.ListBoxRow):
|
|
146
|
|
- def __init__(self, account, label, type_, value,
|
|
147
|
|
- name, callback, data, desc, enabledif, enabled_func):
|
|
|
130
|
+ def __init__(self,
|
|
|
131
|
+ account,
|
|
|
132
|
+ label,
|
|
|
133
|
+ type_,
|
|
|
134
|
+ value,
|
|
|
135
|
+ name,
|
|
|
136
|
+ callback,
|
|
|
137
|
+ data,
|
|
|
138
|
+ desc,
|
|
|
139
|
+ bind,
|
|
|
140
|
+ inverted,
|
|
|
141
|
+ enabled_func):
|
|
148
|
142
|
Gtk.ListBoxRow.__init__(self)
|
|
149
|
143
|
self._grid = Gtk.Grid()
|
|
150
|
144
|
self._grid.set_size_request(-1, 30)
|
| ... |
... |
@@ -157,7 +151,8 @@ class GenericSetting(Gtk.ListBoxRow): |
|
157
|
151
|
self.label = label
|
|
158
|
152
|
self.account = account
|
|
159
|
153
|
self.name = name
|
|
160
|
|
- self.enabledif = enabledif
|
|
|
154
|
+ self.bind = bind
|
|
|
155
|
+ self.inverted = inverted
|
|
161
|
156
|
self.enabled_func = enabled_func
|
|
162
|
157
|
self.setting_value = self.get_value()
|
|
163
|
158
|
|
| ... |
... |
@@ -193,16 +188,26 @@ class GenericSetting(Gtk.ListBoxRow): |
|
193
|
188
|
self._grid.add(self.setting_box)
|
|
194
|
189
|
self.add(self._grid)
|
|
195
|
190
|
|
|
196
|
|
- def do_get_property(self, prop):
|
|
197
|
|
- if prop.name == 'setting-value':
|
|
198
|
|
- return self.setting_value
|
|
199
|
|
- raise AttributeError('unknown property %s' % prop.name)
|
|
|
191
|
+ self.connect('destroy', self._on_destroy)
|
|
|
192
|
+ self._bind_sensitive_state()
|
|
200
|
193
|
|
|
201
|
|
- def do_set_property(self, prop, value):
|
|
202
|
|
- if prop.name == 'setting-value':
|
|
203
|
|
- self.setting_value = value
|
|
204
|
|
- else:
|
|
205
|
|
- raise AttributeError('unknown property %s' % prop.name)
|
|
|
194
|
+ def _bind_sensitive_state(self):
|
|
|
195
|
+ if self.bind is None:
|
|
|
196
|
+ return
|
|
|
197
|
+
|
|
|
198
|
+ app.settings.connect_signal(self.bind,
|
|
|
199
|
+ self._on_setting_changed,
|
|
|
200
|
+ account=self.account)
|
|
|
201
|
+
|
|
|
202
|
+ value = app.settings.get_account_setting(self.account, self.bind)
|
|
|
203
|
+ if self.inverted:
|
|
|
204
|
+ value = not value
|
|
|
205
|
+ self.set_sensitive(value)
|
|
|
206
|
+
|
|
|
207
|
+ def _on_setting_changed(self, value, *args):
|
|
|
208
|
+ if self.inverted:
|
|
|
209
|
+ value = not value
|
|
|
210
|
+ self.set_sensitive(value)
|
|
206
|
211
|
|
|
207
|
212
|
def get_value(self):
|
|
208
|
213
|
return self.__get_value(self.type_, self.value, self.account)
|
| ... |
... |
@@ -249,8 +254,6 @@ class GenericSetting(Gtk.ListBoxRow): |
|
249
|
254
|
if self.callback is not None:
|
|
250
|
255
|
self.callback(state, self.data)
|
|
251
|
256
|
|
|
252
|
|
- self.set_property('setting-value', state)
|
|
253
|
|
-
|
|
254
|
257
|
@staticmethod
|
|
255
|
258
|
def set_no_log_for(account, state):
|
|
256
|
259
|
no_log = app.settings.get_account_setting(account, 'no_log_for').split()
|
| ... |
... |
@@ -265,25 +268,20 @@ class GenericSetting(Gtk.ListBoxRow): |
|
265
|
268
|
def on_row_activated(self):
|
|
266
|
269
|
raise NotImplementedError
|
|
267
|
270
|
|
|
268
|
|
- def update_activatable(self, name, value):
|
|
269
|
|
- enabled_func_value = True
|
|
270
|
|
- if self.enabled_func is not None:
|
|
271
|
|
- enabled_func_value = self.enabled_func()
|
|
|
271
|
+ def update_activatable(self):
|
|
|
272
|
+ if self.enabled_func is None:
|
|
|
273
|
+ return
|
|
272
|
274
|
|
|
273
|
|
- enabledif_value = True
|
|
274
|
|
- if self.enabledif is not None and self.enabledif[0] == name:
|
|
275
|
|
- enabledif_value = (name, value) == self.enabledif
|
|
|
275
|
+ enabled_func_value = self.enabled_func()
|
|
|
276
|
+ self.set_activatable(enabled_func_value)
|
|
|
277
|
+ self.set_sensitive(enabled_func_value)
|
|
276
|
278
|
|
|
277
|
|
- self.set_activatable(enabled_func_value and enabledif_value)
|
|
278
|
|
- self.set_sensitive(enabled_func_value and enabledif_value)
|
|
|
279
|
+ def _on_destroy(self, *args):
|
|
|
280
|
+ if self.bind is not None:
|
|
|
281
|
+ app.settings.disconnect_signals(self)
|
|
279
|
282
|
|
|
280
|
283
|
|
|
281
|
284
|
class SwitchSetting(GenericSetting):
|
|
282
|
|
-
|
|
283
|
|
- __gproperties__ = {
|
|
284
|
|
- "setting-value": (bool, 'Switch Value', '', False,
|
|
285
|
|
- GObject.ParamFlags.READWRITE),}
|
|
286
|
|
-
|
|
287
|
285
|
def __init__(self, *args):
|
|
288
|
286
|
GenericSetting.__init__(self, *args)
|
|
289
|
287
|
|
| ... |
... |
@@ -327,11 +325,6 @@ class SwitchSetting(GenericSetting): |
|
327
|
325
|
|
|
328
|
326
|
|
|
329
|
327
|
class EntrySetting(GenericSetting):
|
|
330
|
|
-
|
|
331
|
|
- __gproperties__ = {
|
|
332
|
|
- "setting-value": (str, 'Entry Value', '', '',
|
|
333
|
|
- GObject.ParamFlags.READWRITE),}
|
|
334
|
|
-
|
|
335
|
328
|
def __init__(self, *args):
|
|
336
|
329
|
GenericSetting.__init__(self, *args)
|
|
337
|
330
|
|
| ... |
... |
@@ -358,12 +351,6 @@ class EntrySetting(GenericSetting): |
|
358
|
351
|
|
|
359
|
352
|
|
|
360
|
353
|
class ColorSetting(GenericSetting):
|
|
361
|
|
-
|
|
362
|
|
- __gproperties__ = {
|
|
363
|
|
- "setting-value": (str, 'Color Value', '', '',
|
|
364
|
|
- GObject.ParamFlags.READWRITE),
|
|
365
|
|
- }
|
|
366
|
|
-
|
|
367
|
354
|
def __init__(self, *args):
|
|
368
|
355
|
GenericSetting.__init__(self, *args)
|
|
369
|
356
|
|
| ... |
... |
@@ -389,11 +376,6 @@ class ColorSetting(GenericSetting): |
|
389
|
376
|
|
|
390
|
377
|
|
|
391
|
378
|
class DialogSetting(GenericSetting):
|
|
392
|
|
-
|
|
393
|
|
- __gproperties__ = {
|
|
394
|
|
- "setting-value": (str, 'Dummy', '', '',
|
|
395
|
|
- GObject.ParamFlags.READWRITE),}
|
|
396
|
|
-
|
|
397
|
379
|
def __init__(self, *args, dialog):
|
|
398
|
380
|
GenericSetting.__init__(self, *args)
|
|
399
|
381
|
self.dialog = dialog
|
| ... |
... |
@@ -422,11 +404,6 @@ class DialogSetting(GenericSetting): |
|
422
|
404
|
|
|
423
|
405
|
|
|
424
|
406
|
class SpinSetting(GenericSetting):
|
|
425
|
|
-
|
|
426
|
|
- __gproperties__ = {
|
|
427
|
|
- "setting-value": (int, 'Priority', '', -128, 127, 0,
|
|
428
|
|
- GObject.ParamFlags.READWRITE),}
|
|
429
|
|
-
|
|
430
|
407
|
def __init__(self, *args, range_):
|
|
431
|
408
|
GenericSetting.__init__(self, *args)
|
|
432
|
409
|
|
| ... |
... |
@@ -460,11 +437,6 @@ class SpinSetting(GenericSetting): |
|
460
|
437
|
|
|
461
|
438
|
|
|
462
|
439
|
class FileChooserSetting(GenericSetting):
|
|
463
|
|
-
|
|
464
|
|
- __gproperties__ = {
|
|
465
|
|
- "setting-value": (str, 'Certificate Path', '', '',
|
|
466
|
|
- GObject.ParamFlags.READWRITE),}
|
|
467
|
|
-
|
|
468
|
440
|
def __init__(self, *args, filefilter):
|
|
469
|
441
|
GenericSetting.__init__(self, *args)
|
|
470
|
442
|
|
| ... |
... |
@@ -510,11 +482,6 @@ class FileChooserSetting(GenericSetting): |
|
510
|
482
|
|
|
511
|
483
|
|
|
512
|
484
|
class CallbackSetting(GenericSetting):
|
|
513
|
|
-
|
|
514
|
|
- __gproperties__ = {
|
|
515
|
|
- "setting-value": (str, 'Dummy', '', '',
|
|
516
|
|
- GObject.ParamFlags.READWRITE),}
|
|
517
|
|
-
|
|
518
|
485
|
def __init__(self, *args, callback):
|
|
519
|
486
|
GenericSetting.__init__(self, *args)
|
|
520
|
487
|
self.callback = callback
|
| ... |
... |
@@ -525,11 +492,6 @@ class CallbackSetting(GenericSetting): |
|
525
|
492
|
|
|
526
|
493
|
|
|
527
|
494
|
class ActionSetting(GenericSetting):
|
|
528
|
|
-
|
|
529
|
|
- __gproperties__ = {
|
|
530
|
|
- "setting-value": (str, 'Dummy', '', '',
|
|
531
|
|
- GObject.ParamFlags.READWRITE),}
|
|
532
|
|
-
|
|
533
|
495
|
def __init__(self, *args, account):
|
|
534
|
496
|
GenericSetting.__init__(self, *args)
|
|
535
|
497
|
action_name = '%s%s' % (account, self.value)
|
| ... |
... |
@@ -556,18 +518,8 @@ class LoginSetting(DialogSetting): |
|
556
|
518
|
jid = app.get_jid_from_account(self.account)
|
|
557
|
519
|
return jid
|
|
558
|
520
|
|
|
559
|
|
- def update_activatable(self, name, value):
|
|
560
|
|
- super().update_activatable(name, value)
|
|
561
|
|
- anonym = app.settings.get_account_setting(self.account, 'anonymous_auth')
|
|
562
|
|
- self.set_activatable(not anonym)
|
|
563
|
|
-
|
|
564
|
521
|
|
|
565
|
522
|
class PopoverSetting(GenericSetting):
|
|
566
|
|
-
|
|
567
|
|
- __gproperties__ = {
|
|
568
|
|
- "setting-value": (str, 'Dummy', '', '',
|
|
569
|
|
- GObject.ParamFlags.READWRITE),}
|
|
570
|
|
-
|
|
571
|
523
|
def __init__(self, *args, entries):
|
|
572
|
524
|
GenericSetting.__init__(self, *args)
|
|
573
|
525
|
|
| ... |
... |
@@ -650,11 +602,6 @@ class PopoverRow(Gtk.ListBoxRow): |
|
650
|
602
|
|
|
651
|
603
|
|
|
652
|
604
|
class ComboSetting(GenericSetting):
|
|
653
|
|
-
|
|
654
|
|
- __gproperties__ = {
|
|
655
|
|
- "setting-value": (str, 'Proxy', '', '',
|
|
656
|
|
- GObject.ParamFlags.READWRITE),}
|
|
657
|
|
-
|
|
658
|
605
|
def __init__(self, *args, combo_items):
|
|
659
|
606
|
GenericSetting.__init__(self, *args)
|
|
660
|
607
|
|
| ... |
... |
@@ -683,11 +630,6 @@ class ComboSetting(GenericSetting): |
|
683
|
630
|
|
|
684
|
631
|
|
|
685
|
632
|
class ProxyComboSetting(GenericSetting):
|
|
686
|
|
-
|
|
687
|
|
- __gproperties__ = {
|
|
688
|
|
- "setting-value": (str, 'Proxy', '', '',
|
|
689
|
|
- GObject.ParamFlags.READWRITE),}
|
|
690
|
|
-
|
|
691
|
633
|
def __init__(self, *args):
|
|
692
|
634
|
GenericSetting.__init__(self, *args)
|
|
693
|
635
|
|
| ... |
... |
@@ -756,7 +698,8 @@ class CutstomHostnameSetting(DialogSetting): |
|
756
|
698
|
DialogSetting.__init__(self, *args, **kwargs)
|
|
757
|
699
|
|
|
758
|
700
|
def get_setting_value(self):
|
|
759
|
|
- custom = app.settings.get_account_setting(self.account, 'use_custom_host')
|
|
|
701
|
+ custom = app.settings.get_account_setting(self.account,
|
|
|
702
|
+ 'use_custom_host')
|
|
760
|
703
|
return Q_('?switch:On') if custom else Q_('?switch:Off')
|
|
761
|
704
|
|
|
762
|
705
|
|
| ... |
... |
@@ -768,7 +711,7 @@ class ChangePasswordSetting(DialogSetting): |
|
768
|
711
|
parent.destroy()
|
|
769
|
712
|
open_window('ChangePassword', account=self.account)
|
|
770
|
713
|
|
|
771
|
|
- def update_activatable(self, name, value):
|
|
|
714
|
+ def update_activatable(self):
|
|
772
|
715
|
activatable = False
|
|
773
|
716
|
if self.account in app.connections:
|
|
774
|
717
|
con = app.connections[self.account]
|