remove too long lines

fix too long variables
etc...
This commit is contained in:
Vincent Hanquez 2005-04-22 01:35:36 +00:00
parent fbc6e0fef4
commit b7c2fdc662
4 changed files with 86 additions and 89 deletions

View File

@ -122,25 +122,27 @@ class History_window:
def new_line(self, date, type, data): def new_line(self, date, type, data):
"""write a new line""" """write a new line"""
start_iter = self.history_buffer.get_start_iter() buffer = self.history_buffer
end_iter = self.history_buffer.get_end_iter() start_iter = buffer.get_start_iter()
end_iter = buffer.get_end_iter()
tim = time.strftime('[%x %X] ', time.localtime(float(date))) tim = time.strftime('[%x %X] ', time.localtime(float(date)))
self.history_buffer.insert(start_iter, tim) buffer.insert(start_iter, tim)
if type == 'recv': if type == 'recv':
msg = ':'.join(data[0:]) msg = ':'.join(data[0:])
msg = msg.replace('\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \ buffer.insert_with_tags_by_name(start_iter, msg,
'incoming') 'incoming')
elif type == 'sent': elif type == 'sent':
msg = ':'.join(data[0:]) msg = ':'.join(data[0:])
msg = msg.replace('\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \ buffer.insert_with_tags_by_name(start_iter, msg,
'outgoing') 'outgoing')
else: else:
msg = ':'.join(data[1:]) msg = ':'.join(data[1:])
msg = msg.replace('\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, \ buffer.insert_with_tags_by_name(start_iter,
_('Status is now: ') + data[0]+': ' + msg, 'status') _('Status is now: ') + data[0]
+ ': ' + msg, 'status')
def __init__(self, plugin, jid): def __init__(self, plugin, jid):
self.plugin = plugin self.plugin = plugin
@ -154,15 +156,19 @@ class History_window:
self.forward_button = xml.get_widget('forward_button') self.forward_button = xml.get_widget('forward_button')
self.latest_button = xml.get_widget('latest_button') self.latest_button = xml.get_widget('latest_button')
xml.signal_autoconnect(self) xml.signal_autoconnect(self)
tagIn = self.history_buffer.create_tag('incoming')
tag = self.history_buffer.create_tag('incoming')
color = gajim.config.get('inmsgcolor') color = gajim.config.get('inmsgcolor')
tagIn.set_property('foreground', color) tag.set_property('foreground', color)
tagOut = self.history_buffer.create_tag('outgoing')
tag = self.history_buffer.create_tag('outgoing')
color = gajim.config.get('outmsgcolor') color = gajim.config.get('outmsgcolor')
tagOut.set_property('foreground', color) tag.set_property('foreground', color)
tagStatus = self.history_buffer.create_tag('status')
tag = self.history_buffer.create_tag('status')
color = gajim.config.get('statusmsgcolor') color = gajim.config.get('statusmsgcolor')
tagStatus.set_property('foreground', color) tag.set_property('foreground', color)
begin = 0 begin = 0
if self.nb_line > 50: if self.nb_line > 50:
begin = self.nb_line - 50 begin = self.nb_line - 50

View File

@ -52,34 +52,24 @@ class Roster_window:
if self.regroup: if self.regroup:
return None return None
model = self.tree.get_model() model = self.tree.get_model()
fin = False
account = model.get_iter_root() account = model.get_iter_root()
if not account: while account:
return None
while not fin:
account_name = model.get_value(account, 3) account_name = model.get_value(account, 3)
if name == account_name: if name == account_name:
return account break
account = model.iter_next(account) account = model.iter_next(account)
if not account: return account
fin = True
return None
def get_group_iter(self, name, account): def get_group_iter(self, name, account):
model = self.tree.get_model() model = self.tree.get_model()
root = self.get_account_iter(account) root = self.get_account_iter(account)
fin = False
group = model.iter_children(root) group = model.iter_children(root)
if not group: while group:
fin = True
while not fin:
group_name = model.get_value(group, 3) group_name = model.get_value(group, 3)
if name == group_name: if name == group_name:
return group break
group = model.iter_next(group) group = model.iter_next(group)
if not group: return group
fin = True
return None
def get_user_iter(self, jid, account): def get_user_iter(self, jid, account):
model = self.tree.get_model() model = self.tree.get_model()
@ -87,22 +77,13 @@ class Roster_window:
found = [] found = []
fin = False fin = False
group = model.iter_children(acct) group = model.iter_children(acct)
if not group: while group:
return found
while not fin:
fin2 = False
user = model.iter_children(group) user = model.iter_children(group)
if not user: while user:
fin2 = True
while not fin2:
if jid == model.get_value(user, 3): if jid == model.get_value(user, 3):
found.append(user) found.append(user)
user = model.iter_next(user) user = model.iter_next(user)
if not user:
fin2 = True
group = model.iter_next(group) group = model.iter_next(group)
if not group:
fin = True
return found return found
def add_account_to_roster(self, account): def add_account_to_roster(self, account):
@ -111,11 +92,11 @@ class Roster_window:
model = self.tree.get_model() model = self.tree.get_model()
if self.get_account_iter(account): if self.get_account_iter(account):
return return
statuss = ['offline', 'connecting', 'online', 'away', 'xa', 'dnd', statuss = ['offline', 'connecting', 'online',
'invisible'] 'away', 'xa', 'dnd', 'invisible']
status = statuss[gajim.connections[account].connected] status = statuss[gajim.connections[account].connected]
model.append(None, (self.pixbufs[status], account, 'account', account, model.append(None, (self.pixbufs[status], account,
account, False)) 'account', account, account, False))
def remove_newly_added(self, jid, account): def remove_newly_added(self, jid, account):
if jid in self.newly_added[account]: if jid in self.newly_added[account]:
@ -134,9 +115,9 @@ class Roster_window:
elif user.groups == []: elif user.groups == []:
user.groups.append('General') user.groups.append('General')
if (user.show == 'offline' or user.show == 'error') and not showOffline\ if (user.show == 'offline' or user.show == 'error') and \
and not 'Agents' in user.groups and \ not showOffline and not 'Agents' in user.groups and \
not self.plugin.queues[account].has_key(user.jid): not self.plugin.queues[account].has_key(user.jid):
return return
model = self.tree.get_model() model = self.tree.get_model()
@ -148,11 +129,12 @@ class Roster_window:
(self.pixbufs['closed'], g, 'group', g, account, False)) (self.pixbufs['closed'], g, 'group', g, account, False))
if not self.groups[account].has_key(g): #It can probably never append if not self.groups[account].has_key(g): #It can probably never append
if account + g in self.hidden_lines: if account + g in self.hidden_lines:
self.groups[account][g] = {'expand': False} ishidden = False
else: else:
self.groups[account][g] = {'expand': True} ishidden = True
if not account in self.hidden_lines and not gajim.config.get( self.groups[account][g] = { 'expand': ishidden }
'mergeaccounts'): if not account in self.hidden_lines and \
not gajim.config.get('mergeaccounts'):
self.tree.expand_row((model.get_path(iterG)[0]), False) self.tree.expand_row((model.get_path(iterG)[0]), False)
typestr = 'user' typestr = 'user'
@ -160,10 +142,11 @@ class Roster_window:
typestr = 'agent' typestr = 'agent'
model.append(iterG, (self.pixbufs[user.show], user.name, model.append(iterG, (self.pixbufs[user.show], user.name,
typestr, user.jid, account, False)) typestr, user.jid, account, False))
if self.groups[account][g]['expand']: if self.groups[account][g]['expand']:
self.tree.expand_row(model.get_path(iterG), False) self.tree.expand_row(model.get_path(iterG),
False)
self.redraw_jid(jid, account) self.redraw_jid(jid, account)
def really_remove_user(self, user, account): def really_remove_user(self, user, account):
@ -357,18 +340,23 @@ class Roster_window:
if not show: if not show:
show = 'offline' show = 'offline'
user1 = User(ji, name, array[jid]['groups'], show, user1 = User(ji, name, array[jid]['groups'],
array[jid]['status'], array[jid]['sub'], show, array[jid]['status'],
array[jid]['ask'], resource, 0, '') array[jid]['sub'], array[jid]['ask'],
#when we draw the roster, we can't have twice the same user with resource, 0, '')
# 2 resources
# when we draw the roster, we can't have twice the same
# user with 2 resources
self.contacts[account][ji] = [user1] self.contacts[account][ji] = [user1]
for g in array[jid]['groups'] : for g in array[jid]['groups'] :
if not g in self.groups[account].keys(): if g in self.groups[account].keys():
if account + g in self.hidden_lines: continue
self.groups[account][g] = {'expand': False}
else: if account + g in self.hidden_lines:
self.groups[account][g] = {'expand': True} ishidden = False
else:
ishidden = True
self.groups[account][g] = { 'expand': ishidden }
def chg_user_status(self, user, show, status, account): def chg_user_status(self, user, show, status, account):
'''When a user change his status''' '''When a user change his status'''
@ -378,7 +366,7 @@ class Roster_window:
user.show = show user.show = show
user.status = status user.status = status
if (show == 'offline' or show == 'error') and \ if (show == 'offline' or show == 'error') and \
not self.plugin.queues[account].has_key(user.jid): not self.plugin.queues[account].has_key(user.jid):
if len(luser) > 1: if len(luser) > 1:
luser.remove(user) luser.remove(user)
self.redraw_jid(user.jid, account) self.redraw_jid(user.jid, account)
@ -401,11 +389,12 @@ class Roster_window:
def on_info(self, widget, user, account): def on_info(self, widget, user, account):
'''Call vcard_information_window class to display user's information''' '''Call vcard_information_window class to display user's information'''
if self.plugin.windows[account]['infos'].has_key(user.jid): info = self.plugin.windows[account]['infos']
self.plugin.windows[account]['infos'][user.jid].window.present() if info.has_key(user.jid):
info[user.jid].window.present()
else: else:
self.plugin.windows[account]['infos'][user.jid] = \ info[user.jid] = Vcard_information_window(user,
Vcard_information_window(user, self.plugin, account) self.plugin, account)
def on_agent_logging(self, widget, jid, state, account): def on_agent_logging(self, widget, jid, state, account):
'''When an agent is requested to log in or off''' '''When an agent is requested to log in or off'''
@ -1146,9 +1135,11 @@ class Roster_window:
iconset = 'sun' iconset = 'sun'
self.path = '../data/iconsets/' + iconset + '/' self.path = '../data/iconsets/' + iconset + '/'
self.pixbufs = {} self.pixbufs = {}
for state in ('connecting', 'online', 'chat', 'away', 'xa', 'dnd', for state in ('connecting', 'online', 'chat', 'away', 'xa',
'invisible', 'offline', 'error', 'requested', 'message', 'dnd', 'invisible', 'offline', 'error',
'opened', 'closed', 'not in the roster'): 'requested', 'message', 'opened', 'closed',
'not in the roster'):
# try to open a pixfile with the correct method # try to open a pixfile with the correct method
state_file = state.replace(' ', '_') state_file = state.replace(' ', '_')
files = [] files = []

View File

@ -55,9 +55,10 @@ class Systray:
for acct in gajim.connections: for acct in gajim.connections:
#in chat / groupchat windows #in chat / groupchat windows
for kind in ['chats', 'gc']: for kind in ['chats', 'gc']:
for jid in self.plugin.windows[acct][kind]: jids = self.plugin.windows[acct][kind]
for jid in jids:
if jid != 'tabbed': if jid != 'tabbed':
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid] nb += jids[jid].nb_unread[jid]
if nb > 1: if nb > 1:
label = _('Gajim - %s unread messages') % nb label = _('Gajim - %s unread messages') % nb
else: else:
@ -110,12 +111,9 @@ class Systray:
new_message_menuitem = self.xml.get_widget('new_message_menuitem') new_message_menuitem = self.xml.get_widget('new_message_menuitem')
#menu.append(new_message_menuitem) #menu.append(new_message_menuitem)
if len(gajim.connections.keys()) > 0: iskey = len(gajim.connections.keys()) > 0
chat_with_menuitem.set_sensitive(True) chat_with_menuitem.set_sensitive(iskey)
new_message_menuitem.set_sensitive(True) new_message_menuitem.set_sensitive(iskey)
else:
chat_with_menuitem.set_sensitive(False)
new_message_menuitem.set_sensitive(False)
if len(gajim.connections.keys()) >= 2: # 2 or more accounts? make submenus if len(gajim.connections.keys()) >= 2: # 2 or more accounts? make submenus
account_menu_for_chat_with = gtk.Menu() account_menu_for_chat_with = gtk.Menu()
@ -199,12 +197,13 @@ class Systray:
else: else:
account = self.jids[0][0] account = self.jids[0][0]
jid = self.jids[0][1] jid = self.jids[0][1]
if self.plugin.windows[account]['gc'].has_key(jid): acc = self.plugin.windows[account]
self.plugin.windows[account]['gc'][jid].active_tab(jid) if acc['gc'].has_key(jid):
self.plugin.windows[account]['gc'][jid].window.present() acc['gc'][jid].active_tab(jid)
elif self.plugin.windows[account]['chats'].has_key(jid): acc['gc'][jid].window.present()
self.plugin.windows[account]['chats'][jid].active_tab(jid) elif acc['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].window.present() acc['chats'][jid].active_tab(jid)
acc['chats'][jid].window.present()
else: else:
self.plugin.roster.new_chat( self.plugin.roster.new_chat(
self.plugin.roster.contacts[account][jid][0], account) self.plugin.roster.contacts[account][jid][0], account)

View File

@ -95,10 +95,11 @@ class Vcard_information_window:
self.xml.get_widget('nickname_label').set_text(self.user.name) self.xml.get_widget('nickname_label').set_text(self.user.name)
self.xml.get_widget('jid_label').set_text(self.user.jid) self.xml.get_widget('jid_label').set_text(self.user.jid)
self.xml.get_widget('subscription_label').set_text(self.user.sub) self.xml.get_widget('subscription_label').set_text(self.user.sub)
label = self.xml.get_widget('ask_label')
if self.user.ask: if self.user.ask:
self.xml.get_widget('ask_label').set_text(self.user.ask) label.set_text(self.user.ask)
else: else:
self.xml.get_widget('ask_label').set_text('None') label.set_text('None')
self.xml.get_widget('nickname_entry').set_text(self.user.name) self.xml.get_widget('nickname_entry').set_text(self.user.name)
log = 1 log = 1
if self.user.jid in gajim.config.get_per('accounts', self.account, \ if self.user.jid in gajim.config.get_per('accounts', self.account, \