Philipp Hörist pushed to branch master at gajim / gajim
Commits: 39b4b8fc by Philipp Hörist at 2019-10-20T17:34:45Z Remove Fuzzy Clock
I consider this feature bloat
- - - - - 19b2911b by Philipp Hörist at 2019-10-20T17:37:33Z Rename method
show_receipt_icon() -> show_receipt()
- - - - - 8b6a1d1c by Philipp Hörist at 2019-10-20T19:54:36Z Receipts: Simplify event code
- - - - - fddcd2b3 by Philipp Hörist at 2019-10-20T19:55:43Z Receipts: use build_receipt()
- - - - -
5 changed files:
- gajim/chat_control.py - gajim/common/config.py - − gajim/common/fuzzyclock.py - gajim/common/modules/receipts.py - gajim/conversation_textview.py
Changes:
===================================== gajim/chat_control.py ===================================== @@ -941,13 +941,9 @@ class ChatControl(ChatControlBase): else: self.old_msg_kind = kind
+ @event_filter(['account', 'jid']) def _receipt_received(self, event): - if event.conn.name != self.account: - return - if event.jid != self.contact.jid: - return - - self.conv_textview.show_receipt_icon(event.receipt_id) + self.conv_textview.show_receipt(event.receipt_id)
def get_tab_label(self): unread = ''
===================================== gajim/common/config.py ===================================== @@ -112,7 +112,6 @@ class Config: 'ignore_incoming_xhtml': [opt_bool, False, ], 'speller_language': [opt_str, '', _('Language used for spell checking.')], 'print_time': [opt_str, 'always', _(''always' - print time for every message.\n'sometimes' - print time every print_ichat_every_foo_minutes minute.\n'never' - never print time.')], - 'print_time_fuzzy': [opt_int, 0, _('Print time in chats using Fuzzy Clock. Value of fuzziness from 1 to 4, or 0 to disable Fuzzy Clock. 1 is the most precise clock, 4 the least precise one. This is used only if 'print_time' is 'sometimes'.')], 'emoticons_theme': [opt_str, 'noto-emoticons', '', True], 'ascii_emoticons': [opt_bool, True, _('When enabled, ASCII emojis will be converted to graphical emojis.'), True], 'ascii_formatting': [opt_bool, True,
===================================== gajim/common/fuzzyclock.py deleted ===================================== @@ -1,95 +0,0 @@ -# Copyright (C) 2006 Christoph Neuroth <delmonico AT gmx.net> -# Copyright (C) 2006-2014 Yann Leboulanger <asterix AT lagaule.org> -# Copyright (C) 2007 Jean-Marie Traissard <jim AT lapin.org> -# Copyright (C) 2009 Benjamin Richter <br AT waldteufel-online.net> -# -# This file is part of Gajim. -# -# Gajim is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Gajim is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Gajim. If not, see http://www.gnu.org/licenses/. - -""" -Python class to show a "fuzzy clock". -Homepage of the original: http://home.gna.org/fuzzyclock/ -Project Page of the original: http://gna.org/projects/fuzzyclock - -The class is based on a port from PHP code by -Henrique Recidive <henrique at recidive.com> which was -in turn based on the Fuzzy Clock Applet of Frerich Raabe (KDE). -So most of the credit goes to this guys, thanks :-) -""" - -from gajim.common.i18n import _ - - -class FuzzyClock: - HOUR_NAMES = [ - _('twelve'), _('one'), _('two'), _('three'), _('four'), - _('five'), _('six'), _('seven'), _('eight'), _('nine'), _('ten'), - _('eleven') - ] - - # Strings to use for the output. %(0)s will be replaced with - # the preceding hour (e.g. "x PAST %(0)s"), %(1)s with the coming hour - # (e.g. "x TO %(0)s") - FUZZY_TIME = [ - _("%(0)s o'clock"), - _('five past %(0)s'), - _('ten past %(0)s'), - _('quarter past %(0)s'), - _('twenty past %(0)s'), - _('twenty five past %(0)s'), - _('half past %(0)s'), - _('twenty five to %(1)s'), - _('twenty to %(1)s'), - _('quarter to %(1)s'), - _('ten to %(1)s'), - _('five to %(1)s'), - _("%(1)s o'clock") - ] - - FUZZY_DAYTIME = [ - _('Night'), - _('Early morning'), - _('Morning'), - _('Almost noon'), - _('Noon'), - _('Afternoon'), - _('Evening'), - _('Late evening'), - _('Night') - ] - - FUZZY_WEEK = [ - _('Start of week'), - _('Middle of week'), - _('Middle of week'), - _('Middle of week'), - _('End of week'), - _('Weekend!'), - _('Weekend!') - ] - - def fuzzy_time(self, fuzzyness, now): - if fuzzyness in (1, 2): - if fuzzyness == 1: - sector = int(round(now.tm_min / 5.0)) - else: - sector = int(round(now.tm_min / 15.0)) * 3 - - return self.FUZZY_TIME[sector] % { - '0': self.HOUR_NAMES[now.tm_hour % 12], - '1': self.HOUR_NAMES[(now.tm_hour + 1) % 12]} - - if fuzzyness == 3: - return self.FUZZY_DAYTIME[int(round(now.tm_hour / 3.0))] - return self.FUZZY_WEEK[now.tm_wday]
===================================== gajim/common/modules/receipts.py ===================================== @@ -16,6 +16,7 @@
import nbxmpp from nbxmpp.structs import StanzaHandler +from nbxmpp.modules.receipts import build_receipt
from gajim.common import app from gajim.common.nec import NetworkEvent @@ -55,7 +56,7 @@ class Receipts(BaseModule): if contact is None: return self._log.info('Send receipt: %s', properties.jid) - self._con.connection.send(stanza.buildReceipt()) + self._con.connection.send(build_receipt(stanza)) return
if properties.receipt.is_received: @@ -65,13 +66,13 @@ class Receipts(BaseModule):
jid = properties.jid if not properties.is_muc_pm: - jid = properties.jid.getBare() + jid.setBare()
app.nec.push_incoming_event( NetworkEvent('receipt-received', - conn=self._con, - receipt_id=properties.receipt.id, - jid=jid)) + account=self._account, + jid=jid, + receipt_id=properties.receipt.id))
raise nbxmpp.NodeProcessed
===================================== gajim/conversation_textview.py ===================================== @@ -41,7 +41,6 @@ from gajim.common import helpers from gajim.common import i18n from gajim.common.i18n import _ from gajim.common.helpers import AdditionalDataDict -from gajim.common.fuzzyclock import FuzzyClock from gajim.common.const import StyleAttr from gajim.common.const import Trust from gajim.common.helpers import to_user_string @@ -188,7 +187,6 @@ class ConversationTextview(GObject.GObject): self.line = 0 self._message_list = [] self.corrected_text_list = {} - self.fc = FuzzyClock()
# no need to inherit TextView, use it as atrribute is safer self.tv = HtmlTextView(account) @@ -403,7 +401,7 @@ class ConversationTextview(GObject.GObject):
return index, end_mark, old_txt
- def show_receipt_icon(self, id_): + def show_receipt(self, id_): line = self._get_message_line(id_) if line is None: return @@ -1198,11 +1196,7 @@ class ConversationTextview(GObject.GObject): seconds_passed = tim - self.last_time_printout if seconds_passed > every_foo_seconds: self.last_time_printout = tim - if app.config.get('print_time_fuzzy') > 0: - tim_format = self.fc.fuzzy_time( - app.config.get('print_time_fuzzy'), local_tim) - else: - tim_format = self.get_time_to_show(local_tim, direction_mark) + tim_format = self.get_time_to_show(local_tim, direction_mark) buffer_.insert_with_tags_by_name(iter_, tim_format + '\n', 'time_sometimes')
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/e5ac5e9bd20c6ad118b8ef67a24e054c9d...