Add option to show chatstate in roster
- Preferences: Add options for display in banner, tab, roster - This makes the chatstate Plugin obsolete
This commit is contained in:
parent
b74468b9c3
commit
15c3de2b4d
6 changed files with 137 additions and 69 deletions
|
@ -669,19 +669,14 @@ class ChatControl(ChatControlBase):
|
||||||
status_reduced = ''
|
status_reduced = ''
|
||||||
status_escaped = GLib.markup_escape_text(status_reduced)
|
status_escaped = GLib.markup_escape_text(status_reduced)
|
||||||
|
|
||||||
st = app.config.get('displayed_chat_state_notifications')
|
|
||||||
if self.TYPE_ID == 'pm':
|
if self.TYPE_ID == 'pm':
|
||||||
cs = self.gc_contact.chatstate
|
cs = self.gc_contact.chatstate
|
||||||
else:
|
else:
|
||||||
cs = app.contacts.get_combined_chatstate(
|
cs = app.contacts.get_combined_chatstate(
|
||||||
self.account, self.contact.jid)
|
self.account, self.contact.jid)
|
||||||
if cs and st in ('composing_only', 'all'):
|
|
||||||
if contact.show == 'offline':
|
if app.config.get('show_chatstate_in_banner'):
|
||||||
chatstate = ''
|
chatstate = helpers.get_uf_chatstate(cs)
|
||||||
elif st == 'all' or cs == 'composing':
|
|
||||||
chatstate = helpers.get_uf_chatstate(cs)
|
|
||||||
else:
|
|
||||||
chatstate = ''
|
|
||||||
|
|
||||||
label_text = '<span>%s</span><span size="x-small" weight="light">%s %s</span>' \
|
label_text = '<span>%s</span><span size="x-small" weight="light">%s %s</span>' \
|
||||||
% (name, acct_info, chatstate)
|
% (name, acct_info, chatstate)
|
||||||
|
|
|
@ -187,7 +187,6 @@ class Config:
|
||||||
'always_english_wiktionary': [opt_bool, True],
|
'always_english_wiktionary': [opt_bool, True],
|
||||||
'remote_control': [opt_bool, False, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True],
|
'remote_control': [opt_bool, False, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True],
|
||||||
'outgoing_chat_state_notifications': [opt_str, 'all', _('Sent chat state notifications. Can be one of all, composing_only, disabled.')],
|
'outgoing_chat_state_notifications': [opt_str, 'all', _('Sent chat state notifications. Can be one of all, composing_only, disabled.')],
|
||||||
'displayed_chat_state_notifications': [opt_str, 'all', _('Displayed chat state notifications in chat windows. Can be one of all, composing_only, disabled.')],
|
|
||||||
'autodetect_browser_mailer': [opt_bool, True, '', True],
|
'autodetect_browser_mailer': [opt_bool, True, '', True],
|
||||||
'print_ichat_every_foo_minutes': [opt_int, 5, _('When not printing time for every message (print_time==sometimes), print it every x minutes.')],
|
'print_ichat_every_foo_minutes': [opt_int, 5, _('When not printing time for every message (print_time==sometimes), print it every x minutes.')],
|
||||||
'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')],
|
'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')],
|
||||||
|
@ -296,6 +295,9 @@ class Config:
|
||||||
'public_room_sync_threshold': [opt_int, 1, _('Maximum history in days we request from a public room archive. 0: As much as possible')],
|
'public_room_sync_threshold': [opt_int, 1, _('Maximum history in days we request from a public room archive. 0: As much as possible')],
|
||||||
'private_room_sync_threshold': [opt_int, 0, _('Maximum history in days we request from a private room archive. 0: As much as possible')],
|
'private_room_sync_threshold': [opt_int, 0, _('Maximum history in days we request from a private room archive. 0: As much as possible')],
|
||||||
'show_subject_on_join': [opt_bool, True, _('If the room subject is shown in chat on join')],
|
'show_subject_on_join': [opt_bool, True, _('If the room subject is shown in chat on join')],
|
||||||
|
'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')],
|
||||||
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
|
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
|
||||||
|
|
||||||
__options_per_key = {
|
__options_per_key = {
|
||||||
|
|
|
@ -737,43 +737,6 @@
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Gajim can send and receive meta-information related to a conversation you may have with a contact. Here you can specify which chatstates you want to display in chat windows.</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">_Display chat state notifications</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="justify">right</property>
|
|
||||||
<property name="mnemonic_widget">displayed_chat_states_combobox</property>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBox" id="displayed_chat_states_combobox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="model">display_chat_state_notifications_liststore</property>
|
|
||||||
<signal name="changed" handler="on_displayed_chat_states_combobox_changed" swapped="no"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText"/>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">0</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -802,6 +765,100 @@
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label_xalign">0</property>
|
||||||
|
<property name="shadow_type">none</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkAlignment">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_top">6</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="show_chatstate_in_tabs">
|
||||||
|
<property name="label" translatable="yes">Show chatstate in tabs</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">If checked, the tab will be colored according to the current chatstate of the contact</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_show_chatstate_in_tabs_toggled" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="show_chatstate_in_roster">
|
||||||
|
<property name="label" translatable="yes">Show chatstate in roster</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">If checked, the contact row will be colored according to the current chatstate of the contact</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_show_chatstate_in_roster_toggled" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="show_chatstate_in_banner">
|
||||||
|
<property name="label" translatable="yes">Show chatstate in banner</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">If checked, a desciption of the contacts current chatstate is shown in the banner</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_show_chatstate_in_banner_toggled" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="label">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Chatstate</property>
|
||||||
|
<style>
|
||||||
|
<class name="bold"/>
|
||||||
|
<class name="margin-top6"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="name">chat</property>
|
<property name="name">chat</property>
|
||||||
|
|
|
@ -157,13 +157,14 @@ class Preferences(Gtk.ApplicationWindow):
|
||||||
self._ui.print_status_in_muc_combobox.set_active(2)
|
self._ui.print_status_in_muc_combobox.set_active(2)
|
||||||
|
|
||||||
# Displayed chat state notifications
|
# Displayed chat state notifications
|
||||||
st = app.config.get('displayed_chat_state_notifications')
|
st = app.config.get('show_chatstate_in_tabs')
|
||||||
if st == 'all':
|
self._ui.show_chatstate_in_tabs.set_active(st)
|
||||||
self._ui.displayed_chat_states_combobox.set_active(0)
|
|
||||||
elif st == 'composing_only':
|
st = app.config.get('show_chatstate_in_roster')
|
||||||
self._ui.displayed_chat_states_combobox.set_active(1)
|
self._ui.show_chatstate_in_roster.set_active(st)
|
||||||
else: # disabled
|
|
||||||
self._ui.displayed_chat_states_combobox.set_active(2)
|
st = app.config.get('show_chatstate_in_banner')
|
||||||
|
self._ui.show_chatstate_in_banner.set_active(st)
|
||||||
|
|
||||||
### Notifications tab ###
|
### Notifications tab ###
|
||||||
## Visual Notifications
|
## Visual Notifications
|
||||||
|
@ -612,15 +613,14 @@ class Preferences(Gtk.ApplicationWindow):
|
||||||
else: # in_and_out
|
else: # in_and_out
|
||||||
app.config.set('print_status_in_muc', 'in_and_out')
|
app.config.set('print_status_in_muc', 'in_and_out')
|
||||||
|
|
||||||
def on_displayed_chat_states_combobox_changed(self, widget):
|
def on_show_chatstate_in_tabs_toggled(self, widget):
|
||||||
active = widget.get_active()
|
self.on_checkbutton_toggled(widget, 'show_chatstate_in_tabs')
|
||||||
if active == 0: # all
|
|
||||||
app.config.set('displayed_chat_state_notifications', 'all')
|
def on_show_chatstate_in_roster_toggled(self, widget):
|
||||||
elif active == 1: # only composing
|
self.on_checkbutton_toggled(widget, 'show_chatstate_in_roster')
|
||||||
app.config.set('displayed_chat_state_notifications',
|
|
||||||
'composing_only')
|
def on_show_chatstate_in_banner_toggled(self, widget):
|
||||||
else: # disabled
|
self.on_checkbutton_toggled(widget, 'show_chatstate_in_banner')
|
||||||
app.config.set('displayed_chat_state_notifications', 'disabled')
|
|
||||||
|
|
||||||
### Notifications tab ###
|
### Notifications tab ###
|
||||||
def on_systray_combobox_changed(self, widget):
|
def on_systray_combobox_changed(self, widget):
|
||||||
|
|
|
@ -652,7 +652,9 @@ class MessageWindow:
|
||||||
if isinstance(ctrl, ChatControl):
|
if isinstance(ctrl, ChatControl):
|
||||||
tab_label_str = ctrl.get_tab_label()
|
tab_label_str = ctrl.get_tab_label()
|
||||||
# Set Label Color
|
# Set Label Color
|
||||||
gtkgui_helpers.add_css_class(nick_label, chatstate, 'gajim-state-')
|
if app.config.get('show_chatstate_in_tabs'):
|
||||||
|
gtkgui_helpers.add_css_class(
|
||||||
|
nick_label, chatstate, 'gajim-state-')
|
||||||
else:
|
else:
|
||||||
tab_label_str, color = ctrl.get_tab_label(chatstate)
|
tab_label_str, color = ctrl.get_tab_label(chatstate)
|
||||||
# Set Label Color
|
# Set Label Color
|
||||||
|
|
|
@ -4639,6 +4639,11 @@ class RosterWindow:
|
||||||
|
|
||||||
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
||||||
|
|
||||||
|
def _nec_chatstate_received(self, event):
|
||||||
|
if event.contact.is_gc_contact or event.contact.is_pm_contact:
|
||||||
|
return
|
||||||
|
self.draw_contact(event.contact.jid, event.account)
|
||||||
|
|
||||||
def _style_changed(self, *args):
|
def _style_changed(self, *args):
|
||||||
self.change_roster_style(None)
|
self.change_roster_style(None)
|
||||||
|
|
||||||
|
@ -4741,17 +4746,22 @@ class RosterWindow:
|
||||||
return
|
return
|
||||||
jid = model[titer][Column.JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][Column.ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
|
|
||||||
color = None
|
color = None
|
||||||
if type_ == 'groupchat':
|
if type_ == 'groupchat':
|
||||||
ctrl = app.interface.minimized_controls[account].get(jid,
|
ctrl = app.interface.minimized_controls[account].get(jid, None)
|
||||||
None)
|
|
||||||
if ctrl and ctrl.attention_flag:
|
if ctrl and ctrl.attention_flag:
|
||||||
color = app.css_config.get_value(
|
color = app.css_config.get_value(
|
||||||
'.state_muc_directed_msg_color', StyleAttr.COLOR)
|
'.state_muc_directed_msg_color', StyleAttr.COLOR)
|
||||||
renderer.set_property('foreground', color)
|
elif app.config.get('show_chatstate_in_roster'):
|
||||||
if not color:
|
chatstate = app.contacts.get_combined_chatstate(account, jid)
|
||||||
color = app.css_config.get_value('.gajim-contact-row', StyleAttr.COLOR)
|
if chatstate not in (None, 'active'):
|
||||||
renderer.set_property('foreground', color)
|
color = app.css_config.get_value(
|
||||||
|
'.gajim-state-%s' % chatstate, StyleAttr.COLOR)
|
||||||
|
else:
|
||||||
|
color = app.css_config.get_value(
|
||||||
|
'.gajim-contact-row', StyleAttr.COLOR)
|
||||||
|
renderer.set_property('foreground', color)
|
||||||
|
|
||||||
self._set_contact_row_background_color(renderer, jid, account)
|
self._set_contact_row_background_color(renderer, jid, account)
|
||||||
desc = app.css_config.get_font('.gajim-contact-row')
|
desc = app.css_config.get_font('.gajim-contact-row')
|
||||||
|
@ -5886,3 +5896,5 @@ class RosterWindow:
|
||||||
self._nec_blocking)
|
self._nec_blocking)
|
||||||
app.ged.register_event_handler('style-changed', ged.GUI1,
|
app.ged.register_event_handler('style-changed', ged.GUI1,
|
||||||
self._style_changed)
|
self._style_changed)
|
||||||
|
app.ged.register_event_handler('chatstate-received', ged.GUI1,
|
||||||
|
self._nec_chatstate_received)
|
||||||
|
|
Loading…
Add table
Reference in a new issue