Move history window into gtk folder
- fix some pep8 warnings
This commit is contained in:
parent
043e764896
commit
92af78f103
7 changed files with 156 additions and 134 deletions
|
@ -24,7 +24,6 @@ from gajim import dialogs
|
||||||
from gajim.gtk import shortcuts_window
|
from gajim.gtk import shortcuts_window
|
||||||
from gajim import accounts_window
|
from gajim import accounts_window
|
||||||
import gajim.plugins.gui
|
import gajim.plugins.gui
|
||||||
from gajim import history_window
|
|
||||||
from gajim import disco
|
from gajim import disco
|
||||||
from gajim.gtk.history_sync import HistorySyncAssistant
|
from gajim.gtk.history_sync import HistorySyncAssistant
|
||||||
from gajim.gtk.server_info import ServerInfoDialog
|
from gajim.gtk.server_info import ServerInfoDialog
|
||||||
|
@ -39,6 +38,7 @@ from gajim.gtk import PrivacyListsWindow
|
||||||
from gajim.gtk import ManageBookmarksWindow
|
from gajim.gtk import ManageBookmarksWindow
|
||||||
from gajim.gtk import FeaturesDialog
|
from gajim.gtk import FeaturesDialog
|
||||||
from gajim.gtk import AccountCreationWizard
|
from gajim.gtk import AccountCreationWizard
|
||||||
|
from gajim.gtk import HistoryWindow
|
||||||
|
|
||||||
|
|
||||||
# General Actions
|
# General Actions
|
||||||
|
@ -305,8 +305,7 @@ def on_history(action, param):
|
||||||
if 'logs' in interface.instances:
|
if 'logs' in interface.instances:
|
||||||
interface.instances['logs'].window.present()
|
interface.instances['logs'].window.present()
|
||||||
else:
|
else:
|
||||||
interface.instances['logs'] = history_window.\
|
interface.instances['logs'] = HistoryWindow()
|
||||||
HistoryWindow()
|
|
||||||
|
|
||||||
|
|
||||||
def on_open_event(action, param):
|
def on_open_event(action, param):
|
||||||
|
|
|
@ -38,7 +38,6 @@ from gi.repository import Gio
|
||||||
from gajim import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
from gajim import message_control
|
from gajim import message_control
|
||||||
from gajim.gtk import NonModalConfirmationDialog
|
from gajim.gtk import NonModalConfirmationDialog
|
||||||
from gajim import history_window
|
|
||||||
from gajim import notify
|
from gajim import notify
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -432,8 +431,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
app.interface.instances['logs'].window.present()
|
app.interface.instances['logs'].window.present()
|
||||||
app.interface.instances['logs'].open_history(jid, self.account)
|
app.interface.instances['logs'].open_history(jid, self.account)
|
||||||
else:
|
else:
|
||||||
app.interface.instances['logs'] = \
|
from gajim.gtk import HistoryWindow
|
||||||
history_window.HistoryWindow(jid, self.account)
|
app.interface.instances['logs'] = HistoryWindow(jid, self.account)
|
||||||
|
|
||||||
def change_encryption(self, action, param):
|
def change_encryption(self, action, param):
|
||||||
encryption = param.get_string()
|
encryption = param.get_string()
|
||||||
|
@ -1119,8 +1118,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
app.interface.instances['logs'].window.present()
|
app.interface.instances['logs'].window.present()
|
||||||
app.interface.instances['logs'].open_history(jid, self.account)
|
app.interface.instances['logs'].open_history(jid, self.account)
|
||||||
else:
|
else:
|
||||||
app.interface.instances['logs'] = \
|
from gajim.gtk import HistoryWindow
|
||||||
history_window.HistoryWindow(jid, self.account)
|
app.interface.instances['logs'] = HistoryWindow(jid, self.account)
|
||||||
|
|
||||||
def _on_send_file(self, action, param):
|
def _on_send_file(self, action, param):
|
||||||
# get file transfer preference
|
# get file transfer preference
|
||||||
|
|
|
@ -67,3 +67,4 @@ from gajim.gtk.profile import ProfileWindow
|
||||||
from gajim.gtk.features import FeaturesDialog
|
from gajim.gtk.features import FeaturesDialog
|
||||||
from gajim.gtk.account_wizard import AccountCreationWizard
|
from gajim.gtk.account_wizard import AccountCreationWizard
|
||||||
from gajim.gtk.service_registration import ServiceRegistration
|
from gajim.gtk.service_registration import ServiceRegistration
|
||||||
|
from gajim.gtk.history import HistoryWindow
|
||||||
|
|
|
@ -1,48 +1,44 @@
|
||||||
# -*- coding:utf-8 -*-
|
# Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
||||||
## src/history_window.py
|
# Copyright (C) 2005 Vincent Hanquez <tab AT snarc.org>
|
||||||
##
|
# Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
||||||
## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
# Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
|
||||||
## Copyright (C) 2005 Vincent Hanquez <tab AT snarc.org>
|
# Travis Shirk <travis AT pobox.com>
|
||||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
# Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
||||||
## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
|
# Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
|
||||||
## Travis Shirk <travis AT pobox.com>
|
# Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
|
||||||
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
#
|
||||||
## Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
|
# This file is part of Gajim.
|
||||||
## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
|
#
|
||||||
##
|
# Gajim is free software; you can redistribute it and/or modify
|
||||||
## This file is part of Gajim.
|
# it under the terms of the GNU General Public License as published
|
||||||
##
|
# by the Free Software Foundation; version 3 only.
|
||||||
## Gajim is free software; you can redistribute it and/or modify
|
#
|
||||||
## it under the terms of the GNU General Public License as published
|
# Gajim is distributed in the hope that it will be useful,
|
||||||
## by the Free Software Foundation; version 3 only.
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
##
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## Gajim is distributed in the hope that it will be useful,
|
# GNU General Public License for more details.
|
||||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# You should have received a copy of the GNU General Public License
|
||||||
## GNU General Public License for more details.
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
|
||||||
## You should have received a copy of the GNU General Public License
|
import time
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
import datetime
|
||||||
##
|
from enum import IntEnum, unique
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
import time
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from enum import IntEnum, unique
|
|
||||||
|
|
||||||
from gajim import gtkgui_helpers
|
|
||||||
from gajim import conversation_textview
|
from gajim import conversation_textview
|
||||||
from gajim.gtk import ErrorDialog
|
from gajim.gtk import ErrorDialog
|
||||||
|
from gajim.gtk import util
|
||||||
|
from gajim.gtk.util import python_month, gtk_month
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import helpers
|
from gajim.common import helpers
|
||||||
from gajim.common import exceptions
|
from gajim.common import exceptions
|
||||||
|
|
||||||
from gajim.common.const import ShowConstant, KindConstant
|
from gajim.common.const import ShowConstant, KindConstant
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class InfoColumn(IntEnum):
|
class InfoColumn(IntEnum):
|
||||||
'''Completion dict'''
|
'''Completion dict'''
|
||||||
|
@ -51,6 +47,7 @@ class InfoColumn(IntEnum):
|
||||||
NAME = 2
|
NAME = 2
|
||||||
COMPLETION = 3
|
COMPLETION = 3
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class Column(IntEnum):
|
class Column(IntEnum):
|
||||||
LOG_JID = 0
|
LOG_JID = 0
|
||||||
|
@ -60,13 +57,14 @@ class Column(IntEnum):
|
||||||
TIME = 4
|
TIME = 4
|
||||||
LOG_LINE_ID = 5
|
LOG_LINE_ID = 5
|
||||||
|
|
||||||
|
|
||||||
class HistoryWindow:
|
class HistoryWindow:
|
||||||
"""
|
"""
|
||||||
Class for browsing logs of conversations with contacts
|
Class for browsing logs of conversations with contacts
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, jid=None, account=None):
|
def __init__(self, jid=None, account=None):
|
||||||
xml = gtkgui_helpers.get_gtk_builder('history_window.ui')
|
xml = util.get_builder('history_window.ui')
|
||||||
self.window = xml.get_object('history_window')
|
self.window = xml.get_object('history_window')
|
||||||
self.window.set_application(app.app)
|
self.window.set_application(app.app)
|
||||||
self.calendar = xml.get_object('calendar')
|
self.calendar = xml.get_object('calendar')
|
||||||
|
@ -102,7 +100,8 @@ class HistoryWindow:
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
|
col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
|
||||||
col.set_sort_column_id(Column.CONTACT_NAME) # user can click this header and sort
|
# user can click this header and sort
|
||||||
|
col.set_sort_column_id(Column.CONTACT_NAME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
|
|
||||||
col = Gtk.TreeViewColumn(_('Date'))
|
col = Gtk.TreeViewColumn(_('Date'))
|
||||||
|
@ -110,7 +109,8 @@ class HistoryWindow:
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', Column.UNIXTIME)
|
col.add_attribute(renderer, 'text', Column.UNIXTIME)
|
||||||
col.set_sort_column_id(Column.UNIXTIME) # user can click this header and sort
|
# user can click this header and sort
|
||||||
|
col.set_sort_column_id(Column.UNIXTIME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
|
|
||||||
col = Gtk.TreeViewColumn(_('Message'))
|
col = Gtk.TreeViewColumn(_('Message'))
|
||||||
|
@ -135,10 +135,10 @@ class HistoryWindow:
|
||||||
else:
|
else:
|
||||||
self._load_history(None)
|
self._load_history(None)
|
||||||
|
|
||||||
gtkgui_helpers.resize_window(self.window,
|
util.resize_window(self.window,
|
||||||
app.config.get('history_window_width'),
|
app.config.get('history_window_width'),
|
||||||
app.config.get('history_window_height'))
|
app.config.get('history_window_height'))
|
||||||
gtkgui_helpers.move_window(self.window,
|
util.move_window(self.window,
|
||||||
app.config.get('history_window_x-position'),
|
app.config.get('history_window_x-position'),
|
||||||
app.config.get('history_window_y-position'))
|
app.config.get('history_window_y-position'))
|
||||||
|
|
||||||
|
@ -161,7 +161,8 @@ class HistoryWindow:
|
||||||
{key : (jid, account, nick_name, full_completion_name}
|
{key : (jid, account, nick_name, full_completion_name}
|
||||||
This is a generator and does pseudo-threading via idle_add().
|
This is a generator and does pseudo-threading via idle_add().
|
||||||
"""
|
"""
|
||||||
liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry.get_child())
|
liststore = util.get_completion_liststore(
|
||||||
|
self.jid_entry.get_child())
|
||||||
liststore.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
liststore.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||||
self.jid_entry.get_child().get_completion().connect(
|
self.jid_entry.get_child().get_completion().connect(
|
||||||
'match-selected', self.on_jid_entry_match_selected)
|
'match-selected', self.on_jid_entry_match_selected)
|
||||||
|
@ -174,12 +175,14 @@ class HistoryWindow:
|
||||||
|
|
||||||
self.accounts_seen_online = list(app.contacts.get_accounts())
|
self.accounts_seen_online = list(app.contacts.get_accounts())
|
||||||
|
|
||||||
# Enhance contacts of online accounts with contact. Needed for mapping below
|
# Enhance contacts of online accounts with contact.
|
||||||
|
# Needed for mapping below
|
||||||
for account in self.accounts_seen_online:
|
for account in self.accounts_seen_online:
|
||||||
completion_dict.update(helpers.get_contact_dict_for_account(account))
|
completion_dict.update(
|
||||||
|
helpers.get_contact_dict_for_account(account))
|
||||||
|
|
||||||
muc_active_icon = gtkgui_helpers.get_iconset_name_for('muc-active')
|
muc_active_icon = util.get_iconset_name_for('muc-active')
|
||||||
online_icon = gtkgui_helpers.get_iconset_name_for('online')
|
online_icon = util.get_iconset_name_for('online')
|
||||||
|
|
||||||
keys = list(completion_dict.keys())
|
keys = list(completion_dict.keys())
|
||||||
# Move the actual jid at first so we load history faster
|
# Move the actual jid at first so we load history faster
|
||||||
|
@ -209,8 +212,8 @@ class HistoryWindow:
|
||||||
|
|
||||||
info_acc = self._get_account_for_jid(info_jid)
|
info_acc = self._get_account_for_jid(info_jid)
|
||||||
|
|
||||||
if app.logger.jid_is_room_jid(completed) or\
|
if (app.logger.jid_is_room_jid(completed) or
|
||||||
app.logger.jid_is_from_pm(completed):
|
app.logger.jid_is_from_pm(completed)):
|
||||||
icon = muc_active_icon
|
icon = muc_active_icon
|
||||||
if app.logger.jid_is_from_pm(completed):
|
if app.logger.jid_is_from_pm(completed):
|
||||||
# It's PM. Make it easier to find
|
# It's PM. Make it easier to find
|
||||||
|
@ -226,16 +229,16 @@ class HistoryWindow:
|
||||||
if len(completed) > 70:
|
if len(completed) > 70:
|
||||||
completed = completed[:70] + '[\u2026]'
|
completed = completed[:70] + '[\u2026]'
|
||||||
liststore.append((icon, completed))
|
liststore.append((icon, completed))
|
||||||
self.completion_dict[key] = (info_jid, info_acc, info_name,
|
self.completion_dict[key] = (
|
||||||
info_completion)
|
info_jid, info_acc, info_name, info_completion)
|
||||||
self.completion_dict[completed] = (info_jid, info_acc,
|
self.completion_dict[completed] = (
|
||||||
info_name, info_completion)
|
info_jid, info_acc, info_name, info_completion)
|
||||||
if completed2:
|
if completed2:
|
||||||
if len(completed2) > 70:
|
if len(completed2) > 70:
|
||||||
completed2 = completed2[:70] + '[\u2026]'
|
completed2 = completed2[:70] + '[\u2026]'
|
||||||
liststore.append((icon, completed2))
|
liststore.append((icon, completed2))
|
||||||
self.completion_dict[completed2] = (info_jid, info_acc,
|
self.completion_dict[completed2] = (
|
||||||
info_name, info_completion2)
|
info_jid, info_acc, info_name, info_completion2)
|
||||||
if key == actual_jid:
|
if key == actual_jid:
|
||||||
self._load_history(info_jid, self.account or info_acc)
|
self._load_history(info_jid, self.account or info_acc)
|
||||||
yield True
|
yield True
|
||||||
|
@ -311,22 +314,22 @@ class HistoryWindow:
|
||||||
self.checkbutton.set_sensitive(False)
|
self.checkbutton.set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
# Are log disabled for account ?
|
# Are log disabled for account ?
|
||||||
if self.account in app.config.get_per('accounts', self.account,
|
if self.account in app.config.get_per(
|
||||||
'no_log_for').split(' '):
|
'accounts', self.account, 'no_log_for').split(' '):
|
||||||
self.checkbutton.set_active(False)
|
self.checkbutton.set_active(False)
|
||||||
self.checkbutton.set_sensitive(False)
|
self.checkbutton.set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
# Are log disabled for jid ?
|
# Are log disabled for jid ?
|
||||||
log = True
|
log = True
|
||||||
if self.jid in app.config.get_per('accounts', self.account,
|
if self.jid in app.config.get_per(
|
||||||
'no_log_for').split(' '):
|
'accounts', self.account, 'no_log_for').split(' '):
|
||||||
log = False
|
log = False
|
||||||
self.checkbutton.set_active(log)
|
self.checkbutton.set_active(log)
|
||||||
self.checkbutton.set_sensitive(True)
|
self.checkbutton.set_sensitive(True)
|
||||||
|
|
||||||
self.jids_to_search = [info_jid]
|
self.jids_to_search = [info_jid]
|
||||||
|
|
||||||
# Get first/last date we have logs with contact (for log navigation)
|
# Get first/last date we have logs with contact
|
||||||
self.first_log = app.logger.get_first_date_that_has_logs(
|
self.first_log = app.logger.get_first_date_that_has_logs(
|
||||||
self.account, self.jid)
|
self.account, self.jid)
|
||||||
self.first_day = self._get_date_from_timestamp(self.first_log)
|
self.first_day = self._get_date_from_timestamp(self.first_log)
|
||||||
|
@ -336,9 +339,8 @@ class HistoryWindow:
|
||||||
|
|
||||||
# Select logs for last date we have logs with contact
|
# Select logs for last date we have logs with contact
|
||||||
self.search_menu_button.set_sensitive(True)
|
self.search_menu_button.set_sensitive(True)
|
||||||
gtk_month = gtkgui_helpers.make_python_month_gtk_month(
|
month = gtk_month(self.last_day.month)
|
||||||
self.last_day.month)
|
self.calendar.select_month(month, self.last_day.year)
|
||||||
self.calendar.select_month(gtk_month, self.last_day.year)
|
|
||||||
self.calendar.select_day(self.last_day.day)
|
self.calendar.select_day(self.last_day.day)
|
||||||
|
|
||||||
self.button_previous_day.set_sensitive(True)
|
self.button_previous_day.set_sensitive(True)
|
||||||
|
@ -351,7 +353,8 @@ class HistoryWindow:
|
||||||
|
|
||||||
self.jid_entry.get_child().set_text(info_completion)
|
self.jid_entry.get_child().set_text(info_completion)
|
||||||
|
|
||||||
else: # neither a valid jid, nor an existing contact name was entered
|
else:
|
||||||
|
# neither a valid jid, nor an existing contact name was entered
|
||||||
# we have got nothing to show or to search in
|
# we have got nothing to show or to search in
|
||||||
self.jid = None
|
self.jid = None
|
||||||
self.account = None
|
self.account = None
|
||||||
|
@ -373,14 +376,15 @@ class HistoryWindow:
|
||||||
if not self.jid:
|
if not self.jid:
|
||||||
return
|
return
|
||||||
year, month, day = self.calendar.get_date() # integers
|
year, month, day = self.calendar.get_date() # integers
|
||||||
month = gtkgui_helpers.make_gtk_month_python_month(month)
|
month = python_month(month)
|
||||||
date_str = datetime.date(year, month, day).strftime('%x')
|
date_str = datetime.date(year, month, day).strftime('%x')
|
||||||
self.date_label.set_text(date_str)
|
self.date_label.set_text(date_str)
|
||||||
self._load_conversation(year, month, day)
|
self._load_conversation(year, month, day)
|
||||||
|
|
||||||
def on_calendar_month_changed(self, widget):
|
def on_calendar_month_changed(self, widget):
|
||||||
"""
|
"""
|
||||||
Ask for days in this month, if they have logs it bolds them (marks them)
|
Ask for days in this month, if they have logs it bolds them
|
||||||
|
(marks them)
|
||||||
"""
|
"""
|
||||||
if not self.jid:
|
if not self.jid:
|
||||||
return
|
return
|
||||||
|
@ -391,7 +395,7 @@ class HistoryWindow:
|
||||||
return
|
return
|
||||||
|
|
||||||
widget.clear_marks()
|
widget.clear_marks()
|
||||||
month = gtkgui_helpers.make_gtk_month_python_month(month)
|
month = python_month(month)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log_days = app.logger.get_days_with_logs(
|
log_days = app.logger.get_days_with_logs(
|
||||||
|
@ -413,17 +417,16 @@ class HistoryWindow:
|
||||||
def _change_date(self, widget):
|
def _change_date(self, widget):
|
||||||
# Get day selected in calendar
|
# Get day selected in calendar
|
||||||
y, m, d = self.calendar.get_date()
|
y, m, d = self.calendar.get_date()
|
||||||
py_m = gtkgui_helpers.make_gtk_month_python_month(m)
|
py_m = python_month(m)
|
||||||
_date = datetime.datetime(y, py_m, d)
|
_date = datetime.datetime(y, py_m, d)
|
||||||
|
|
||||||
if widget is self.button_first_day:
|
if widget is self.button_first_day:
|
||||||
gtk_m = gtkgui_helpers.make_python_month_gtk_month(
|
gtk_m = gtk_month(self.first_day.month)
|
||||||
self.first_day.month)
|
|
||||||
self.calendar.select_month(gtk_m, self.first_day.year)
|
self.calendar.select_month(gtk_m, self.first_day.year)
|
||||||
self.calendar.select_day(self.first_day.day)
|
self.calendar.select_day(self.first_day.day)
|
||||||
return
|
return
|
||||||
elif widget is self.button_last_day:
|
elif widget is self.button_last_day:
|
||||||
gtk_m = gtkgui_helpers.make_python_month_gtk_month(
|
gtk_m = gtk_month(
|
||||||
self.last_day.month)
|
self.last_day.month)
|
||||||
self.calendar.select_month(gtk_m, self.last_day.year)
|
self.calendar.select_month(gtk_m, self.last_day.year)
|
||||||
self.calendar.select_day(self.last_day.day)
|
self.calendar.select_day(self.last_day.day)
|
||||||
|
@ -453,8 +456,8 @@ class HistoryWindow:
|
||||||
ErrorDialog(_('Disk Error'), str(e))
|
ErrorDialog(_('Disk Error'), str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
gtk_month = gtkgui_helpers.make_python_month_gtk_month(_date.month)
|
gtk_m = gtk_month(_date.month)
|
||||||
self.calendar.select_month(gtk_month, _date.year)
|
self.calendar.select_month(gtk_m, _date.year)
|
||||||
self.calendar.select_day(_date.day)
|
self.calendar.select_day(_date.day)
|
||||||
|
|
||||||
def _get_string_show_from_constant_int(self, show):
|
def _get_string_show_from_constant_int(self, show):
|
||||||
|
@ -526,8 +529,8 @@ class HistoryWindow:
|
||||||
if seconds_passed > every_foo_seconds:
|
if seconds_passed > every_foo_seconds:
|
||||||
self.last_time_printout = tim
|
self.last_time_printout = tim
|
||||||
tim = time.strftime('%X ', time.localtime(float(tim)))
|
tim = time.strftime('%X ', time.localtime(float(tim)))
|
||||||
buf.insert_with_tags_by_name(end_iter, tim + '\n',
|
buf.insert_with_tags_by_name(
|
||||||
'time_sometimes')
|
end_iter, tim + '\n', 'time_sometimes')
|
||||||
|
|
||||||
tag_name = ''
|
tag_name = ''
|
||||||
tag_msg = ''
|
tag_msg = ''
|
||||||
|
@ -536,11 +539,13 @@ class HistoryWindow:
|
||||||
|
|
||||||
if kind == KindConstant.GC_MSG:
|
if kind == KindConstant.GC_MSG:
|
||||||
tag_name = 'incoming'
|
tag_name = 'incoming'
|
||||||
elif kind in (KindConstant.SINGLE_MSG_RECV, KindConstant.CHAT_MSG_RECV):
|
elif kind in (KindConstant.SINGLE_MSG_RECV,
|
||||||
|
KindConstant.CHAT_MSG_RECV):
|
||||||
contact_name = self.completion_dict[self.jid][InfoColumn.NAME]
|
contact_name = self.completion_dict[self.jid][InfoColumn.NAME]
|
||||||
tag_name = 'incoming'
|
tag_name = 'incoming'
|
||||||
tag_msg = 'incomingtxt'
|
tag_msg = 'incomingtxt'
|
||||||
elif kind in (KindConstant.SINGLE_MSG_SENT, KindConstant.CHAT_MSG_SENT):
|
elif kind in (KindConstant.SINGLE_MSG_SENT,
|
||||||
|
KindConstant.CHAT_MSG_SENT):
|
||||||
if self.account:
|
if self.account:
|
||||||
contact_name = app.nicks[self.account]
|
contact_name = app.nicks[self.account]
|
||||||
else:
|
else:
|
||||||
|
@ -553,11 +558,13 @@ class HistoryWindow:
|
||||||
elif kind == KindConstant.GCSTATUS:
|
elif kind == KindConstant.GCSTATUS:
|
||||||
# message here (if not None) is status message
|
# message here (if not None) is status message
|
||||||
if message:
|
if message:
|
||||||
message = _('%(nick)s is now %(status)s: %(status_msg)s') %\
|
message = _('%(nick)s is now %(status)s: %(status_msg)s') % {
|
||||||
{'nick': contact_name, 'status': helpers.get_uf_show(show),
|
'nick': contact_name,
|
||||||
|
'status': helpers.get_uf_show(show),
|
||||||
'status_msg': message}
|
'status_msg': message}
|
||||||
else:
|
else:
|
||||||
message = _('%(nick)s is now %(status)s') % {'nick': contact_name,
|
message = _('%(nick)s is now %(status)s') % {
|
||||||
|
'nick': contact_name,
|
||||||
'status': helpers.get_uf_show(show) }
|
'status': helpers.get_uf_show(show) }
|
||||||
tag_msg = 'status'
|
tag_msg = 'status'
|
||||||
else: # 'status'
|
else: # 'status'
|
||||||
|
@ -568,11 +575,12 @@ class HistoryWindow:
|
||||||
else:
|
else:
|
||||||
message = _('Error')
|
message = _('Error')
|
||||||
elif message:
|
elif message:
|
||||||
message = _('Status is now: %(status)s: %(status_msg)s') % \
|
message = _('Status is now: %(status)s: %(status_msg)s') % {
|
||||||
{'status': helpers.get_uf_show(show), 'status_msg': message}
|
'status': helpers.get_uf_show(show),
|
||||||
|
'status_msg': message}
|
||||||
else:
|
else:
|
||||||
message = _('Status is now: %(status)s') % { 'status':
|
message = _('Status is now: %(status)s') % {
|
||||||
helpers.get_uf_show(show) }
|
'status': helpers.get_uf_show(show)}
|
||||||
tag_msg = 'status'
|
tag_msg = 'status'
|
||||||
|
|
||||||
if message.startswith('/me ') or message.startswith('/me\n'):
|
if message.startswith('/me ') or message.startswith('/me\n'):
|
||||||
|
@ -586,11 +594,11 @@ class HistoryWindow:
|
||||||
before_str = helpers.from_one_line(before_str)
|
before_str = helpers.from_one_line(before_str)
|
||||||
after_str = app.config.get('after_nickname')
|
after_str = app.config.get('after_nickname')
|
||||||
after_str = helpers.from_one_line(after_str)
|
after_str = helpers.from_one_line(after_str)
|
||||||
format = before_str + contact_name + after_str + ' '
|
format_ = before_str + contact_name + after_str + ' '
|
||||||
if tag_name:
|
if tag_name:
|
||||||
buf.insert_with_tags_by_name(end_iter, format, tag_name)
|
buf.insert_with_tags_by_name(end_iter, format_, tag_name)
|
||||||
else:
|
else:
|
||||||
buf.insert(end_iter, format)
|
buf.insert(end_iter, format_)
|
||||||
if subject:
|
if subject:
|
||||||
message = _('Subject: %s\n') % subject + message
|
message = _('Subject: %s\n') % subject + message
|
||||||
xhtml = None
|
xhtml = None
|
||||||
|
@ -598,11 +606,17 @@ class HistoryWindow:
|
||||||
xhtml = message
|
xhtml = message
|
||||||
|
|
||||||
if tag_msg:
|
if tag_msg:
|
||||||
self.history_textview.print_real_text(message, [tag_msg],
|
self.history_textview.print_real_text(
|
||||||
name=contact_name, xhtml=xhtml, additional_data=additional_data)
|
message, [tag_msg],
|
||||||
|
name=contact_name,
|
||||||
|
xhtml=xhtml,
|
||||||
|
additional_data=additional_data)
|
||||||
else:
|
else:
|
||||||
self.history_textview.print_real_text(message, name=contact_name,
|
self.history_textview.print_real_text(
|
||||||
xhtml=xhtml, additional_data=additional_data)
|
message,
|
||||||
|
name=contact_name,
|
||||||
|
xhtml=xhtml,
|
||||||
|
additional_data=additional_data)
|
||||||
self.history_textview.print_real_text('\n', text_tags=['eol'])
|
self.history_textview.print_real_text('\n', text_tags=['eol'])
|
||||||
|
|
||||||
def on_search_complete_history_toggled(self, widget):
|
def on_search_complete_history_toggled(self, widget):
|
||||||
|
@ -634,16 +648,16 @@ class HistoryWindow:
|
||||||
for jid in self.jids_to_search:
|
for jid in self.jids_to_search:
|
||||||
account = self.completion_dict[jid][InfoColumn.ACCOUNT]
|
account = self.completion_dict[jid][InfoColumn.ACCOUNT]
|
||||||
if account is None:
|
if account is None:
|
||||||
# We do not know an account. This can only happen if the contact is offine,
|
# We do not know an account. This can only happen if
|
||||||
# or if we browse a groupchat history. The account is not needed, a dummy can
|
# the contact is offine, or if we browse a groupchat history.
|
||||||
# be set.
|
# The account is not needed, a dummy can be set.
|
||||||
# This may leed to wrong self nick in the displayed history (Uggh!)
|
# This may leed to wrong self nick in the displayed history
|
||||||
account = list(app.contacts.get_accounts())[0]
|
account = list(app.contacts.get_accounts())[0]
|
||||||
|
|
||||||
date = None
|
date = None
|
||||||
if self.search_in_date.get_active():
|
if self.search_in_date.get_active():
|
||||||
year, month, day = self.calendar.get_date() # integers
|
year, month, day = self.calendar.get_date() # integers
|
||||||
month = gtkgui_helpers.make_gtk_month_python_month(month)
|
month = python_month(month)
|
||||||
date = datetime.datetime(year, month, day)
|
date = datetime.datetime(year, month, day)
|
||||||
|
|
||||||
show_status = self.show_status_checkbutton.get_active()
|
show_status = self.show_status_checkbutton.get_active()
|
||||||
|
@ -660,7 +674,7 @@ class HistoryWindow:
|
||||||
|
|
||||||
contact_name = row.contact_name
|
contact_name = row.contact_name
|
||||||
if not contact_name:
|
if not contact_name:
|
||||||
if row.kind == KindConstant.CHAT_MSG_SENT: # it's us! :)
|
if row.kind == KindConstant.CHAT_MSG_SENT:
|
||||||
contact_name = app.nicks[account]
|
contact_name = app.nicks[account]
|
||||||
else:
|
else:
|
||||||
contact_name = self.completion_dict[jid][InfoColumn.NAME]
|
contact_name = self.completion_dict[jid][InfoColumn.NAME]
|
||||||
|
@ -685,7 +699,7 @@ class HistoryWindow:
|
||||||
|
|
||||||
# get currently selected date
|
# get currently selected date
|
||||||
cur_year, cur_month, cur_day = self.calendar.get_date()
|
cur_year, cur_month, cur_day = self.calendar.get_date()
|
||||||
cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
|
cur_month = python_month(cur_month)
|
||||||
model, paths = self.results_treeview.get_selection().get_selected_rows()
|
model, paths = self.results_treeview.get_selection().get_selected_rows()
|
||||||
|
|
||||||
if not paths:
|
if not paths:
|
||||||
|
@ -696,7 +710,7 @@ class HistoryWindow:
|
||||||
tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
|
tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
|
||||||
year = tim[0]
|
year = tim[0]
|
||||||
gtk_month = tim[1]
|
gtk_month = tim[1]
|
||||||
month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
|
month = gtk_month(gtk_month)
|
||||||
day = tim[2]
|
day = tim[2]
|
||||||
|
|
||||||
# switch to belonging logfile if necessary
|
# switch to belonging logfile if necessary
|
||||||
|
@ -740,25 +754,27 @@ class HistoryWindow:
|
||||||
match_end = match_start.copy()
|
match_end = match_start.copy()
|
||||||
match_end.forward_to_tag_toggle(self.history_buffer.eol_tag)
|
match_end.forward_to_tag_toggle(self.history_buffer.eol_tag)
|
||||||
|
|
||||||
self.history_buffer.apply_tag_by_name('highlight', match_start, match_end)
|
self.history_buffer.apply_tag_by_name(
|
||||||
|
'highlight', match_start, match_end)
|
||||||
mark = self.history_buffer.create_mark('match', match_start, True)
|
mark = self.history_buffer.create_mark('match', match_start, True)
|
||||||
GLib.idle_add(self.history_textview.tv.scroll_to_mark, mark, 0, True, 0.0, 0.5)
|
GLib.idle_add(
|
||||||
|
self.history_textview.tv.scroll_to_mark, mark, 0, True, 0.0, 0.5)
|
||||||
|
|
||||||
def on_log_history_checkbutton_toggled(self, widget, *args):
|
def on_log_history_checkbutton_toggled(self, widget, *args):
|
||||||
# log conversation history?
|
# log conversation history?
|
||||||
oldlog = True
|
oldlog = True
|
||||||
no_log_for = app.config.get_per('accounts', self.account,
|
no_log_for = app.config.get_per(
|
||||||
'no_log_for').split()
|
'accounts', self.account, 'no_log_for').split()
|
||||||
if self.jid in no_log_for:
|
if self.jid in no_log_for:
|
||||||
oldlog = False
|
oldlog = False
|
||||||
log = widget.get_active()
|
log = widget.get_active()
|
||||||
if not log and not self.jid in no_log_for:
|
if not log and self.jid not in no_log_for:
|
||||||
no_log_for.append(self.jid)
|
no_log_for.append(self.jid)
|
||||||
if log and self.jid in no_log_for:
|
if log and self.jid in no_log_for:
|
||||||
no_log_for.remove(self.jid)
|
no_log_for.remove(self.jid)
|
||||||
if oldlog != log:
|
if oldlog != log:
|
||||||
app.config.set_per('accounts', self.account, 'no_log_for',
|
app.config.set_per(
|
||||||
' '.join(no_log_for))
|
'accounts', self.account, 'no_log_for', ' '.join(no_log_for))
|
||||||
|
|
||||||
def on_show_status_checkbutton_toggled(self, widget):
|
def on_show_status_checkbutton_toggled(self, widget):
|
||||||
# reload logs
|
# reload logs
|
||||||
|
@ -773,8 +789,8 @@ class HistoryWindow:
|
||||||
# Update dict to not only show bare jid
|
# Update dict to not only show bare jid
|
||||||
GLib.idle_add(next, self._fill_completion_dict())
|
GLib.idle_add(next, self._fill_completion_dict())
|
||||||
else:
|
else:
|
||||||
# Only in that case because it's called by self._fill_completion_dict()
|
# Only in that case because it's called by
|
||||||
# otherwise
|
# self._fill_completion_dict() otherwise
|
||||||
self._load_history(jid, account)
|
self._load_history(jid, account)
|
||||||
self.results_window.set_property('visible', False)
|
self.results_window.set_property('visible', False)
|
||||||
|
|
|
@ -203,3 +203,11 @@ def get_image_button(icon_name, tooltip, toggle=False):
|
||||||
icon_name, Gtk.IconSize.MENU)
|
icon_name, Gtk.IconSize.MENU)
|
||||||
button.set_tooltip_text(tooltip)
|
button.set_tooltip_text(tooltip)
|
||||||
return button
|
return button
|
||||||
|
|
||||||
|
|
||||||
|
def python_month(month):
|
||||||
|
return month + 1
|
||||||
|
|
||||||
|
|
||||||
|
def gtk_month(month):
|
||||||
|
return month - 1
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
## NOTE: some method names may match those of logger.py but that's it
|
## NOTE: some method names may match those of logger.py but that's it
|
||||||
## someday (TM) should have common class
|
## someday (TM) should have common class
|
||||||
## that abstracts db connections and helpers on it
|
## that abstracts db connections and helpers on it
|
||||||
## the same can be said for history_window.py
|
## the same can be said for history.py
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -47,7 +47,6 @@ import logging
|
||||||
|
|
||||||
from enum import IntEnum, unique
|
from enum import IntEnum, unique
|
||||||
|
|
||||||
from gajim import history_window
|
|
||||||
from gajim import dialogs
|
from gajim import dialogs
|
||||||
from gajim import vcard
|
from gajim import vcard
|
||||||
from gajim import config
|
from gajim import config
|
||||||
|
@ -72,6 +71,7 @@ from gajim.gtk import ManagePEPServicesWindow
|
||||||
from gajim.gtk import ManageBookmarksWindow
|
from gajim.gtk import ManageBookmarksWindow
|
||||||
from gajim.gtk import AccountCreationWizard
|
from gajim.gtk import AccountCreationWizard
|
||||||
from gajim.gtk import ServiceRegistration
|
from gajim.gtk import ServiceRegistration
|
||||||
|
from gajim.gtk import HistoryWindow
|
||||||
|
|
||||||
from gajim.common.const import AvatarSize
|
from gajim.common.const import AvatarSize
|
||||||
|
|
||||||
|
@ -3047,8 +3047,7 @@ class RosterWindow:
|
||||||
app.interface.instances['logs'].window.present()
|
app.interface.instances['logs'].window.present()
|
||||||
app.interface.instances['logs'].open_history(contact.jid, account)
|
app.interface.instances['logs'].open_history(contact.jid, account)
|
||||||
else:
|
else:
|
||||||
app.interface.instances['logs'] = history_window.\
|
app.interface.instances['logs'] = HistoryWindow(contact.jid, account)
|
||||||
HistoryWindow(contact.jid, account)
|
|
||||||
|
|
||||||
def on_disconnect(self, widget, jid, account):
|
def on_disconnect(self, widget, jid, account):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue