Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
2b755d2d
by Bronko at 2020-01-25T19:59:41+01:00
4 changed files:
- gajim/common/config.py
- gajim/common/optparser.py
- gajim/conversation_textview.py
- gajim/history_manager.py
Changes:
| ... | ... | @@ -152,7 +152,7 @@ class Config: |
| 152 | 152 |
'history_window_x-position': [opt_int, 0],
|
| 153 | 153 |
'history_window_y-position': [opt_int, 0],
|
| 154 | 154 |
'latest_disco_addresses': [opt_str, ''],
|
| 155 |
- '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).')],
|
|
| 155 |
+ '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).')],
|
|
| 156 | 156 |
'before_nickname': [opt_str, '', _('Characters that are printed before the nickname in conversations.')],
|
| 157 | 157 |
'after_nickname': [opt_str, ':', _('Characters that are printed after the nickname in conversations.')],
|
| 158 | 158 |
'change_roster_title': [opt_bool, True, _('If enabled, Gajim will add * and [n] in contact list window title.')],
|
| ... | ... | @@ -146,6 +146,8 @@ class OptionsParser: |
| 146 | 146 |
self.update_config_to_016105()
|
| 147 | 147 |
if old < [0, 98, 3] and new >= [0, 98, 3]:
|
| 148 | 148 |
self.update_config_to_0983()
|
| 149 |
+ if old < [1, 1, 93] and new >= [1, 1, 93]:
|
|
| 150 |
+ self.update_config_to_1193()
|
|
| 149 | 151 |
|
| 150 | 152 |
app.config.set('version', new_version)
|
| 151 | 153 |
|
| ... | ... | @@ -212,3 +214,9 @@ class OptionsParser: |
| 212 | 214 |
elif password == "libsecret:":
|
| 213 | 215 |
app.config.set_per('accounts', account, 'password', '')
|
| 214 | 216 |
app.config.set('version', '0.98.3')
|
| 217 |
+ |
|
| 218 |
+ def update_config_to_1193(self):
|
|
| 219 |
+ # add date to time_stamp, if user did not set a custom time_stamp
|
|
| 220 |
+ if self.old_values['time_stamp'] == '[%X] ':
|
|
| 221 |
+ app.config.set('time_stamp', '%x | %X ')
|
|
| 222 |
+ app.config.set('version', '1.1.93')
|
| ... | ... | @@ -24,11 +24,9 @@ |
| 24 | 24 |
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
| 25 | 25 |
|
| 26 | 26 |
import time
|
| 27 |
-import os
|
|
| 28 | 27 |
import queue
|
| 29 | 28 |
import urllib
|
| 30 | 29 |
import logging
|
| 31 |
-from calendar import timegm
|
|
| 32 | 30 |
|
| 33 | 31 |
from gi.repository import Gtk
|
| 34 | 32 |
from gi.repository import Pango
|
| ... | ... | @@ -1084,34 +1082,11 @@ class ConversationTextview(GObject.GObject): |
| 1084 | 1082 |
|
| 1085 | 1083 |
self.line += 1
|
| 1086 | 1084 |
|
| 1087 |
- def get_time_to_show(self, tim, direction_mark=''):
|
|
| 1085 |
+ def get_time_to_show(self, tim):
|
|
| 1088 | 1086 |
"""
|
| 1089 |
- Get the time, with the day before if needed and return it. It DOESN'T
|
|
| 1090 |
- format a fuzzy time
|
|
| 1087 |
+ Format the time according to config setting 'time_stamp'
|
|
| 1091 | 1088 |
"""
|
| 1092 |
- format_ = ''
|
|
| 1093 |
- # get difference in days since epoch (86400 = 24*3600)
|
|
| 1094 |
- # number of days since epoch for current time (in GMT) -
|
|
| 1095 |
- # number of days since epoch for message (in GMT)
|
|
| 1096 |
- diff_day = int(int(timegm(time.localtime())) / 86400 -\
|
|
| 1097 |
- int(timegm(tim)) / 86400)
|
|
| 1098 |
- if diff_day == 0.0:
|
|
| 1099 |
- day_str = ''
|
|
| 1100 |
- else:
|
|
| 1101 |
- #%i is day in year (1-365)
|
|
| 1102 |
- day_str = i18n.ngettext('Yesterday',
|
|
| 1103 |
- '%(nb_days)i days ago', diff_day, {'nb_days': diff_day},
|
|
| 1104 |
- {'nb_days': diff_day})
|
|
| 1105 |
- if day_str:
|
|
| 1106 |
- # strftime Windows bug has problems with Unicode
|
|
| 1107 |
- # see: http://bugs.python.org/issue8304
|
|
| 1108 |
- if os.name != 'nt':
|
|
| 1109 |
- format_ += i18n.direction_mark + day_str + direction_mark + ' '
|
|
| 1110 |
- else:
|
|
| 1111 |
- format_ += day_str + ' '
|
|
| 1112 |
- timestamp_str = app.config.get('time_stamp')
|
|
| 1113 |
- timestamp_str = helpers.from_one_line(timestamp_str)
|
|
| 1114 |
- format_ += timestamp_str
|
|
| 1089 |
+ format_ = helpers.from_one_line(app.config.get('time_stamp'))
|
|
| 1115 | 1090 |
tim_format = time.strftime(format_, tim)
|
| 1116 | 1091 |
return tim_format
|
| 1117 | 1092 |
|
| ... | ... | @@ -1188,7 +1163,7 @@ class ConversationTextview(GObject.GObject): |
| 1188 | 1163 |
current_print_time = app.config.get('print_time')
|
| 1189 | 1164 |
|
| 1190 | 1165 |
if current_print_time == 'always':
|
| 1191 |
- timestamp_str = self.get_time_to_show(local_tim, direction_mark)
|
|
| 1166 |
+ timestamp_str = self.get_time_to_show(local_tim)
|
|
| 1192 | 1167 |
timestamp = time.strftime(timestamp_str, local_tim)
|
| 1193 | 1168 |
timestamp = direction_mark + timestamp + direction_mark
|
| 1194 | 1169 |
if other_tags_for_time:
|
| ... | ... | @@ -1202,7 +1177,7 @@ class ConversationTextview(GObject.GObject): |
| 1202 | 1177 |
seconds_passed = tim - self.last_time_printout
|
| 1203 | 1178 |
if seconds_passed > every_foo_seconds:
|
| 1204 | 1179 |
self.last_time_printout = tim
|
| 1205 |
- tim_format = self.get_time_to_show(local_tim, direction_mark)
|
|
| 1180 |
+ tim_format = self.get_time_to_show(local_tim)
|
|
| 1206 | 1181 |
buffer_.insert_with_tags_by_name(iter_, tim_format + '\n',
|
| 1207 | 1182 |
'time_sometimes')
|
| 1208 | 1183 |
|
| ... | ... | @@ -364,6 +364,7 @@ class HistoryManager: |
| 364 | 364 |
self.nickname_col_for_logs.set_visible(False)
|
| 365 | 365 |
self.subject_col_for_logs.set_visible(True)
|
| 366 | 366 |
|
| 367 |
+ format_ = helpers.from_one_line(app.config.get('time_stamp'))
|
|
| 367 | 368 |
for row in results:
|
| 368 | 369 |
# exposed in UI (TreeViewColumns) are only
|
| 369 | 370 |
# time, message, subject, nickname
|
| ... | ... | @@ -372,7 +373,7 @@ class HistoryManager: |
| 372 | 373 |
log_line_id, jid_id, time_, kind, message, subject, nickname, \
|
| 373 | 374 |
show = row
|
| 374 | 375 |
try:
|
| 375 |
- time_ = time.strftime('%x', time.localtime(float(time_)))
|
|
| 376 |
+ time_ = time.strftime(format_, time.localtime(float(time_)))
|
|
| 376 | 377 |
except ValueError:
|
| 377 | 378 |
pass
|
| 378 | 379 |
else:
|
| ... | ... | @@ -420,6 +421,7 @@ class HistoryManager: |
| 420 | 421 |
''', (like_sql, like_sql))
|
| 421 | 422 |
|
| 422 | 423 |
results = self.cur.fetchall()
|
| 424 |
+ format_ = helpers.from_one_line(app.config.get('time_stamp'))
|
|
| 423 | 425 |
for row in results:
|
| 424 | 426 |
# exposed in UI (TreeViewColumns) are only
|
| 425 | 427 |
# JID, time, message, subject, nickname
|
| ... | ... | @@ -427,7 +429,7 @@ class HistoryManager: |
| 427 | 429 |
# log_line_id, jid (from jid_id), time, message, subject, nickname
|
| 428 | 430 |
log_line_id, jid_id, time_, message, subject, nickname = row
|
| 429 | 431 |
try:
|
| 430 |
- time_ = time.strftime('%x', time.localtime(float(time_)))
|
|
| 432 |
+ time_ = time.strftime(format_, time.localtime(float(time_)))
|
|
| 431 | 433 |
except ValueError:
|
| 432 | 434 |
pass
|
| 433 | 435 |
else:
|