Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
657050ad
by Philipp Hörist at 2019-04-20T17:54:48Z
6 changed files:
- gajim/chat_control.py
- gajim/common/config.py
- gajim/common/modules/chatstates.py
- gajim/groupchat_control.py
- gajim/gtk/const.py
- gajim/gtk/settings.py
Changes:
| ... | ... | @@ -289,8 +289,9 @@ class ChatControl(ChatControlBase): |
| 289 | 289 |
self.video_action.connect('change-state', self._on_video)
|
| 290 | 290 |
self.parent_win.window.add_action(self.video_action)
|
| 291 | 291 |
|
| 292 |
+ default_chatstate = app.config.get('send_chatstate_default')
|
|
| 292 | 293 |
chatstate = app.config.get_per(
|
| 293 |
- 'contacts', self.contact.jid, 'send_chatstate', 'composing_only')
|
|
| 294 |
+ 'contacts', self.contact.jid, 'send_chatstate', default_chatstate)
|
|
| 294 | 295 |
|
| 295 | 296 |
act = Gio.SimpleAction.new_stateful(
|
| 296 | 297 |
'send-chatstate-' + self.control_id,
|
| ... | ... | @@ -292,6 +292,8 @@ class Config: |
| 292 | 292 |
'show_chatstate_in_roster': [opt_bool, True, _('If the contact row is colored according to the current chatstate of the contact')],
|
| 293 | 293 |
'show_chatstate_in_tabs': [opt_bool, True, _('If the tab is colored according to the current chatstate of the contact')],
|
| 294 | 294 |
'show_chatstate_in_banner': [opt_bool, True, _('Shows a text in the banner that describes the current chatstate of the contact')],
|
| 295 |
+ 'send_chatstate_default': [opt_str, 'composing_only', _('Chat state notifications that are sent to contacts. Possible values: all, composing_only, disabled')],
|
|
| 296 |
+ 'send_chatstate_muc_default': [opt_str, 'composing_only', _('Chat state notifications that are sent to the group chat. Possible values: all, composing_only, disabled')],
|
|
| 295 | 297 |
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
|
| 296 | 298 |
|
| 297 | 299 |
__options_per_key = {
|
| ... | ... | @@ -617,6 +619,20 @@ class Config: |
| 617 | 619 |
del opt[1][name][subname]
|
| 618 | 620 |
self._timeout_save()
|
| 619 | 621 |
|
| 622 |
+ def del_all_per(self, typename, subname):
|
|
| 623 |
+ # Deletes all settings per typename
|
|
| 624 |
+ # Example: Delete `account_label` for all accounts
|
|
| 625 |
+ if typename not in self.__options_per_key:
|
|
| 626 |
+ raise ValueError('typename %s does not exist' % typename)
|
|
| 627 |
+ |
|
| 628 |
+ opt = self.__options_per_key[typename]
|
|
| 629 |
+ for name in opt[1]:
|
|
| 630 |
+ try:
|
|
| 631 |
+ del opt[1][name][subname]
|
|
| 632 |
+ except KeyError:
|
|
| 633 |
+ pass
|
|
| 634 |
+ self._timeout_save()
|
|
| 635 |
+ |
|
| 620 | 636 |
def set_per(self, optname, key, subname, value): # per_group_of_option
|
| 621 | 637 |
if optname not in self.__options_per_key:
|
| 622 | 638 |
return
|
| ... | ... | @@ -356,10 +356,12 @@ class Chatstate(BaseModule): |
| 356 | 356 |
@staticmethod
|
| 357 | 357 |
def _get_chatstate_setting(contact):
|
| 358 | 358 |
if contact.is_groupchat():
|
| 359 |
+ default = app.config.get('send_chatstate_muc_default')
|
|
| 359 | 360 |
return app.config.get_per(
|
| 360 |
- 'rooms', contact.jid, 'send_chatstate', 'composing_only')
|
|
| 361 |
+ 'rooms', contact.jid, 'send_chatstate', default)
|
|
| 362 |
+ default = app.config.get('send_chatstate_default')
|
|
| 361 | 363 |
return app.config.get_per(
|
| 362 |
- 'contacts', contact.jid, 'send_chatstate', 'composing_only')
|
|
| 364 |
+ 'contacts', contact.jid, 'send_chatstate', default)
|
|
| 363 | 365 |
|
| 364 | 366 |
def remove_delay_timeout(self, contact):
|
| 365 | 367 |
timeout = self._delay_timeout_ids.get(contact.jid)
|
| ... | ... | @@ -390,8 +390,9 @@ class GroupchatControl(ChatControlBase): |
| 390 | 390 |
act.connect('change-state', self._on_minimize_on_autojoin)
|
| 391 | 391 |
self.parent_win.window.add_action(act)
|
| 392 | 392 |
|
| 393 |
+ default_muc_chatstate = app.config.get('send_chatstate_muc_default')
|
|
| 393 | 394 |
chatstate = app.config.get_per(
|
| 394 |
- 'rooms', self.contact.jid, 'send_chatstate', 'composing_only')
|
|
| 395 |
+ 'rooms', self.contact.jid, 'send_chatstate', default_chatstate)
|
|
| 395 | 396 |
|
| 396 | 397 |
act = Gio.SimpleAction.new_stateful(
|
| 397 | 398 |
'send-chatstate-' + self.control_id,
|
| ... | ... | @@ -56,6 +56,7 @@ class SettingKind(IntEnum): |
| 56 | 56 |
FILECHOOSER = 10
|
| 57 | 57 |
CHANGEPASSWORD = 11
|
| 58 | 58 |
COMBO = 12
|
| 59 |
+ CHATSTATE_COMBO = 13
|
|
| 59 | 60 |
|
| 60 | 61 |
|
| 61 | 62 |
@unique
|
| ... | ... | @@ -99,6 +99,7 @@ class SettingsBox(Gtk.ListBox): |
| 99 | 99 |
SettingKind.HOSTNAME: CutstomHostnameSetting,
|
| 100 | 100 |
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
|
| 101 | 101 |
SettingKind.COMBO: ComboSetting,
|
| 102 |
+ SettingKind.CHATSTATE_COMBO: ChatstateComboSetting,
|
|
| 102 | 103 |
}
|
| 103 | 104 |
|
| 104 | 105 |
if extend is not None:
|
| ... | ... | @@ -535,6 +536,15 @@ class ComboSetting(GenericSetting): |
| 535 | 536 |
self.set_value(combo.get_active_id())
|
| 536 | 537 |
|
| 537 | 538 |
|
| 539 |
+class ChatstateComboSetting(ComboSetting):
|
|
| 540 |
+ def on_value_change(self, combo):
|
|
| 541 |
+ self.set_value(combo.get_active_id())
|
|
| 542 |
+ if 'muc' in self.value:
|
|
| 543 |
+ app.config.del_all_per('rooms', 'send_chatstate')
|
|
| 544 |
+ else:
|
|
| 545 |
+ app.config.del_all_per('contacts', 'send_chatstate')
|
|
| 546 |
+ |
|
| 547 |
+ |
|
| 538 | 548 |
class ProxyComboSetting(GenericSetting):
|
| 539 | 549 |
|
| 540 | 550 |
__gproperties__ = {
|