Philipp Hörist pushed to branch master at gajim / gajim
Commits: 2b755d2d by Bronko at 2020-01-25T19:59:41+01:00 ConversationsTextview: Remove fuzzy timestamps
- Change default timestamp to include date
closes #9272
- - - - -
4 changed files:
- gajim/common/config.py - gajim/common/optparser.py - gajim/conversation_textview.py - gajim/history_manager.py
Changes:
===================================== gajim/common/config.py ===================================== @@ -152,7 +152,7 @@ class Config: 'history_window_x-position': [opt_int, 0], 'history_window_y-position': [opt_int, 0], 'latest_disco_addresses': [opt_str, ''], - 'time_stamp': [opt_str, '[%X] ', _('This option lets you customize the timestamp that is printed in conversation. For example '[%H:%M] ' will show '[hour:minute] '. See python doc on strftime for full documentation (https://docs.python.org/3/library/time.html).')], + 'time_stamp': [opt_str, '%x | %X ', _('This option lets you customize the timestamp that is printed in conversation. For example '[%H:%M] ' will show '[hour:minute] '. See python doc on strftime for full documentation (https://docs.python.org/3/library/time.html#time.strftime).')], 'before_nickname': [opt_str, '', _('Characters that are printed before the nickname in conversations.')], 'after_nickname': [opt_str, ':', _('Characters that are printed after the nickname in conversations.')], 'change_roster_title': [opt_bool, True, _('If enabled, Gajim will add * and [n] in contact list window title.')],
===================================== gajim/common/optparser.py ===================================== @@ -146,6 +146,8 @@ class OptionsParser: self.update_config_to_016105() if old < [0, 98, 3] and new >= [0, 98, 3]: self.update_config_to_0983() + if old < [1, 1, 93] and new >= [1, 1, 93]: + self.update_config_to_1193()
app.config.set('version', new_version)
@@ -212,3 +214,9 @@ class OptionsParser: elif password == "libsecret:": app.config.set_per('accounts', account, 'password', '') app.config.set('version', '0.98.3') + + def update_config_to_1193(self): + # add date to time_stamp, if user did not set a custom time_stamp + if self.old_values['time_stamp'] == '[%X] ': + app.config.set('time_stamp', '%x | %X ') + app.config.set('version', '1.1.93')
===================================== gajim/conversation_textview.py ===================================== @@ -24,11 +24,9 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
import time -import os import queue import urllib import logging -from calendar import timegm
from gi.repository import Gtk from gi.repository import Pango @@ -1084,34 +1082,11 @@ class ConversationTextview(GObject.GObject):
self.line += 1
- def get_time_to_show(self, tim, direction_mark=''): + def get_time_to_show(self, tim): """ - Get the time, with the day before if needed and return it. It DOESN'T - format a fuzzy time + Format the time according to config setting 'time_stamp' """ - format_ = '' - # get difference in days since epoch (86400 = 24*3600) - # number of days since epoch for current time (in GMT) - - # number of days since epoch for message (in GMT) - diff_day = int(int(timegm(time.localtime())) / 86400 -\ - int(timegm(tim)) / 86400) - if diff_day == 0.0: - day_str = '' - else: - #%i is day in year (1-365) - day_str = i18n.ngettext('Yesterday', - '%(nb_days)i days ago', diff_day, {'nb_days': diff_day}, - {'nb_days': diff_day}) - if day_str: - # strftime Windows bug has problems with Unicode - # see: http://bugs.python.org/issue8304 - if os.name != 'nt': - format_ += i18n.direction_mark + day_str + direction_mark + ' ' - else: - format_ += day_str + ' ' - timestamp_str = app.config.get('time_stamp') - timestamp_str = helpers.from_one_line(timestamp_str) - format_ += timestamp_str + format_ = helpers.from_one_line(app.config.get('time_stamp')) tim_format = time.strftime(format_, tim) return tim_format
@@ -1188,7 +1163,7 @@ class ConversationTextview(GObject.GObject): current_print_time = app.config.get('print_time')
if current_print_time == 'always': - timestamp_str = self.get_time_to_show(local_tim, direction_mark) + timestamp_str = self.get_time_to_show(local_tim) timestamp = time.strftime(timestamp_str, local_tim) timestamp = direction_mark + timestamp + direction_mark if other_tags_for_time: @@ -1202,7 +1177,7 @@ class ConversationTextview(GObject.GObject): seconds_passed = tim - self.last_time_printout if seconds_passed > every_foo_seconds: self.last_time_printout = tim - tim_format = self.get_time_to_show(local_tim, direction_mark) + tim_format = self.get_time_to_show(local_tim) buffer_.insert_with_tags_by_name(iter_, tim_format + '\n', 'time_sometimes')
===================================== gajim/history_manager.py ===================================== @@ -364,6 +364,7 @@ class HistoryManager: self.nickname_col_for_logs.set_visible(False) self.subject_col_for_logs.set_visible(True)
+ format_ = helpers.from_one_line(app.config.get('time_stamp')) for row in results: # exposed in UI (TreeViewColumns) are only # time, message, subject, nickname @@ -372,7 +373,7 @@ class HistoryManager: log_line_id, jid_id, time_, kind, message, subject, nickname, \ show = row try: - time_ = time.strftime('%x', time.localtime(float(time_))) + time_ = time.strftime(format_, time.localtime(float(time_))) except ValueError: pass else: @@ -420,6 +421,7 @@ class HistoryManager: ''', (like_sql, like_sql))
results = self.cur.fetchall() + format_ = helpers.from_one_line(app.config.get('time_stamp')) for row in results: # exposed in UI (TreeViewColumns) are only # JID, time, message, subject, nickname @@ -427,7 +429,7 @@ class HistoryManager: # log_line_id, jid (from jid_id), time, message, subject, nickname log_line_id, jid_id, time_, message, subject, nickname = row try: - time_ = time.strftime('%x', time.localtime(float(time_))) + time_ = time.strftime(format_, time.localtime(float(time_))) except ValueError: pass else:
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/2b755d2ddbe36b17d1c462cadccb4a81f08...