fixing #294 [thanks to Nick Lopez!]
This commit is contained in:
parent
2a3ac7a89d
commit
6c7d811a3c
21
src/chat.py
21
src/chat.py
|
@ -56,6 +56,7 @@ class Chat:
|
|||
self.tagStatus = {}
|
||||
self.nb_unread = {}
|
||||
self.last_message_time = {}
|
||||
self.last_time_printout = {}
|
||||
self.print_time_timeout_id = {}
|
||||
self.names = {} # what is printed in the tab (eg. user.name)
|
||||
self.childs = {}
|
||||
|
@ -225,6 +226,7 @@ class Chat:
|
|||
del self.plugin.windows[self.account][kind][jid]
|
||||
del self.nb_unread[jid]
|
||||
del self.last_message_time[jid]
|
||||
del self.last_time_printout[jid]
|
||||
del self.xmls[jid]
|
||||
del self.tagIn[jid]
|
||||
del self.tagOut[jid]
|
||||
|
@ -234,6 +236,7 @@ class Chat:
|
|||
def new_tab(self, jid):
|
||||
self.nb_unread[jid] = 0
|
||||
self.last_message_time[jid] = 0
|
||||
self.last_time_printout[jid] = float(0.0)
|
||||
|
||||
if gajim.config.get('use_speller') and 'gtkspell' in globals():
|
||||
message_textview = self.xmls[jid].get_widget('message_textview')
|
||||
|
@ -485,7 +488,7 @@ class Chat:
|
|||
|
||||
def print_time_timeout(self, jid):
|
||||
if not jid in self.xmls.keys():
|
||||
return 0
|
||||
return False
|
||||
if gajim.config.get('print_time') == 'sometimes':
|
||||
textview = self.xmls[jid].get_widget('conversation_textview')
|
||||
buffer = textview.get_buffer()
|
||||
|
@ -501,10 +504,10 @@ class Chat:
|
|||
if end_rect.y <= (visible_rect.y + visible_rect.height):
|
||||
#we are at the end
|
||||
self.scroll_to_end(textview)
|
||||
return 1
|
||||
return True # loop again
|
||||
if self.print_time_timeout_id.has_key(jid):
|
||||
del self.print_time_timeout_id[jid]
|
||||
return 0
|
||||
return False
|
||||
|
||||
def on_open_link_activate(self, widget, kind, text):
|
||||
self.plugin.launch_browser_mailer(kind, text)
|
||||
|
@ -685,6 +688,18 @@ class Chat:
|
|||
tim_format = time.strftime(format, tim)
|
||||
self.print_with_tag_list(buffer, tim_format + ' ', end_iter,
|
||||
other_tags_for_time)
|
||||
elif gajim.config.get('print_time') == 'sometimes':
|
||||
if (time.time() - self.last_time_printout[jid]) > (5*60):
|
||||
self.last_time_printout[jid] = time.time()
|
||||
end_iter = buffer.get_end_iter()
|
||||
tim = time.localtime()
|
||||
tim_format = time.strftime('%H:%M', tim)
|
||||
buffer.insert_with_tags_by_name(end_iter,
|
||||
tim_format + '\n',
|
||||
'time_sometimes')
|
||||
#scroll to the end of the textview
|
||||
end_rect = textview.get_iter_location(end_iter)
|
||||
visible_rect = textview.get_visible_rect()
|
||||
|
||||
text_tags = other_tags_for_text[:]
|
||||
if kind == 'status':
|
||||
|
|
|
@ -172,6 +172,7 @@ class Tabbed_chat_window(chat.Chat):
|
|||
nontabbed_status_image.show()
|
||||
|
||||
def new_user(self, user):
|
||||
'''when new tab is created'''
|
||||
self.names[user.jid] = user.name
|
||||
self.xmls[user.jid] = gtk.glade.XML(GTKGUI_GLADE, 'chats_vbox', APP)
|
||||
self.childs[user.jid] = self.xmls[user.jid].get_widget('chats_vbox')
|
||||
|
@ -181,6 +182,7 @@ class Tabbed_chat_window(chat.Chat):
|
|||
|
||||
self.redraw_tab(user.jid)
|
||||
self.draw_widgets(user)
|
||||
|
||||
uf_show = helpers.get_uf_show(user.show)
|
||||
s = _('%s is %s') % (user.name, uf_show)
|
||||
if user.status:
|
||||
|
@ -196,12 +198,6 @@ class Tabbed_chat_window(chat.Chat):
|
|||
if self.plugin.queues[self.account].has_key(user.jid):
|
||||
self.read_queue(user.jid)
|
||||
|
||||
if gajim.config.get('print_time') == 'sometimes':
|
||||
self.print_time_timeout(user.jid)
|
||||
self.print_time_timeout_id[user.jid] = gobject.timeout_add(300000,
|
||||
self.print_time_timeout, user.jid)
|
||||
|
||||
|
||||
def on_message_textview_key_press_event(self, widget, event):
|
||||
"""When a key is pressed:
|
||||
if enter is pressed without the shit key, message (if not empty) is sent
|
||||
|
|
Loading…
Reference in New Issue