Philipp Hörist pushed to branch master at gajim / gajim
Commits: c61bd656 by Philipp Hörist at 2018-11-20T14:32:01Z Simplify PEP module inits
- - - - - b74468b9 by Philipp Hörist at 2018-11-20T14:32:01Z Move chatstate css to default theme
This is needed so we can query the current chatstate colors in cellrenderers
- - - - - 15c3de2b by Philipp Hörist at 2018-11-20T14:32:01Z Add option to show chatstate in roster
- Preferences: Add options for display in banner, tab, roster - This makes the chatstate Plugin obsolete
- - - - - 8f9c596a by Philipp Hörist at 2018-11-20T15:10:11Z Windows: Remove cryptography fix
The package has been fixed in the mingw repos
- - - - -
18 changed files:
- gajim/chat_control.py - gajim/common/config.py - gajim/common/modules/atom.py - gajim/common/modules/pep.py - gajim/common/modules/user_activity.py - gajim/common/modules/user_avatar.py - gajim/common/modules/user_location.py - gajim/common/modules/user_mood.py - gajim/common/modules/user_nickname.py - gajim/common/modules/user_tune.py - gajim/data/gui/preferences_window.ui - gajim/data/style/default-dark.css - gajim/data/style/default.css - gajim/data/style/gajim.css - gajim/gtk/preferences.py - gajim/message_window.py - gajim/roster_window.py - win/_base.sh
Changes:
===================================== gajim/chat_control.py ===================================== @@ -669,19 +669,14 @@ class ChatControl(ChatControlBase): status_reduced = '' status_escaped = GLib.markup_escape_text(status_reduced)
- st = app.config.get('displayed_chat_state_notifications') if self.TYPE_ID == 'pm': cs = self.gc_contact.chatstate else: cs = app.contacts.get_combined_chatstate( self.account, self.contact.jid) - if cs and st in ('composing_only', 'all'): - if contact.show == 'offline': - chatstate = '' - elif st == 'all' or cs == 'composing': - chatstate = helpers.get_uf_chatstate(cs) - else: - chatstate = '' + + if app.config.get('show_chatstate_in_banner'): + chatstate = helpers.get_uf_chatstate(cs)
label_text = '<span>%s</span><span size="x-small" weight="light">%s %s</span>' \ % (name, acct_info, chatstate)
===================================== gajim/common/config.py ===================================== @@ -187,7 +187,6 @@ class Config: 'always_english_wiktionary': [opt_bool, 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.')], - '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], '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.')], @@ -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')], '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_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]]
__options_per_key = {
===================================== gajim/common/modules/atom.py ===================================== @@ -58,11 +58,6 @@ class Atom(AbstractPEPModule): store_publish = False _log = log
- def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): entry = item.getTag('entry', namespace=nbxmpp.NS_ATOM) if entry is None:
===================================== gajim/common/modules/pep.py ===================================== @@ -153,11 +153,11 @@ class AbstractPEPModule: store_publish = True _log = log
- def __init__(self, - con: ConnectionT, - account: str) -> None: - self._account = account + def __init__(self, con: ConnectionT) -> None: self._con = con + self._account = con.name + + self.handlers = [] # type: List[Tuple[Any, ...]]
self._stored_publish = None
===================================== gajim/common/modules/user_activity.py ===================================== @@ -30,9 +30,6 @@ class UserActivityData(AbstractPEPData):
type_ = PEPEventType.ACTIVITY
- def __init__(self, activity): - self.data = activity - def as_markup_text(self): pep = self.data activity = pep['activity'] @@ -62,11 +59,6 @@ class UserActivity(AbstractPEPModule): store_publish = True _log = log
- def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): activity_dict = {} activity_tag = item.getTag('activity', namespace=self.namespace)
===================================== gajim/common/modules/user_avatar.py ===================================== @@ -32,9 +32,6 @@ class UserAvatarData(AbstractPEPData):
type_ = PEPEventType.AVATAR
- def __init__(self, avatar): - self.data = avatar -
class UserAvatar(AbstractPEPModule):
@@ -44,11 +41,6 @@ class UserAvatar(AbstractPEPModule): store_publish = False _log = log
- def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def get_pubsub_avatar(self, jid, item_id): log.info('Request: %s %s', jid, item_id) self._con.get_module('PubSub').send_pb_retrieve(
===================================== gajim/common/modules/user_location.py ===================================== @@ -30,11 +30,6 @@ class UserLocationData(AbstractPEPData):
type_ = PEPEventType.LOCATION
- def __init__(self, location): - # set_location plugin uses self._pep_specific_data - self._pep_specific_data = location - self.data = location - def as_markup_text(self): location = self.data location_string = '' @@ -58,11 +53,6 @@ class UserLocation(AbstractPEPModule): store_publish = True _log = log
- def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): location_dict = {} location_tag = item.getTag('geoloc', namespace=nbxmpp.NS_LOCATION)
===================================== gajim/common/modules/user_mood.py ===================================== @@ -37,9 +37,6 @@ class UserMoodData(AbstractPEPData):
type_ = PEPEventType.MOOD
- def __init__(self, mood: Optional[Dict[str, str]]) -> None: - self.data = mood - def as_markup_text(self) -> str: if self.data is None: return '' @@ -65,11 +62,6 @@ class UserMood(AbstractPEPModule): store_publish = True _log = log
- def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[Dict[str, str]]: mood_dict = {} mood_tag = item.getTag('mood', namespace=nbxmpp.NS_MOOD)
===================================== gajim/common/modules/user_nickname.py ===================================== @@ -36,9 +36,6 @@ class UserNicknameData(AbstractPEPData):
type_ = PEPEventType.NICKNAME
- def __init__(self, nickname: Optional[str]) -> None: - self.data = nickname - def get_nick(self) -> str: return self.data or ''
@@ -51,11 +48,6 @@ class UserNickname(AbstractPEPModule): store_publish = True _log = log
- def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[str]: nick = '' child = item.getTag('nick', namespace=nbxmpp.NS_NICK)
===================================== gajim/common/modules/user_tune.py ===================================== @@ -39,9 +39,6 @@ class UserTuneData(AbstractPEPData):
type_ = PEPEventType.TUNE
- def __init__(self, tune: Optional[Dict[str, str]]) -> None: - self.data = tune - def as_markup_text(self) -> str: if self.data is None: return '' @@ -72,11 +69,6 @@ class UserTune(AbstractPEPModule): store_publish = True _log = log
- def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[Dict[str, str]]: tune_dict = {} tune_tag = item.getTag('tune', namespace=self.namespace)
===================================== gajim/data/gui/preferences_window.ui ===================================== @@ -737,49 +737,107 @@ <property name="top_attach">0</property> </packing> </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </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">Chat Settings</property> + <property name="use_markup">True</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">0</property> + </packing> + </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="GtkLabel"> + <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">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="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="justify">right</property> - <property name="mnemonic_widget">displayed_chat_states_combobox</property> - <style> - <class name="dim-label"/> - </style> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_show_chatstate_in_tabs_toggled" swapped="no"/> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkComboBox" id="displayed_chat_states_combobox"> + <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">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> + <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="left_attach">1</property> - <property name="top_attach">1</property> + <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> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">5</property> - </packing> </child> </object> </child> @@ -787,8 +845,7 @@ <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Chat Settings</property> - <property name="use_markup">True</property> + <property name="label" translatable="yes">Chatstate</property> <style> <class name="bold"/> <class name="margin-top6"/> @@ -799,7 +856,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> </object>
===================================== gajim/data/style/default-dark.css ===================================== @@ -15,4 +15,16 @@ } .gajim-status-message { color: rgb(115, 210, 22) + } +.gajim-state-composing { + color: rgb(0, 139, 0) + } +.gajim-state-inactive { + color: rgb(158, 158, 158) + } +.gajim-state-gone { + color: rgb(128, 128, 128) + } +.gajim-state-paused { + color: rgb(0, 0, 205) } \ No newline at end of file
===================================== gajim/data/style/default.css ===================================== @@ -1 +1 @@ - .gajim-incoming-nickname { color: rgb(164, 0, 0) } .gajim-outgoing-nickname { color: rgb(52, 101, 164) } .gajim-outgoing-message-text { color: rgb(85, 87, 83) } .gajim-status-message { color: rgb(78, 154, 6) } .gajim-url { color: rgb(32, 74, 135) } .gajim-highlight-message { color: rgb(255, 128, 128) } .gajim-restored-message { color: rgb(85, 87, 83) } .gajim-roster-disconnected { background: rgb(171 ,97 ,97) } .gajim-roster-connected { background: rgb(173, 195, 198) } \ No newline at end of file + .gajim-incoming-nickname { color: rgb(164, 0, 0) } .gajim-outgoing-nickname { color: rgb(52, 101, 164) } .gajim-outgoing-message-text { color: rgb(85, 87, 83) } .gajim-status-message { color: rgb(78, 154, 6) } .gajim-url { color: rgb(32, 74, 135) } .gajim-highlight-message { color: rgb(255, 128, 128) } .gajim-restored-message { color: rgb(85, 87, 83) } .gajim-roster-disconnected { background: rgb(171 ,97 ,97) } .gajim-roster-connected { background: rgb(173, 195, 198) } .gajim-state-composing { color: rgb(0, 139, 0) } .gajim-state-inactive { color: rgb(158, 158, 158) } .gajim-state-gone { color: rgb(128, 128, 128) } .gajim-state-paused { color: rgb(0, 0, 205) } \ No newline at end of file
===================================== gajim/data/style/gajim.css ===================================== @@ -1,17 +1,5 @@ /* Gajim Application CSS File */
-.gajim-state-composing { - color: rgb(0, 139, 0) - } -.gajim-state-inactive { - color: rgb(158, 158, 158) - } -.gajim-state-gone { - color: rgb(128, 128, 128) - } -.gajim-state-paused { - color: rgb(0, 0, 205) - } .gajim-msg-correcting text { background: rgb(238, 232, 170) }
===================================== gajim/gtk/preferences.py ===================================== @@ -157,13 +157,14 @@ class Preferences(Gtk.ApplicationWindow): self._ui.print_status_in_muc_combobox.set_active(2)
# Displayed chat state notifications - st = app.config.get('displayed_chat_state_notifications') - if st == 'all': - self._ui.displayed_chat_states_combobox.set_active(0) - elif st == 'composing_only': - self._ui.displayed_chat_states_combobox.set_active(1) - else: # disabled - self._ui.displayed_chat_states_combobox.set_active(2) + st = app.config.get('show_chatstate_in_tabs') + self._ui.show_chatstate_in_tabs.set_active(st) + + st = app.config.get('show_chatstate_in_roster') + self._ui.show_chatstate_in_roster.set_active(st) + + st = app.config.get('show_chatstate_in_banner') + self._ui.show_chatstate_in_banner.set_active(st)
### Notifications tab ### ## Visual Notifications @@ -612,15 +613,14 @@ class Preferences(Gtk.ApplicationWindow): else: # in_and_out app.config.set('print_status_in_muc', 'in_and_out')
- def on_displayed_chat_states_combobox_changed(self, widget): - active = widget.get_active() - if active == 0: # all - app.config.set('displayed_chat_state_notifications', 'all') - elif active == 1: # only composing - app.config.set('displayed_chat_state_notifications', - 'composing_only') - else: # disabled - app.config.set('displayed_chat_state_notifications', 'disabled') + def on_show_chatstate_in_tabs_toggled(self, widget): + self.on_checkbutton_toggled(widget, 'show_chatstate_in_tabs') + + def on_show_chatstate_in_roster_toggled(self, widget): + self.on_checkbutton_toggled(widget, 'show_chatstate_in_roster') + + def on_show_chatstate_in_banner_toggled(self, widget): + self.on_checkbutton_toggled(widget, 'show_chatstate_in_banner')
### Notifications tab ### def on_systray_combobox_changed(self, widget):
===================================== gajim/message_window.py ===================================== @@ -652,7 +652,9 @@ class MessageWindow: if isinstance(ctrl, ChatControl): tab_label_str = ctrl.get_tab_label() # 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: tab_label_str, color = ctrl.get_tab_label(chatstate) # Set Label Color
===================================== gajim/roster_window.py ===================================== @@ -4639,6 +4639,11 @@ class RosterWindow:
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): self.change_roster_style(None)
@@ -4741,17 +4746,22 @@ class RosterWindow: return jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] + color = None if type_ == 'groupchat': - ctrl = app.interface.minimized_controls[account].get(jid, - None) + ctrl = app.interface.minimized_controls[account].get(jid, None) if ctrl and ctrl.attention_flag: color = app.css_config.get_value( '.state_muc_directed_msg_color', StyleAttr.COLOR) - renderer.set_property('foreground', color) - if not color: - color = app.css_config.get_value('.gajim-contact-row', StyleAttr.COLOR) - renderer.set_property('foreground', color) + elif app.config.get('show_chatstate_in_roster'): + chatstate = app.contacts.get_combined_chatstate(account, jid) + if chatstate not in (None, 'active'): + 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) desc = app.css_config.get_font('.gajim-contact-row') @@ -5886,3 +5896,5 @@ class RosterWindow: self._nec_blocking) app.ged.register_event_handler('style-changed', ged.GUI1, self._style_changed) + app.ged.register_event_handler('chatstate-received', ged.GUI1, + self._nec_chatstate_received)
===================================== win/_base.sh ===================================== @@ -75,11 +75,6 @@ function install_deps { https://gajim.org/downloads/snap/win/build/mingw-w64-%22$%7BARCH%7D%22-glib2... build_pacman --noconfirm -U "${BUILD_ROOT}"/mingw-w64-"${ARCH}"-glib2-2.56.2-1-any.pkg.tar.xz
- # Fix broken cryptography package - curl -o "${BUILD_ROOT}"/mingw-w64-"${ARCH}"-python3-cryptography-2.3.1-1-any.pkg.tar.xz \ - https://gajim.org/downloads/snap/win/build/mingw-w64-%22$%7BARCH%7D%22-pytho... - build_pacman --noconfirm -U "${BUILD_ROOT}"/mingw-w64-"${ARCH}"-python3-cryptography-2.3.1-1-any.pkg.tar.xz - build_pacman --noconfirm -S mingw-w64-"${ARCH}"-gtk3 mingw-w64-"${ARCH}"-"${PYTHON_ID}" \ mingw-w64-"${ARCH}"-"${PYTHON_ID}"-gobject \ mingw-w64-"${ARCH}"-"${PYTHON_ID}"-pip \
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/9d8b56bc0fa9770e05f8cd5d3dfa0bb375...