Author: jim++
Date: 2008-05-31 22:49:48 +0200 (Sat, 31 May 2008)
New Revision: 9728
Modified:
trunk/src/history_window.py
Log:
-Fix TB in my last commit
-Stop using idle_call for marking days with log in calendar, because this was... longer !
-Stop emiting month changed signal two times (so it was even longer)
Modified: trunk/src/history_window.py
===================================================================
--- trunk/src/history_window.py 2008-05-31 19:41:42 UTC (rev 9727)
+++ trunk/src/history_window.py 2008-05-31 20:49:48 UTC (rev 9728)
@@ -65,8 +65,6 @@
'''Class for browsing logs of conversations with contacts'''
def __init__(self, jid = None, account = None):
- self.mark_days_idle_call_id = None
-
xml = gtkgui_helpers.get_glade('history_window.glade')
self.window = xml.get_widget('history_window')
self.jid_entry = xml.get_widget('jid_entry')
@@ -158,7 +156,8 @@
keys = self.completion_dict.keys()
# Move the actual jid at first so we load history faster
actual_jid = self.jid_entry.get_text().decode('utf-8')
- keys.remove(actual_jid)
+ if actual_jid in keys:
+ keys.remove(actual_jid)
keys.insert(0, actual_jid)
# Map jid to info tuple
# Warning : This for is time critical with big DB
@@ -214,10 +213,6 @@
return account
def on_history_window_destroy(self, widget):
- if self.mark_days_idle_call_id:
- # if user destroys the window, and we have a generator filling mark days
- # stop him!
- gobject.source_remove(self.mark_days_idle_call_id)
self.history_textview.del_handlers()
del gajim.interface.instances['logs']
@@ -277,7 +272,6 @@
# select logs for last date we have logs with contact
self.calendar.set_sensitive(True)
- self.calendar.emit('month-changed')
lastlog = gajim.logger.get_last_date_that_has_logs(self.jid, self.account)
tim = lastlog
@@ -317,31 +311,21 @@
month = gtkgui_helpers.make_gtk_month_python_month(month)
self._add_lines_for_date(year, month, day)
- def do_possible_mark_for_days_in_this_month(self, widget, year, month):
- '''this is a generator and does pseudo-threading via idle_add()
- so it runs progressively! yea :)
- asks for days in this month if they have logs it bolds them (marks them)'''
- weekday, days_in_this_month = calendar.monthrange(year, month)
- log_days = gajim.logger.get_days_with_logs(self.jid, year,
- month, days_in_this_month, self.account)
- for day in log_days:
- widget.mark_day(day)
- yield True
- yield False
-
def on_calendar_month_changed(self, widget):
+ '''asks for days in this month if they have logs it bolds them (marks
+ them)
+ '''
year, month, day = widget.get_date() # integers
# in gtk January is 1, in python January is 0,
# I want the second
# first day of month is 1 not 0
- if self.mark_days_idle_call_id:
- # if user changed month, and we have a generator filling mark days
- # stop him from marking dates for the previously selected month
- gobject.source_remove(self.mark_days_idle_call_id)
widget.clear_marks()
month = gtkgui_helpers.make_gtk_month_python_month(month)
- self.mark_days_idle_call_id = gobject.idle_add(
- self.do_possible_mark_for_days_in_this_month(widget, year, month).next)
+ weekday, days_in_this_month = calendar.monthrange(year, month)
+ log_days = gajim.logger.get_days_with_logs(self.jid, year,
+ month, days_in_this_month, self.account)
+ for day in log_days:
+ widget.mark_day(day)
def _get_string_show_from_constant_int(self, show):
if show == constants.SHOW_ONLINE: