add_jid remove_jid is better coded like that. removal of systrayDummy class [have a look and we can discuss], also have a look at a FIXME, back to detection of http://b) with ) in it, cause http://be?b)b can be valid url

This commit is contained in:
Nikos Kouremenos 2005-03-29 16:16:42 +00:00
parent 6b19bc4c74
commit d8d40e0c01
7 changed files with 47 additions and 39 deletions

6
README
View File

@ -34,3 +34,9 @@ Enjoy!
(C) 2005
The Gajim Team
http://gajim.org
ps.
sounds & emoticons taken from Psi
'gossip' iconstyle taken from Imendio Gossip

View File

@ -116,7 +116,7 @@ class Chat:
def on_window_destroy(self, widget, kind): #kind is 'chats' or 'gc'
#clean self.plugin.windows[self.account][kind]
for jid in self.xmls:
if self.nb_unread[jid] > 0:
if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
self.plugin.systray.remove_jid(jid, self.account)
del self.plugin.windows[self.account][kind][jid]
if self.print_time_timeout_id.has_key(jid):
@ -154,7 +154,8 @@ class Chat:
self.nb_unread[jid] = 0
self.redraw_tab(jid)
self.show_title()
self.plugin.systray.remove_jid(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
def on_chat_notebook_switch_page(self, notebook, page, page_num):
new_child = notebook.get_nth_page(page_num)
@ -175,7 +176,8 @@ class Chat:
self.nb_unread[new_jid] = 0
self.redraw_tab(new_jid)
self.show_title()
self.plugin.systray.remove_jid(new_jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(new_jid, self.account)
def active_tab(self, jid):
self.notebook.set_current_page(\
@ -188,7 +190,8 @@ class Chat:
if self.nb_unread[jid] > 0:
self.nb_unread[jid] = 0
self.show_title()
self.plugin.systray.remove_jid(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
if self.print_time_timeout_id.has_key(jid):
gobject.source_remove(self.print_time_timeout_id[jid])
del self.print_time_timeout_id[jid]
@ -331,7 +334,8 @@ class Chat:
self.nb_unread[jid] = 0
self.redraw_tab(jid)
self.show_title()
self.plugin.systray.remove_jid(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
def on_conversation_textview_motion_notify_event(self, widget, event):
"""change the cursor to a hand when we are on a mail or an url"""
@ -484,12 +488,14 @@ class Chat:
self.plugin.emoticons[emot_ascii])
elif special_text.startswith('mailto:'):
#it's a mail
special_text = special_text[0:-1]
tags.append('mail')
use_other_tags = False
elif self.plugin.sth_at_sth_dot_sth_re.match(special_text):
#it's a mail
tags.append('mail')
use_other_tags = False
special_text = special_text[0:-1]
elif special_text.startswith('*'): # it's a bold text
tags.append('bold')
if special_text[1] == '/': # it's also italic
@ -589,6 +595,7 @@ class Chat:
if ((jid != self.get_active_jid()) or (not self.window.is_active()) or \
(not end)) and kind == 'incoming':
self.nb_unread[jid] += 1
self.plugin.systray.add_jid(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(jid, self.account)
self.redraw_tab(jid)
self.show_title()

View File

@ -716,11 +716,12 @@ class Preferences_window:
self.notebook = self.xml.get_widget('preferences_notebook')
#trayicon
st = self.plugin.config['trayicon']
self.tray_icon_checkbutton.set_active(st)
if isinstance(self.plugin.systray, gtkgui.systrayDummy):
if self.plugin.systray_capabilities:
st = self.plugin.config['trayicon']
self.tray_icon_checkbutton.set_active(st)
else:
self.tray_icon_checkbutton.set_sensitive(False)
#Save position
st = self.plugin.config['saveposition']
self.xml.get_widget('save_position_checkbutton').set_active(st)

View File

@ -738,13 +738,11 @@ class plugin:
# [^\s*] anything but whitespaces and '*'
# (?<!\S) is a one char lookbehind assertion and asks for any leading whitespace
# and mathces beginning of lines so we have correct formatting detection
# even if the the text is just '*something*'
# even if the the text is just '*foo*'
# (?!\S) is the same thing but it's a lookahead assertion
# basic_pattern is one string literal.
# I've put spaces to make the regexp look better.
links = r'\bhttp://[^)\s]+|' r'\bhttps://[^)\s]+|' r'\bnews://[^)\s]+|' r'\bftp://[^)\s]+|' r'\bed2k://[^)\s]+|' r'\bwww\.[^)\s]+|' r'\bftp\.[^)\s]+|'
links = r'\bhttp://\S+|' r'\bhttps://\S+|' r'\bnews://\S+|' r'\bftp://\S+|' r'\bed2k://\S+|' r'\bwww\.\S+|' r'\bftp\.\S+|'
#2nd one: at_least_one_char@at_least_one_char.at_least_one_char
mail = r'\bmailto:[^)\s]+|' r'\b[^)\s]+@[^)\s]+\.[^)\s]+|'
mail = r'\bmailto:\S+|' r'\b\S+@\S+\.\S+|'
#detects eg. *b* *bold* *bold bold* test *bold*
#doesn't detect (it's a feature :P) * bold* *bold * * bold * test*bold*
@ -908,8 +906,9 @@ class plugin:
except: # user doesn't have trayicon capabilities
self.config['trayicon'] = 0
self.send('CONFIG', None, ('GtkGui', self.config, 'GtkGui'))
self.systray = systrayDummy()
self.systray_capabilities = False
else:
self.systray_capabilities = True
self.systray = systray(self)
else:
self.systray = systray(self)

View File

@ -877,7 +877,8 @@ class Roster_window:
model = self.tree.get_model()
self.plugin.queues[account][jid] = Queue.Queue(50)
self.redraw_jid(jid, account)
self.plugin.systray.add_jid(jid, account)
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(jid, account)
self.plugin.queues[account][jid].put((msg, tim))
self.nb_unread += 1
self.show_title()
@ -1307,7 +1308,20 @@ class Roster_window:
cell = gtk.CellRendererText()
self.cb.pack_start(cell, True)
self.cb.add_attribute(cell, 'text', 0)
for status in ['online', 'away', 'xa', 'dnd', 'invisible', 'offline']:
for status in ['online', 'dnd', 'away', 'xa', 'invisible', 'offline']:
''' GIVES ERROR in core.py line: 805
First I like status to be Online and not online
and jargon word as dnd and xa should be as I have them
that means either this code, or changing 'xa' and 'dnd' all over
you know the core better yann so let us talk on this
if status == 'dnd':
status_better = 'Busy'
elif status == 'xa':
status_better = 'Extended Away'
else:
status_better = status.capitalize()
iter = liststore.append([status_better, self.pixbufs[status]])
'''
iter = liststore.append([status, self.pixbufs[status]])
self.cb.show_all()
self.cb.set_model(liststore)

View File

@ -31,22 +31,6 @@ gtk.glade.textdomain(APP)
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
class systrayDummy:
"""Class when we don't want icon in the systray"""
def add_jid(self, jid, account):
pass
def remove_jid(self, jid, account):
pass
def set_status(self, status):
pass
def show_icon(self):
pass
def hide_icon(self):
pass
def __init__(self):
self.t = gtk.Button()
self.jids = []
class systray:
"""Class for icon in the systray"""
def set_img(self):
@ -61,8 +45,6 @@ class systray:
self.img_tray.set_from_pixbuf(image.get_pixbuf())
def add_jid(self, jid, account):
if not self.t: # the systray is hidden
return
list = [account, jid]
if not list in self.jids:
self.jids.append(list)
@ -83,8 +65,6 @@ class systray:
self.tip.set_tip(self.t, label)
def remove_jid(self, jid, account):
if not self.t: # the systray is hidden
return
list = [account, jid]
if list in self.jids:
self.jids.remove(list)

View File

@ -200,7 +200,8 @@ class Tabbed_chat_window(Chat):
self.plugin.roster.show_title()
del self.plugin.queues[self.account][jid]
self.plugin.roster.redraw_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
showOffline = self.plugin.config['showoffline']
if (user.show == 'offline' or user.show == 'error') and \
not showOffline: