print timestamp as invisible in history window when we don't want to see it so we can search for it. See #3939

This commit is contained in:
Yann Leboulanger 2016-04-17 20:31:19 +02:00
parent 7c2c4cd0ac
commit e585c579cb
1 changed files with 9 additions and 2 deletions

View File

@ -74,6 +74,7 @@ class HistoryWindow:
scrolledwindow.add(self.history_textview.tv)
self.history_buffer = self.history_textview.tv.get_buffer()
self.history_buffer.create_tag('highlight', background = 'yellow')
self.history_buffer.create_tag('invisible', invisible=True)
self.checkbutton = xml.get_object('log_history_checkbutton')
self.checkbutton.connect('toggled',
self.on_log_history_checkbutton_toggled)
@ -429,6 +430,12 @@ class HistoryWindow:
tim = time.strftime('%X ', time.localtime(float(tim)))
buf.insert_with_tags_by_name(end_iter, tim + '\n',
'time_sometimes')
else: # don't print time. So we print it as invisible to be able to
# search for it
timestamp_str = gajim.config.get('time_stamp')
timestamp_str = helpers.from_one_line(timestamp_str)
tim = time.strftime(timestamp_str, time.localtime(float(tim)))
buf.insert_with_tags_by_name(end_iter, tim, 'invisible')
tag_name = ''
tag_msg = ''
@ -605,8 +612,8 @@ class HistoryWindow:
timestamp_str = gajim.config.get('time_stamp')
timestamp_str = helpers.from_one_line(timestamp_str)
tim = time.strftime(timestamp_str, local_time)
result = start_iter.forward_search(tim, Gtk.TextSearchFlags.VISIBLE_ONLY,
None)
result = start_iter.forward_search(tim, Gtk.TextSearchFlags.TEXT_ONLY,
None)
if result is not None:
match_start_iter, match_end_iter = result
match_start_iter.backward_char() # include '[' or other character before time