Philipp Hörist pushed to branch master at gajim / gajim
Commits:
657050ad by Philipp Hörist at 2019-04-20T17:54:48Z
Add default chatstate setting
- - - - -
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:
=====================================
gajim/chat_control.py
=====================================
@@ -289,8 +289,9 @@ class ChatControl(ChatControlBase):
self.video_action.connect('change-state', self._on_video)
self.parent_win.window.add_action(self.video_action)
+ default_chatstate = app.config.get('send_chatstate_default')
chatstate = app.config.get_per(
- 'contacts', self.contact.jid, 'send_chatstate', 'composing_only')
+ 'contacts', self.contact.jid, 'send_chatstate', default_chatstate)
act = Gio.SimpleAction.new_stateful(
'send-chatstate-' + self.control_id,
=====================================
gajim/common/config.py
=====================================
@@ -292,6 +292,8 @@ class Config:
'show_chatstate_in_roster': [opt_bool, True, _('If the contact row is
colored according to the current chatstate of the contact')],
'show_chatstate_in_tabs': [opt_bool, True, _('If the tab is colored
according to the current chatstate of the contact')],
'show_chatstate_in_banner': [opt_bool, True, _('Shows a text in the
banner that describes the current chatstate of the contact')],
+ 'send_chatstate_default': [opt_str, 'composing_only', _('Chat state
notifications that are sent to contacts. Possible values: all, composing_only,
disabled')],
+ 'send_chatstate_muc_default': [opt_str, 'composing_only', _('Chat
state notifications that are sent to the group chat. Possible values: all,
composing_only, disabled')],
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
__options_per_key = {
@@ -617,6 +619,20 @@ class Config:
del opt[1][name][subname]
self._timeout_save()
+ def del_all_per(self, typename, subname):
+ # Deletes all settings per typename
+ # Example: Delete `account_label` for all accounts
+ if typename not in self.__options_per_key:
+ raise ValueError('typename %s does not exist' % typename)
+
+ opt = self.__options_per_key[typename]
+ for name in opt[1]:
+ try:
+ del opt[1][name][subname]
+ except KeyError:
+ pass
+ self._timeout_save()
+
def set_per(self, optname, key, subname, value): # per_group_of_option
if optname not in self.__options_per_key:
return
=====================================
gajim/common/modules/chatstates.py
=====================================
@@ -356,10 +356,12 @@ class Chatstate(BaseModule):
@staticmethod
def _get_chatstate_setting(contact):
if contact.is_groupchat():
+ default = app.config.get('send_chatstate_muc_default')
return app.config.get_per(
- 'rooms', contact.jid, 'send_chatstate', 'composing_only')
+ 'rooms', contact.jid, 'send_chatstate', default)
+ default = app.config.get('send_chatstate_default')
return app.config.get_per(
- 'contacts', contact.jid, 'send_chatstate', 'composing_only')
+ 'contacts', contact.jid, 'send_chatstate', default)
def remove_delay_timeout(self, contact):
timeout = self._delay_timeout_ids.get(contact.jid)
=====================================
gajim/groupchat_control.py
=====================================
@@ -390,8 +390,9 @@ class GroupchatControl(ChatControlBase):
act.connect('change-state', self._on_minimize_on_autojoin)
self.parent_win.window.add_action(act)
+ default_muc_chatstate = app.config.get('send_chatstate_muc_default')
chatstate = app.config.get_per(
- 'rooms', self.contact.jid, 'send_chatstate', 'composing_only')
+ 'rooms', self.contact.jid, 'send_chatstate', default_chatstate)
act = Gio.SimpleAction.new_stateful(
'send-chatstate-' + self.control_id,
=====================================
gajim/gtk/const.py
=====================================
@@ -56,6 +56,7 @@ class SettingKind(IntEnum):
FILECHOOSER = 10
CHANGEPASSWORD = 11
COMBO = 12
+ CHATSTATE_COMBO = 13
@unique
=====================================
gajim/gtk/settings.py
=====================================
@@ -99,6 +99,7 @@ class SettingsBox(Gtk.ListBox):
SettingKind.HOSTNAME: CutstomHostnameSetting,
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
SettingKind.COMBO: ComboSetting,
+ SettingKind.CHATSTATE_COMBO: ChatstateComboSetting,
}
if extend is not None:
@@ -535,6 +536,15 @@ class ComboSetting(GenericSetting):
self.set_value(combo.get_active_id())
+class ChatstateComboSetting(ComboSetting):
+ def on_value_change(self, combo):
+ self.set_value(combo.get_active_id())
+ if 'muc' in self.value:
+ app.config.del_all_per('rooms', 'send_chatstate')
+ else:
+ app.config.del_all_per('contacts', 'send_chatstate')
+
+
class ProxyComboSetting(GenericSetting):
__gproperties__ = {
View it on GitLab:
https://dev.gajim.org/gajim/gajim/commit/657050ad52ba95859a60bd9c07c4178d515e11a1
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/commit/657050ad52ba95859a60bd9c07c4178d515e11a1
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits