|
1
|
|
-# -*- coding:utf-8 -*-
|
|
2
|
|
-## src/history_window.py
|
|
3
|
|
-##
|
|
4
|
|
-## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
|
5
|
|
-## Copyright (C) 2005 Vincent Hanquez <tab AT snarc.org>
|
|
6
|
|
-## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
|
7
|
|
-## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
|
|
8
|
|
-## Travis Shirk <travis AT pobox.com>
|
|
9
|
|
-## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
|
10
|
|
-## Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
|
|
11
|
|
-## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
|
|
12
|
|
-##
|
|
13
|
|
-## This file is part of Gajim.
|
|
14
|
|
-##
|
|
15
|
|
-## Gajim is free software; you can redistribute it and/or modify
|
|
16
|
|
-## it under the terms of the GNU General Public License as published
|
|
17
|
|
-## by the Free Software Foundation; version 3 only.
|
|
18
|
|
-##
|
|
19
|
|
-## Gajim is distributed in the hope that it will be useful,
|
|
20
|
|
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
|
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
|
-## GNU General Public License for more details.
|
|
23
|
|
-##
|
|
24
|
|
-## You should have received a copy of the GNU General Public License
|
|
25
|
|
-## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
26
|
|
-##
|
|
|
1
|
+# Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
2
|
+# Copyright (C) 2005 Vincent Hanquez <tab AT snarc.org>
|
|
|
3
|
+# Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
|
|
4
|
+# Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
|
|
|
5
|
+# Travis Shirk <travis AT pobox.com>
|
|
|
6
|
+# Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
7
|
+# Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
|
|
|
8
|
+# Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
|
|
|
9
|
+#
|
|
|
10
|
+# This file is part of Gajim.
|
|
|
11
|
+#
|
|
|
12
|
+# Gajim is free software; you can redistribute it and/or modify
|
|
|
13
|
+# it under the terms of the GNU General Public License as published
|
|
|
14
|
+# by the Free Software Foundation; version 3 only.
|
|
|
15
|
+#
|
|
|
16
|
+# Gajim is distributed in the hope that it will be useful,
|
|
|
17
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
18
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
19
|
+# GNU General Public License for more details.
|
|
|
20
|
+#
|
|
|
21
|
+# You should have received a copy of the GNU General Public License
|
|
|
22
|
+# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
27
|
23
|
|
|
28
|
|
-from gi.repository import Gtk
|
|
29
|
|
-from gi.repository import Gdk
|
|
30
|
|
-from gi.repository import GLib
|
|
31
|
24
|
import time
|
|
32
|
25
|
import datetime
|
|
33
|
|
-
|
|
34
|
26
|
from enum import IntEnum, unique
|
|
35
|
27
|
|
|
36
|
|
-from gajim import gtkgui_helpers
|
|
|
28
|
+from gi.repository import Gtk
|
|
|
29
|
+from gi.repository import Gdk
|
|
|
30
|
+from gi.repository import GLib
|
|
|
31
|
+
|
|
37
|
32
|
from gajim import conversation_textview
|
|
38
|
33
|
from gajim.gtk import ErrorDialog
|
|
39
|
|
-
|
|
|
34
|
+from gajim.gtk import util
|
|
|
35
|
+from gajim.gtk.util import python_month, gtk_month
|
|
40
|
36
|
from gajim.common import app
|
|
41
|
37
|
from gajim.common import helpers
|
|
42
|
38
|
from gajim.common import exceptions
|
|
43
|
|
-
|
|
44
|
39
|
from gajim.common.const import ShowConstant, KindConstant
|
|
45
|
40
|
|
|
|
41
|
+
|
|
46
|
42
|
@unique
|
|
47
|
43
|
class InfoColumn(IntEnum):
|
|
48
|
44
|
'''Completion dict'''
|
| ... |
... |
@@ -51,6 +47,7 @@ class InfoColumn(IntEnum): |
|
51
|
47
|
NAME = 2
|
|
52
|
48
|
COMPLETION = 3
|
|
53
|
49
|
|
|
|
50
|
+
|
|
54
|
51
|
@unique
|
|
55
|
52
|
class Column(IntEnum):
|
|
56
|
53
|
LOG_JID = 0
|
| ... |
... |
@@ -60,13 +57,14 @@ class Column(IntEnum): |
|
60
|
57
|
TIME = 4
|
|
61
|
58
|
LOG_LINE_ID = 5
|
|
62
|
59
|
|
|
|
60
|
+
|
|
63
|
61
|
class HistoryWindow:
|
|
64
|
62
|
"""
|
|
65
|
63
|
Class for browsing logs of conversations with contacts
|
|
66
|
64
|
"""
|
|
67
|
65
|
|
|
68
|
66
|
def __init__(self, jid=None, account=None):
|
|
69
|
|
- xml = gtkgui_helpers.get_gtk_builder('history_window.ui')
|
|
|
67
|
+ xml = util.get_builder('history_window.ui')
|
|
70
|
68
|
self.window = xml.get_object('history_window')
|
|
71
|
69
|
self.window.set_application(app.app)
|
|
72
|
70
|
self.calendar = xml.get_object('calendar')
|
| ... |
... |
@@ -76,7 +74,7 @@ class HistoryWindow: |
|
76
|
74
|
self.button_last_day = xml.get_object('button_last_day')
|
|
77
|
75
|
scrolledwindow = xml.get_object('scrolledwindow')
|
|
78
|
76
|
self.history_textview = conversation_textview.ConversationTextview(
|
|
79
|
|
- account, used_in_history_window = True)
|
|
|
77
|
+ account, used_in_history_window=True)
|
|
80
|
78
|
scrolledwindow.add(self.history_textview.tv)
|
|
81
|
79
|
self.history_buffer = self.history_textview.tv.get_buffer()
|
|
82
|
80
|
self.history_buffer.create_tag('highlight', background='yellow')
|
| ... |
... |
@@ -102,7 +100,8 @@ class HistoryWindow: |
|
102
|
100
|
renderer = Gtk.CellRendererText()
|
|
103
|
101
|
col.pack_start(renderer, True)
|
|
104
|
102
|
col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
|
|
105
|
|
- col.set_sort_column_id(Column.CONTACT_NAME) # user can click this header and sort
|
|
|
103
|
+ # user can click this header and sort
|
|
|
104
|
+ col.set_sort_column_id(Column.CONTACT_NAME)
|
|
106
|
105
|
col.set_resizable(True)
|
|
107
|
106
|
|
|
108
|
107
|
col = Gtk.TreeViewColumn(_('Date'))
|
| ... |
... |
@@ -110,7 +109,8 @@ class HistoryWindow: |
|
110
|
109
|
renderer = Gtk.CellRendererText()
|
|
111
|
110
|
col.pack_start(renderer, True)
|
|
112
|
111
|
col.add_attribute(renderer, 'text', Column.UNIXTIME)
|
|
113
|
|
- col.set_sort_column_id(Column.UNIXTIME) # user can click this header and sort
|
|
|
112
|
+ # user can click this header and sort
|
|
|
113
|
+ col.set_sort_column_id(Column.UNIXTIME)
|
|
114
|
114
|
col.set_resizable(True)
|
|
115
|
115
|
|
|
116
|
116
|
col = Gtk.TreeViewColumn(_('Message'))
|
| ... |
... |
@@ -120,10 +120,10 @@ class HistoryWindow: |
|
120
|
120
|
col.add_attribute(renderer, 'text', Column.MESSAGE)
|
|
121
|
121
|
col.set_resizable(True)
|
|
122
|
122
|
|
|
123
|
|
- self.jid = None # The history we are currently viewing
|
|
|
123
|
+ self.jid = None # The history we are currently viewing
|
|
124
|
124
|
self.account = account
|
|
125
|
125
|
self.completion_dict = {}
|
|
126
|
|
- self.accounts_seen_online = [] # Update dict when new accounts connect
|
|
|
126
|
+ self.accounts_seen_online = [] # Update dict when new accounts connect
|
|
127
|
127
|
self.jids_to_search = []
|
|
128
|
128
|
|
|
129
|
129
|
# This will load history too
|
| ... |
... |
@@ -135,12 +135,12 @@ class HistoryWindow: |
|
135
|
135
|
else:
|
|
136
|
136
|
self._load_history(None)
|
|
137
|
137
|
|
|
138
|
|
- gtkgui_helpers.resize_window(self.window,
|
|
139
|
|
- app.config.get('history_window_width'),
|
|
140
|
|
- app.config.get('history_window_height'))
|
|
141
|
|
- gtkgui_helpers.move_window(self.window,
|
|
142
|
|
- app.config.get('history_window_x-position'),
|
|
143
|
|
- app.config.get('history_window_y-position'))
|
|
|
138
|
+ util.resize_window(self.window,
|
|
|
139
|
+ app.config.get('history_window_width'),
|
|
|
140
|
+ app.config.get('history_window_height'))
|
|
|
141
|
+ util.move_window(self.window,
|
|
|
142
|
+ app.config.get('history_window_x-position'),
|
|
|
143
|
+ app.config.get('history_window_y-position'))
|
|
144
|
144
|
|
|
145
|
145
|
xml.connect_signals(self)
|
|
146
|
146
|
self.window.show_all()
|
| ... |
... |
@@ -161,7 +161,8 @@ class HistoryWindow: |
|
161
|
161
|
{key : (jid, account, nick_name, full_completion_name}
|
|
162
|
162
|
This is a generator and does pseudo-threading via idle_add().
|
|
163
|
163
|
"""
|
|
164
|
|
- liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry.get_child())
|
|
|
164
|
+ liststore = util.get_completion_liststore(
|
|
|
165
|
+ self.jid_entry.get_child())
|
|
165
|
166
|
liststore.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
|
166
|
167
|
self.jid_entry.get_child().get_completion().connect(
|
|
167
|
168
|
'match-selected', self.on_jid_entry_match_selected)
|
| ... |
... |
@@ -174,12 +175,14 @@ class HistoryWindow: |
|
174
|
175
|
|
|
175
|
176
|
self.accounts_seen_online = list(app.contacts.get_accounts())
|
|
176
|
177
|
|
|
177
|
|
- # Enhance contacts of online accounts with contact. Needed for mapping below
|
|
|
178
|
+ # Enhance contacts of online accounts with contact.
|
|
|
179
|
+ # Needed for mapping below
|
|
178
|
180
|
for account in self.accounts_seen_online:
|
|
179
|
|
- completion_dict.update(helpers.get_contact_dict_for_account(account))
|
|
|
181
|
+ completion_dict.update(
|
|
|
182
|
+ helpers.get_contact_dict_for_account(account))
|
|
180
|
183
|
|
|
181
|
|
- muc_active_icon = gtkgui_helpers.get_iconset_name_for('muc-active')
|
|
182
|
|
- online_icon = gtkgui_helpers.get_iconset_name_for('online')
|
|
|
184
|
+ muc_active_icon = util.get_iconset_name_for('muc-active')
|
|
|
185
|
+ online_icon = util.get_iconset_name_for('online')
|
|
183
|
186
|
|
|
184
|
187
|
keys = list(completion_dict.keys())
|
|
185
|
188
|
# Move the actual jid at first so we load history faster
|
| ... |
... |
@@ -209,8 +212,8 @@ class HistoryWindow: |
|
209
|
212
|
|
|
210
|
213
|
info_acc = self._get_account_for_jid(info_jid)
|
|
211
|
214
|
|
|
212
|
|
- if app.logger.jid_is_room_jid(completed) or\
|
|
213
|
|
- app.logger.jid_is_from_pm(completed):
|
|
|
215
|
+ if (app.logger.jid_is_room_jid(completed) or
|
|
|
216
|
+ app.logger.jid_is_from_pm(completed)):
|
|
214
|
217
|
icon = muc_active_icon
|
|
215
|
218
|
if app.logger.jid_is_from_pm(completed):
|
|
216
|
219
|
# It's PM. Make it easier to find
|
| ... |
... |
@@ -226,16 +229,16 @@ class HistoryWindow: |
|
226
|
229
|
if len(completed) > 70:
|
|
227
|
230
|
completed = completed[:70] + '[\u2026]'
|
|
228
|
231
|
liststore.append((icon, completed))
|
|
229
|
|
- self.completion_dict[key] = (info_jid, info_acc, info_name,
|
|
230
|
|
- info_completion)
|
|
231
|
|
- self.completion_dict[completed] = (info_jid, info_acc,
|
|
232
|
|
- info_name, info_completion)
|
|
|
232
|
+ self.completion_dict[key] = (
|
|
|
233
|
+ info_jid, info_acc, info_name, info_completion)
|
|
|
234
|
+ self.completion_dict[completed] = (
|
|
|
235
|
+ info_jid, info_acc, info_name, info_completion)
|
|
233
|
236
|
if completed2:
|
|
234
|
237
|
if len(completed2) > 70:
|
|
235
|
238
|
completed2 = completed2[:70] + '[\u2026]'
|
|
236
|
239
|
liststore.append((icon, completed2))
|
|
237
|
|
- self.completion_dict[completed2] = (info_jid, info_acc,
|
|
238
|
|
- info_name, info_completion2)
|
|
|
240
|
+ self.completion_dict[completed2] = (
|
|
|
241
|
+ info_jid, info_acc, info_name, info_completion2)
|
|
239
|
242
|
if key == actual_jid:
|
|
240
|
243
|
self._load_history(info_jid, self.account or info_acc)
|
|
241
|
244
|
yield True
|
| ... |
... |
@@ -295,7 +298,7 @@ class HistoryWindow: |
|
295
|
298
|
Load history for the given jid/name and show it
|
|
296
|
299
|
"""
|
|
297
|
300
|
if jid_or_name and jid_or_name in self.completion_dict:
|
|
298
|
|
- # a full qualified jid or a contact name was entered
|
|
|
301
|
+ # a full qualified jid or a contact name was entered
|
|
299
|
302
|
info_jid, info_account, info_name, info_completion = self.completion_dict[jid_or_name]
|
|
300
|
303
|
self.jids_to_search = [info_jid]
|
|
301
|
304
|
self.jid = info_jid
|
| ... |
... |
@@ -311,22 +314,22 @@ class HistoryWindow: |
|
311
|
314
|
self.checkbutton.set_sensitive(False)
|
|
312
|
315
|
else:
|
|
313
|
316
|
# Are log disabled for account ?
|
|
314
|
|
- if self.account in app.config.get_per('accounts', self.account,
|
|
315
|
|
- 'no_log_for').split(' '):
|
|
|
317
|
+ if self.account in app.config.get_per(
|
|
|
318
|
+ 'accounts', self.account, 'no_log_for').split(' '):
|
|
316
|
319
|
self.checkbutton.set_active(False)
|
|
317
|
320
|
self.checkbutton.set_sensitive(False)
|
|
318
|
321
|
else:
|
|
319
|
322
|
# Are log disabled for jid ?
|
|
320
|
323
|
log = True
|
|
321
|
|
- if self.jid in app.config.get_per('accounts', self.account,
|
|
322
|
|
- 'no_log_for').split(' '):
|
|
|
324
|
+ if self.jid in app.config.get_per(
|
|
|
325
|
+ 'accounts', self.account, 'no_log_for').split(' '):
|
|
323
|
326
|
log = False
|
|
324
|
327
|
self.checkbutton.set_active(log)
|
|
325
|
328
|
self.checkbutton.set_sensitive(True)
|
|
326
|
329
|
|
|
327
|
330
|
self.jids_to_search = [info_jid]
|
|
328
|
331
|
|
|
329
|
|
- # Get first/last date we have logs with contact (for log navigation)
|
|
|
332
|
+ # Get first/last date we have logs with contact
|
|
330
|
333
|
self.first_log = app.logger.get_first_date_that_has_logs(
|
|
331
|
334
|
self.account, self.jid)
|
|
332
|
335
|
self.first_day = self._get_date_from_timestamp(self.first_log)
|
| ... |
... |
@@ -336,9 +339,8 @@ class HistoryWindow: |
|
336
|
339
|
|
|
337
|
340
|
# Select logs for last date we have logs with contact
|
|
338
|
341
|
self.search_menu_button.set_sensitive(True)
|
|
339
|
|
- gtk_month = gtkgui_helpers.make_python_month_gtk_month(
|
|
340
|
|
- self.last_day.month)
|
|
341
|
|
- self.calendar.select_month(gtk_month, self.last_day.year)
|
|
|
342
|
+ month = gtk_month(self.last_day.month)
|
|
|
343
|
+ self.calendar.select_month(month, self.last_day.year)
|
|
342
|
344
|
self.calendar.select_day(self.last_day.day)
|
|
343
|
345
|
|
|
344
|
346
|
self.button_previous_day.set_sensitive(True)
|
| ... |
... |
@@ -351,12 +353,13 @@ class HistoryWindow: |
|
351
|
353
|
|
|
352
|
354
|
self.jid_entry.get_child().set_text(info_completion)
|
|
353
|
355
|
|
|
354
|
|
- else: # neither a valid jid, nor an existing contact name was entered
|
|
|
356
|
+ else:
|
|
|
357
|
+ # neither a valid jid, nor an existing contact name was entered
|
|
355
|
358
|
# we have got nothing to show or to search in
|
|
356
|
359
|
self.jid = None
|
|
357
|
360
|
self.account = None
|
|
358
|
361
|
|
|
359
|
|
- self.history_buffer.set_text('') # clear the buffer
|
|
|
362
|
+ self.history_buffer.set_text('') # clear the buffer
|
|
360
|
363
|
self.search_entry.set_sensitive(False)
|
|
361
|
364
|
|
|
362
|
365
|
self.checkbutton.set_sensitive(False)
|
| ... |
... |
@@ -372,26 +375,27 @@ class HistoryWindow: |
|
372
|
375
|
def on_calendar_day_selected(self, widget):
|
|
373
|
376
|
if not self.jid:
|
|
374
|
377
|
return
|
|
375
|
|
- year, month, day = self.calendar.get_date() # integers
|
|
376
|
|
- month = gtkgui_helpers.make_gtk_month_python_month(month)
|
|
|
378
|
+ year, month, day = self.calendar.get_date() # integers
|
|
|
379
|
+ month = python_month(month)
|
|
377
|
380
|
date_str = datetime.date(year, month, day).strftime('%x')
|
|
378
|
381
|
self.date_label.set_text(date_str)
|
|
379
|
382
|
self._load_conversation(year, month, day)
|
|
380
|
383
|
|
|
381
|
384
|
def on_calendar_month_changed(self, widget):
|
|
382
|
385
|
"""
|
|
383
|
|
- Ask for days in this month, if they have logs it bolds them (marks them)
|
|
|
386
|
+ Ask for days in this month, if they have logs it bolds them
|
|
|
387
|
+ (marks them)
|
|
384
|
388
|
"""
|
|
385
|
389
|
if not self.jid:
|
|
386
|
390
|
return
|
|
387
|
|
- year, month, day = widget.get_date() # integers
|
|
|
391
|
+ year, month, day = widget.get_date() # integers
|
|
388
|
392
|
if year < 1900:
|
|
389
|
393
|
widget.select_month(0, 1900)
|
|
390
|
394
|
widget.select_day(1)
|
|
391
|
395
|
return
|
|
392
|
396
|
|
|
393
|
397
|
widget.clear_marks()
|
|
394
|
|
- month = gtkgui_helpers.make_gtk_month_python_month(month)
|
|
|
398
|
+ month = python_month(month)
|
|
395
|
399
|
|
|
396
|
400
|
try:
|
|
397
|
401
|
log_days = app.logger.get_days_with_logs(
|
| ... |
... |
@@ -413,17 +417,16 @@ class HistoryWindow: |
|
413
|
417
|
def _change_date(self, widget):
|
|
414
|
418
|
# Get day selected in calendar
|
|
415
|
419
|
y, m, d = self.calendar.get_date()
|
|
416
|
|
- py_m = gtkgui_helpers.make_gtk_month_python_month(m)
|
|
|
420
|
+ py_m = python_month(m)
|
|
417
|
421
|
_date = datetime.datetime(y, py_m, d)
|
|
418
|
422
|
|
|
419
|
423
|
if widget is self.button_first_day:
|
|
420
|
|
- gtk_m = gtkgui_helpers.make_python_month_gtk_month(
|
|
421
|
|
- self.first_day.month)
|
|
|
424
|
+ gtk_m = gtk_month(self.first_day.month)
|
|
422
|
425
|
self.calendar.select_month(gtk_m, self.first_day.year)
|
|
423
|
426
|
self.calendar.select_day(self.first_day.day)
|
|
424
|
427
|
return
|
|
425
|
428
|
elif widget is self.button_last_day:
|
|
426
|
|
- gtk_m = gtkgui_helpers.make_python_month_gtk_month(
|
|
|
429
|
+ gtk_m = gtk_month(
|
|
427
|
430
|
self.last_day.month)
|
|
428
|
431
|
self.calendar.select_month(gtk_m, self.last_day.year)
|
|
429
|
432
|
self.calendar.select_day(self.last_day.day)
|
| ... |
... |
@@ -453,8 +456,8 @@ class HistoryWindow: |
|
453
|
456
|
ErrorDialog(_('Disk Error'), str(e))
|
|
454
|
457
|
return
|
|
455
|
458
|
|
|
456
|
|
- gtk_month = gtkgui_helpers.make_python_month_gtk_month(_date.month)
|
|
457
|
|
- self.calendar.select_month(gtk_month, _date.year)
|
|
|
459
|
+ gtk_m = gtk_month(_date.month)
|
|
|
460
|
+ self.calendar.select_month(gtk_m, _date.year)
|
|
458
|
461
|
self.calendar.select_day(_date.day)
|
|
459
|
462
|
|
|
460
|
463
|
def _get_string_show_from_constant_int(self, show):
|
| ... |
... |
@@ -521,13 +524,13 @@ class HistoryWindow: |
|
521
|
524
|
buf.insert(end_iter, tim)
|
|
522
|
525
|
elif app.config.get('print_time') == 'sometimes':
|
|
523
|
526
|
every_foo_seconds = 60 * app.config.get(
|
|
524
|
|
- 'print_ichat_every_foo_minutes')
|
|
|
527
|
+ 'print_ichat_every_foo_minutes')
|
|
525
|
528
|
seconds_passed = tim - self.last_time_printout
|
|
526
|
529
|
if seconds_passed > every_foo_seconds:
|
|
527
|
530
|
self.last_time_printout = tim
|
|
528
|
531
|
tim = time.strftime('%X ', time.localtime(float(tim)))
|
|
529
|
|
- buf.insert_with_tags_by_name(end_iter, tim + '\n',
|
|
530
|
|
- 'time_sometimes')
|
|
|
532
|
+ buf.insert_with_tags_by_name(
|
|
|
533
|
+ end_iter, tim + '\n', 'time_sometimes')
|
|
531
|
534
|
|
|
532
|
535
|
tag_name = ''
|
|
533
|
536
|
tag_msg = ''
|
| ... |
... |
@@ -536,11 +539,13 @@ class HistoryWindow: |
|
536
|
539
|
|
|
537
|
540
|
if kind == KindConstant.GC_MSG:
|
|
538
|
541
|
tag_name = 'incoming'
|
|
539
|
|
- elif kind in (KindConstant.SINGLE_MSG_RECV, KindConstant.CHAT_MSG_RECV):
|
|
|
542
|
+ elif kind in (KindConstant.SINGLE_MSG_RECV,
|
|
|
543
|
+ KindConstant.CHAT_MSG_RECV):
|
|
540
|
544
|
contact_name = self.completion_dict[self.jid][InfoColumn.NAME]
|
|
541
|
545
|
tag_name = 'incoming'
|
|
542
|
546
|
tag_msg = 'incomingtxt'
|
|
543
|
|
- elif kind in (KindConstant.SINGLE_MSG_SENT, KindConstant.CHAT_MSG_SENT):
|
|
|
547
|
+ elif kind in (KindConstant.SINGLE_MSG_SENT,
|
|
|
548
|
+ KindConstant.CHAT_MSG_SENT):
|
|
544
|
549
|
if self.account:
|
|
545
|
550
|
contact_name = app.nicks[self.account]
|
|
546
|
551
|
else:
|
| ... |
... |
@@ -553,26 +558,29 @@ class HistoryWindow: |
|
553
|
558
|
elif kind == KindConstant.GCSTATUS:
|
|
554
|
559
|
# message here (if not None) is status message
|
|
555
|
560
|
if message:
|
|
556
|
|
- message = _('%(nick)s is now %(status)s: %(status_msg)s') %\
|
|
557
|
|
- {'nick': contact_name, 'status': helpers.get_uf_show(show),
|
|
558
|
|
- 'status_msg': message }
|
|
|
561
|
+ message = _('%(nick)s is now %(status)s: %(status_msg)s') % {
|
|
|
562
|
+ 'nick': contact_name,
|
|
|
563
|
+ 'status': helpers.get_uf_show(show),
|
|
|
564
|
+ 'status_msg': message}
|
|
559
|
565
|
else:
|
|
560
|
|
- message = _('%(nick)s is now %(status)s') % {'nick': contact_name,
|
|
561
|
|
- 'status': helpers.get_uf_show(show) }
|
|
|
566
|
+ message = _('%(nick)s is now %(status)s') % {
|
|
|
567
|
+ 'nick': contact_name,
|
|
|
568
|
+ 'status': helpers.get_uf_show(show) }
|
|
562
|
569
|
tag_msg = 'status'
|
|
563
|
|
- else: # 'status'
|
|
|
570
|
+ else: # 'status'
|
|
564
|
571
|
# message here (if not None) is status message
|
|
565
|
|
- if show is None: # it means error
|
|
|
572
|
+ if show is None: # it means error
|
|
566
|
573
|
if message:
|
|
567
|
574
|
message = _('Error: %s') % message
|
|
568
|
575
|
else:
|
|
569
|
576
|
message = _('Error')
|
|
570
|
577
|
elif message:
|
|
571
|
|
- message = _('Status is now: %(status)s: %(status_msg)s') % \
|
|
572
|
|
- {'status': helpers.get_uf_show(show), 'status_msg': message}
|
|
|
578
|
+ message = _('Status is now: %(status)s: %(status_msg)s') % {
|
|
|
579
|
+ 'status': helpers.get_uf_show(show),
|
|
|
580
|
+ 'status_msg': message}
|
|
573
|
581
|
else:
|
|
574
|
|
- message = _('Status is now: %(status)s') % { 'status':
|
|
575
|
|
- helpers.get_uf_show(show) }
|
|
|
582
|
+ message = _('Status is now: %(status)s') % {
|
|
|
583
|
+ 'status': helpers.get_uf_show(show)}
|
|
576
|
584
|
tag_msg = 'status'
|
|
577
|
585
|
|
|
578
|
586
|
if message.startswith('/me ') or message.startswith('/me\n'):
|
| ... |
... |
@@ -586,11 +594,11 @@ class HistoryWindow: |
|
586
|
594
|
before_str = helpers.from_one_line(before_str)
|
|
587
|
595
|
after_str = app.config.get('after_nickname')
|
|
588
|
596
|
after_str = helpers.from_one_line(after_str)
|
|
589
|
|
- format = before_str + contact_name + after_str + ' '
|
|
|
597
|
+ format_ = before_str + contact_name + after_str + ' '
|
|
590
|
598
|
if tag_name:
|
|
591
|
|
- buf.insert_with_tags_by_name(end_iter, format, tag_name)
|
|
|
599
|
+ buf.insert_with_tags_by_name(end_iter, format_, tag_name)
|
|
592
|
600
|
else:
|
|
593
|
|
- buf.insert(end_iter, format)
|
|
|
601
|
+ buf.insert(end_iter, format_)
|
|
594
|
602
|
if subject:
|
|
595
|
603
|
message = _('Subject: %s\n') % subject + message
|
|
596
|
604
|
xhtml = None
|
| ... |
... |
@@ -598,11 +606,17 @@ class HistoryWindow: |
|
598
|
606
|
xhtml = message
|
|
599
|
607
|
|
|
600
|
608
|
if tag_msg:
|
|
601
|
|
- self.history_textview.print_real_text(message, [tag_msg],
|
|
602
|
|
- name=contact_name, xhtml=xhtml, additional_data=additional_data)
|
|
|
609
|
+ self.history_textview.print_real_text(
|
|
|
610
|
+ message, [tag_msg],
|
|
|
611
|
+ name=contact_name,
|
|
|
612
|
+ xhtml=xhtml,
|
|
|
613
|
+ additional_data=additional_data)
|
|
603
|
614
|
else:
|
|
604
|
|
- self.history_textview.print_real_text(message, name=contact_name,
|
|
605
|
|
- xhtml=xhtml, additional_data=additional_data)
|
|
|
615
|
+ self.history_textview.print_real_text(
|
|
|
616
|
+ message,
|
|
|
617
|
+ name=contact_name,
|
|
|
618
|
+ xhtml=xhtml,
|
|
|
619
|
+ additional_data=additional_data)
|
|
606
|
620
|
self.history_textview.print_real_text('\n', text_tags=['eol'])
|
|
607
|
621
|
|
|
608
|
622
|
def on_search_complete_history_toggled(self, widget):
|
| ... |
... |
@@ -634,23 +648,23 @@ class HistoryWindow: |
|
634
|
648
|
for jid in self.jids_to_search:
|
|
635
|
649
|
account = self.completion_dict[jid][InfoColumn.ACCOUNT]
|
|
636
|
650
|
if account is None:
|
|
637
|
|
- # We do not know an account. This can only happen if the contact is offine,
|
|
638
|
|
- # or if we browse a groupchat history. The account is not needed, a dummy can
|
|
639
|
|
- # be set.
|
|
640
|
|
- # This may leed to wrong self nick in the displayed history (Uggh!)
|
|
|
651
|
+ # We do not know an account. This can only happen if
|
|
|
652
|
+ # the contact is offine, or if we browse a groupchat history.
|
|
|
653
|
+ # The account is not needed, a dummy can be set.
|
|
|
654
|
+ # This may leed to wrong self nick in the displayed history
|
|
641
|
655
|
account = list(app.contacts.get_accounts())[0]
|
|
642
|
656
|
|
|
643
|
657
|
date = None
|
|
644
|
658
|
if self.search_in_date.get_active():
|
|
645
|
|
- year, month, day = self.calendar.get_date() # integers
|
|
646
|
|
- month = gtkgui_helpers.make_gtk_month_python_month(month)
|
|
|
659
|
+ year, month, day = self.calendar.get_date() # integers
|
|
|
660
|
+ month = python_month(month)
|
|
647
|
661
|
date = datetime.datetime(year, month, day)
|
|
648
|
662
|
|
|
649
|
663
|
show_status = self.show_status_checkbutton.get_active()
|
|
650
|
664
|
|
|
651
|
665
|
results = app.logger.search_log(account, jid, text, date)
|
|
652
|
666
|
result_found = False
|
|
653
|
|
- #FIXME:
|
|
|
667
|
+ # FIXME:
|
|
654
|
668
|
# add "subject: | message: " in message column if kind is single
|
|
655
|
669
|
# also do we need show at all? (we do not search on subject)
|
|
656
|
670
|
for row in results:
|
| ... |
... |
@@ -660,7 +674,7 @@ class HistoryWindow: |
|
660
|
674
|
|
|
661
|
675
|
contact_name = row.contact_name
|
|
662
|
676
|
if not contact_name:
|
|
663
|
|
- if row.kind == KindConstant.CHAT_MSG_SENT: # it's us! :)
|
|
|
677
|
+ if row.kind == KindConstant.CHAT_MSG_SENT:
|
|
664
|
678
|
contact_name = app.nicks[account]
|
|
665
|
679
|
else:
|
|
666
|
680
|
contact_name = self.completion_dict[jid][InfoColumn.NAME]
|
| ... |
... |
@@ -685,7 +699,7 @@ class HistoryWindow: |
|
685
|
699
|
|
|
686
|
700
|
# get currently selected date
|
|
687
|
701
|
cur_year, cur_month, cur_day = self.calendar.get_date()
|
|
688
|
|
- cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
|
|
|
702
|
+ cur_month = python_month(cur_month)
|
|
689
|
703
|
model, paths = self.results_treeview.get_selection().get_selected_rows()
|
|
690
|
704
|
|
|
691
|
705
|
if not paths:
|
| ... |
... |
@@ -696,7 +710,7 @@ class HistoryWindow: |
|
696
|
710
|
tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
|
|
697
|
711
|
year = tim[0]
|
|
698
|
712
|
gtk_month = tim[1]
|
|
699
|
|
- month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
|
|
|
713
|
+ month = gtk_month(gtk_month)
|
|
700
|
714
|
day = tim[2]
|
|
701
|
715
|
|
|
702
|
716
|
# switch to belonging logfile if necessary
|
| ... |
... |
@@ -740,25 +754,27 @@ class HistoryWindow: |
|
740
|
754
|
match_end = match_start.copy()
|
|
741
|
755
|
match_end.forward_to_tag_toggle(self.history_buffer.eol_tag)
|
|
742
|
756
|
|
|
743
|
|
- self.history_buffer.apply_tag_by_name('highlight', match_start, match_end)
|
|
|
757
|
+ self.history_buffer.apply_tag_by_name(
|
|
|
758
|
+ 'highlight', match_start, match_end)
|
|
744
|
759
|
mark = self.history_buffer.create_mark('match', match_start, True)
|
|
745
|
|
- GLib.idle_add(self.history_textview.tv.scroll_to_mark, mark, 0, True, 0.0, 0.5)
|
|
|
760
|
+ GLib.idle_add(
|
|
|
761
|
+ self.history_textview.tv.scroll_to_mark, mark, 0, True, 0.0, 0.5)
|
|
746
|
762
|
|
|
747
|
763
|
def on_log_history_checkbutton_toggled(self, widget, *args):
|
|
748
|
764
|
# log conversation history?
|
|
749
|
765
|
oldlog = True
|
|
750
|
|
- no_log_for = app.config.get_per('accounts', self.account,
|
|
751
|
|
- 'no_log_for').split()
|
|
|
766
|
+ no_log_for = app.config.get_per(
|
|
|
767
|
+ 'accounts', self.account, 'no_log_for').split()
|
|
752
|
768
|
if self.jid in no_log_for:
|
|
753
|
769
|
oldlog = False
|
|
754
|
770
|
log = widget.get_active()
|
|
755
|
|
- if not log and not self.jid in no_log_for:
|
|
|
771
|
+ if not log and self.jid not in no_log_for:
|
|
756
|
772
|
no_log_for.append(self.jid)
|
|
757
|
773
|
if log and self.jid in no_log_for:
|
|
758
|
774
|
no_log_for.remove(self.jid)
|
|
759
|
775
|
if oldlog != log:
|
|
760
|
|
- app.config.set_per('accounts', self.account, 'no_log_for',
|
|
761
|
|
- ' '.join(no_log_for))
|
|
|
776
|
+ app.config.set_per(
|
|
|
777
|
+ 'accounts', self.account, 'no_log_for', ' '.join(no_log_for))
|
|
762
|
778
|
|
|
763
|
779
|
def on_show_status_checkbutton_toggled(self, widget):
|
|
764
|
780
|
# reload logs
|
| ... |
... |
@@ -773,8 +789,8 @@ class HistoryWindow: |
|
773
|
789
|
# Update dict to not only show bare jid
|
|
774
|
790
|
GLib.idle_add(next, self._fill_completion_dict())
|
|
775
|
791
|
else:
|
|
776
|
|
- # Only in that case because it's called by self._fill_completion_dict()
|
|
777
|
|
- # otherwise
|
|
|
792
|
+ # Only in that case because it's called by
|
|
|
793
|
+ # self._fill_completion_dict() otherwise
|
|
778
|
794
|
self._load_history(jid, account)
|
|
779
|
795
|
self.results_window.set_property('visible', False)
|
|
780
|
796
|
|