remove trailing whitespaces and fix coding styles etc and add a FIXME

This commit is contained in:
Nikos Kouremenos 2005-12-06 17:43:21 +00:00
parent 5868901824
commit eb94b9632a
5 changed files with 187 additions and 182 deletions

View File

@ -85,7 +85,7 @@ awaiting_events = {} # list of messages/FT reveived but not printed
# if type in ('chat', 'normal'): data = (message, subject, kind, time,
# encrypted, resource)
# kind can be (incoming, error)
# if type in file-request, file-request-error, file-send-error, file-error,
# if type in file-request, file-request-error, file-send-error, file-error,
# file-completed, file-stopped:
# data = file_props
nicks = {} # list of our nick names in each account
@ -118,7 +118,7 @@ def get_nick_from_fjid(jid):
# fake jid is the jid for a contact in a room
# gaim@conference.jabber.no/nick/nick-continued
return jid.split('/', 1)[1]
def get_room_name_and_server_from_room_jid(jid):
room_name = get_nick_from_jid(jid)
server = get_server_from_jid(jid)
@ -169,7 +169,7 @@ def get_first_contact_instance_from_jid(account, jid):
get_room_and_nick_from_fjid(jid) # if we ban/kick we now real jid
if gc_contacts[account].has_key(room) and \
nick in gc_contacts[account][room]:
contact = gc_contacts[account][room][nick]
contact = gc_contacts[account][room][nick]
return contact
def get_contact_instance_with_highest_priority(account, jid):
@ -178,7 +178,7 @@ def get_contact_instance_with_highest_priority(account, jid):
def get_contact_name_from_jid(account, jid):
return contacts[account][jid][0].name
def get_highest_prio_contact_from_contacts(contacts):
prim_contact = None # primary contact
for contact in contacts:
@ -197,7 +197,7 @@ def construct_fjid(room_jid, nick):
if isinstance(nick, str):
nick = unicode(nick, 'utf-8')
return room_jid + '/' + nick
def get_resource_from_jid(jid):
jids = jid.split('/', 1)
if len(jids) > 1:
@ -255,7 +255,7 @@ def jid_is_transport(jid):
sms = jid.startswith('sms.')
tlen = jid.startswith('tlen.')
yahoo = jid.startswith('yahoo.')
if aim or gg or irc or icq or msn or sms or yahoo or tlen:
is_transport = True
else:

View File

@ -369,7 +369,8 @@ class PreferencesWindow:
self.applications_frame.set_no_show_all(True)
self.applications_frame.hide()
else:
self.applications_combobox = self.xml.get_widget('applications_combobox')
self.applications_combobox = self.xml.get_widget(
'applications_combobox')
if gajim.config.get('autodetect_browser_mailer'):
self.applications_combobox.set_active(0)
gtkgui_helpers.autodetect_browser_mailer()
@ -527,7 +528,7 @@ class PreferencesWindow:
def merge_windows(self, kind):
for acct in gajim.connections:
#save buffers and close windows
# save buffers and close windows
buf1 = {}
buf2 = {}
saved_var = {}
@ -539,7 +540,7 @@ class PreferencesWindow:
buf2[jid] = window.message_textviews[jid].get_buffer()
saved_var[jid] = window.save_var(jid)
window.window.destroy()
#open new tabbed chat windows
# open new tabbed chat windows
for jid in jids:
if kind == 'chats':
c = gajim.get_contact_instance_with_highest_priority(acct, jid)
@ -553,7 +554,7 @@ class PreferencesWindow:
def split_windows(self, kind):
for acct in gajim.connections:
#save buffers and close tabbed chat windows
# save buffers and close tabbed chat windows
buf1 = {}
buf2 = {}
saved_var = {}
@ -568,7 +569,7 @@ class PreferencesWindow:
buf2[jid] = window.message_textviews[jid].get_buffer()
saved_var[jid] = window.save_var(jid)
windows['tabbed'].window.destroy()
#open new tabbed chat windows
# open new tabbed chat windows
for jid in jids:
if kind == 'chats':
c = gajim.get_contact_instance_with_highest_priority(acct, jid)

View File

@ -73,11 +73,11 @@ def _gen_agent_type_info():
return {
# Defaults
(0, 0): (None, None),
# Jabber server
('server', 'im'): (ToplevelAgentBrowser, 'jabber.png'),
('services', 'jabber'): (ToplevelAgentBrowser, 'jabber.png'),
# Services
('conference', 'text'): (MucBrowser, 'conference.png'),
('headline', 'rss'): (AgentBrowser, 'rss.png'),
@ -88,7 +88,7 @@ def _gen_agent_type_info():
('directory', 'user'): (None, 'jud.png'),
('pubsub', 'generic'): (None, 'pubsub.png'),
('proxy', 'bytestreams'): (None, 'bytestreams.png'), # Socks5 FT proxy
# Transports
('conference', 'irc'): (False, 'irc.png'),
('_jid', 'irc'): (False, 'irc.png'),
@ -185,7 +185,7 @@ class Closure(object):
Weak references to methods immediatly die, even if the object is still
alive. Besides a handy way to store a callback, this provides a workaround
that keeps a reference to the object instead.
Userargs and removeargs must be tuples.'''
def __init__(self, cb, userargs = (), remove = None, removeargs = ()):
self.userargs = userargs
@ -235,7 +235,7 @@ class ServicesCache:
# Clean an empty list
if not self._cbs[cbkey]:
del self._cbs[cbkey]
def get_icon(self, identities = []):
'''Return the icon for an agent.'''
# Grab the first identity with an icon
@ -264,7 +264,7 @@ class ServicesCache:
# Store in cache
_icon_cache[filename] = pix
return pix
def get_browser(self, identities = [], features = []):
'''Return the browser class for an agent.'''
# Grab the first identity with a browser
@ -365,7 +365,7 @@ class ServicesCache:
# clean_closure may have beaten us to it
if self._cbs.has_key(cbkey):
del self._cbs[cbkey]
def agent_info_error(self, jid):
'''Callback for when a query fails. (even after the browse and agents
namespaces)'''
@ -379,7 +379,7 @@ class ServicesCache:
# clean_closure may have beaten us to it
if self._cbs.has_key(cbkey):
del self._cbs[cbkey]
def agent_items_error(self, jid):
'''Callback for when a query fails. (even after the browse and agents
namespaces)'''
@ -404,12 +404,12 @@ class ServiceDiscoveryWindow:
if not jid:
jid = gajim.config.get_per('accounts', account, 'hostname')
node = ''
self.jid = None
self.browser = None
self.children = []
self.dying = False
# Check connection
if gajim.connections[account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'),
@ -428,7 +428,8 @@ _('Without a connection, you can not browse available services')).get_response()
self.services_treeview = self.xml.get_widget('services_treeview')
# This is more reliable than the cursor-changed signal.
selection = self.services_treeview.get_selection()
selection.connect_after('changed', self.on_services_treeview_selection_changed)
selection.connect_after('changed',
self.on_services_treeview_selection_changed)
self.services_scrollwin = self.xml.get_widget('services_scrollwin')
self.progressbar = self.xml.get_widget('services_progressbar')
self.progressbar.set_no_show_all(True)
@ -446,14 +447,16 @@ _('Without a connection, you can not browse available services')).get_response()
self.address_comboboxentry = None
address_hbox = self.xml.get_widget('address_hbox')
if address_entry:
self.address_comboboxentry = self.xml.get_widget('address_comboboxentry')
self.address_comboboxentry = self.xml.get_widget(
'address_comboboxentry')
self.address_comboboxentry_entry = self.address_comboboxentry.child
self.address_comboboxentry_entry.set_activates_default(True)
liststore = gtk.ListStore(str)
self.address_comboboxentry.set_model(liststore)
self.address_comboboxentry.set_text_column(0)
self.latest_addresses = gajim.config.get('latest_disco_addresses').split()
self.latest_addresses = gajim.config.get(
'latest_disco_addresses').split()
jid = gajim.get_hostname_from_account(self.account, use_srv = True)
if jid in self.latest_addresses:
self.latest_addresses.remove(jid)
@ -472,17 +475,17 @@ _('Without a connection, you can not browse available services')).get_response()
self.xml.signal_autoconnect(self)
self.travel(jid, node)
self.window.show_all()
def _get_account(self):
return self._account
def _set_account(self, value):
self._account = value
self.cache.account = value
if self.browser:
self.browser.account = value
account = property(_get_account, _set_account)
def _initial_state(self):
'''Set some initial state on the window. Separated in a method because
it's handy to use within browser's cleanup method.'''
@ -541,7 +544,7 @@ _('Without a connection, you can not browse available services')).get_response()
if chain and not self.parent.children:
self.parent.destroy(chain = chain)
self.parent = None
def travel(self, jid, node):
'''Travel to an agent within the current services window.'''
if self.browser:
@ -558,7 +561,7 @@ _('Without a connection, you can not browse available services')).get_response()
self.jid = jid
self.node = node
self.cache.get_info(jid, node, self._travel)
def _travel(self, jid, node, identities, features, data):
'''Continuation of travel.'''
if self.dying or jid != self.jid or node != self.node:
@ -580,7 +583,7 @@ _('This type of service does not contain any items to browse.')).get_response()
self.browser = klass(self.account, jid, node)
self.browser.prepare_window(self)
self.browser.browse()
def open(self, jid, node):
'''Open an agent. By default, this happens in a new window.'''
try:
@ -608,7 +611,7 @@ _('This type of service does not contain any items to browse.')).get_response()
# user selected one of the entries so do auto-visit
jid = self.address_comboboxentry.child.get_text().decode('utf-8')
self.travel(jid, '')
def on_go_button_clicked(self, widget):
jid = self.address_comboboxentry.child.get_text().decode('utf-8')
if jid in self.latest_addresses:
@ -626,7 +629,7 @@ _('This type of service does not contain any items to browse.')).get_response()
def on_services_treeview_row_activated(self, widget, path, col = 0):
self.browser.default_action()
def on_services_treeview_selection_changed(self, widget):
self.browser.update_actions()
@ -679,13 +682,13 @@ class AgentBrowser:
self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True)
self.window.services_treeview.set_headers_visible(True)
def _clean_treemodel(self):
self.window.services_treeview.get_model().clear()
for col in self.window.services_treeview.get_columns():
self.window.services_treeview.remove_column(col)
self.window.services_treeview.set_headers_visible(False)
def _add_actions(self):
'''Add the action buttons to the buttonbox for actions the browser can
perform.'''
@ -706,7 +709,7 @@ class AgentBrowser:
if self.browse_button:
self.browse_button.destroy()
self.browse_button = None
def _set_title(self, jid, node, identities, features, data):
'''Set the window title based on agent info.'''
# Set the banner and window title
@ -714,12 +717,12 @@ class AgentBrowser:
name = identities[0]['name']
self.window.banner.set_markup('<span weight="heavy" size="large">'\
'%s</span>\n%s' % (self._get_agent_address(), name))
# Add an icon to the banner.
pix = self.cache.get_icon(identities)
self.window.banner_icon.set_from_pixbuf(pix)
self.window.banner_icon.show()
def _clean_title(self):
# Everything done here is done in window._initial_state
# This is for subclasses.
@ -730,37 +733,37 @@ class AgentBrowser:
up with a ServiceDiscoveryWindow instance.'''
self.window = window
self.cache = window.cache
self._set_initial_title()
self._create_treemodel()
self._add_actions()
# This is a hack. The buttonbox apparently doesn't care about pack_start
# or pack_end, so we repack the close button here to make sure it's last
close_button = self.window.xml.get_widget('close_button')
self.window.action_buttonbox.remove(close_button)
self.window.action_buttonbox.pack_end(close_button)
close_button.show_all()
self.update_actions()
self.active = True
self.cache.get_info(self.jid, self.node, self._set_title)
def cleanup(self):
'''Cleanup when the window intends to switch browsers.'''
self.active = False
self._clean_actions()
self._clean_treemodel()
self._clean_title()
self.window._initial_state()
def update_theme(self):
'''Called when the default theme is changed.'''
pass
def on_browse_button_clicked(self, widget = None):
'''When we want to browse an agent:
Open a new services window with a browser for the agent type.'''
@ -784,7 +787,7 @@ class AgentBrowser:
node = model[iter][1].decode('utf-8')
if jid:
self.cache.get_info(jid, node, self._update_actions, nofetch = True)
def _update_actions(self, jid, node, identities, features, data):
'''Continuation of update_actions.'''
if not identities or not self.browse_button:
@ -792,7 +795,7 @@ class AgentBrowser:
klass = self.cache.get_browser(identities, features)
if klass:
self.browse_button.set_sensitive(True)
def default_action(self):
'''When we double-click a row:
perform the default action on the selected item.'''
@ -803,7 +806,7 @@ class AgentBrowser:
node = model[iter][1].decode('utf-8')
if jid:
self.cache.get_info(jid, node, self._default_action, nofetch = True)
def _default_action(self, jid, node, identities, features, data):
'''Continuation of default_action.'''
if self.cache.get_browser(identities, features):
@ -820,16 +823,16 @@ class AgentBrowser:
self.window.progressbar.pulse()
self.window.progressbar.show()
self._pulse_timeout = gobject.timeout_add(250, self._pulse_timeout_cb)
self.cache.get_items(self.jid, self.node, self._agent_items,
self.cache.get_items(self.jid, self.node, self._agent_items,
force = force, args = (force,))
def _pulse_timeout_cb(self, *args):
'''Simple callback to keep the progressbar pulsing.'''
if not self.active:
return False
self.window.progressbar.pulse()
return True
def _find_item(self, jid, node):
'''Check if an item is already in the treeview. Return an iter to it
if so, None otherwise.'''
@ -844,7 +847,7 @@ class AgentBrowser:
if iter:
return iter
return None
def _agent_items(self, jid, node, items, force):
'''Callback for when we receive a list of agent items.'''
model = self.window.services_treeview.get_model()
@ -870,7 +873,7 @@ _('This service does not contain any items to browse.')).get_response()
# Not in the treeview
self._total_items += 1
self._add_item(model, jid, node, item, force)
def _agent_info(self, jid, node, identities, features, data):
'''Callback for when we receive info about an agent's item.'''
addr = get_agent_address(jid, node)
@ -904,7 +907,7 @@ _('This service does not contain any items to browse.')).get_response()
'''Called when an item should be updated in the model with further info.
The result of a disco#info query.'''
model[iter][2] = identities[0].get('name', '')
def _update_error(self, model, iter, jid, node):
'''Called when a disco#info query failed for an item.'''
pass
@ -933,7 +936,7 @@ class ToplevelAgentBrowser(AgentBrowser):
cell.set_property('pixbuf', pix)
else:
cell.set_property('visible', False)
def _text_renderer_data_func(self, col, cell, model, iter):
'''Callback for setting the text renderer's properties.'''
jid = model.get_value(iter, 0)
@ -985,7 +988,7 @@ class ToplevelAgentBrowser(AgentBrowser):
(position[0], position[1] + rect.y))
else:
self.tooltip.hide_tooltip()
# These are all callbacks to make tooltips work
def on_treeview_leave_notify_event(self, widget, event):
model = widget.get_model()
@ -1030,7 +1033,7 @@ class ToplevelAgentBrowser(AgentBrowser):
model.set_sort_column_id(4, gtk.SORT_ASCENDING)
view = self.window.services_treeview
view.set_model(model)
col = gtk.TreeViewColumn()
# Icon Renderer
renderer = gtk.CellRendererPixbuf()
@ -1045,10 +1048,10 @@ class ToplevelAgentBrowser(AgentBrowser):
# Save this so we can go along with theme changes
self._renderer = renderer
self.update_theme()
view.insert_column(col, -1)
col.set_resizable(True)
# Connect signals
scrollwin = self.window.services_scrollwin
self._view_signals.append(view.connect('leave-notify-event',
@ -1061,7 +1064,7 @@ class ToplevelAgentBrowser(AgentBrowser):
self.on_treeview_event_hide_tooltip))
self._scroll_signal = scrollwin.connect('scroll-event',
self.on_treeview_event_hide_tooltip)
def _clean_treemodel(self):
# Disconnect signals
view = self.window.services_treeview
@ -1073,7 +1076,7 @@ class ToplevelAgentBrowser(AgentBrowser):
scrollwin.disconnect(self._scroll_signal)
self._scroll_signal = None
AgentBrowser._clean_treemodel(self)
def _add_actions(self):
AgentBrowser._add_actions(self)
self.register_button = gtk.Button(label=_("Re_gister"),
@ -1103,14 +1106,14 @@ class ToplevelAgentBrowser(AgentBrowser):
def cleanup(self):
self.tooltip.hide_tooltip()
AgentBrowser.cleanup(self)
def update_theme(self):
theme = gajim.config.get('roster_theme')
bgcolor = gajim.config.get_per('themes', theme, 'groupbgcolor')
if bgcolor:
self._renderer.set_property('cell-background', bgcolor)
self.window.services_treeview.queue_draw()
def on_register_button_clicked(self, widget = None):
'''When we want to register an agent:
request information about registering with the agent and close the
@ -1190,7 +1193,7 @@ class ToplevelAgentBrowser(AgentBrowser):
self.register_button.set_sensitive(True)
if self.join_button and xmpp.NS_MUC in features:
self.join_button.set_sensitive(True)
def _default_action(self, jid, node, identities, features, data):
if AgentBrowser._default_action(self, jid, node, identities, features, data):
return True
@ -1203,7 +1206,7 @@ class ToplevelAgentBrowser(AgentBrowser):
def browse(self, force = False):
self._progress = 0
AgentBrowser.browse(self, force = force)
def _expand_all(self):
'''Expand all items in the treeview'''
# GTK apparently screws up here occasionally. :/
@ -1214,7 +1217,7 @@ class ToplevelAgentBrowser(AgentBrowser):
#self.expanding = True
#gobject.idle_add(expand_all)
self.window.services_treeview.expand_all()
def _update_progressbar(self):
'''Update the progressbar.'''
# Refresh this every update
@ -1236,13 +1239,13 @@ class ToplevelAgentBrowser(AgentBrowser):
id = gobject.timeout_add(20000, self._hide_progressbar_cb)
self._progressbar_sourceid = id
self.window.progressbar.set_fraction(fraction)
def _hide_progressbar_cb(self, *args):
'''Simple callback to hide the progressbar a second after we finish.'''
if self.active:
self.window.progressbar.hide()
return False
def _friendly_category(self, category, type=None):
'''Get the friendly category name and priority.'''
cat = None
@ -1258,13 +1261,13 @@ class ToplevelAgentBrowser(AgentBrowser):
except KeyError:
cat, prio = _cat_to_descr['other']
return cat, prio
def _create_category(self, cat, type=None):
'''Creates a category row.'''
model = self.window.services_treeview.get_model()
cat, prio = self._friendly_category(cat, type)
return model.append(None, ('', '', None, cat, prio))
def _find_category(self, cat, type=None):
'''Looks up a category row and returns the iterator to it, or None.'''
model = self.window.services_treeview.get_model()
@ -1277,7 +1280,7 @@ class ToplevelAgentBrowser(AgentBrowser):
if iter:
return iter
return None
def _find_item(self, jid, node):
model = self.window.services_treeview.get_model()
iter = None
@ -1340,7 +1343,7 @@ class ToplevelAgentBrowser(AgentBrowser):
descr = "<b>%s</b>\n%s" % (name, addr)
else:
descr = "<b>%s</b>" % addr
# Update progress
self._progress += 1
self._update_progressbar()
@ -1365,13 +1368,13 @@ class ToplevelAgentBrowser(AgentBrowser):
return
# Not in the right category, move it.
model.remove(iter)
# Check if the old category is empty
if not model.iter_is_valid(old_cat_iter):
old_cat_iter = self._find_category(old_cat)
if not model.iter_children(old_cat_iter):
model.remove(old_cat_iter)
cat_iter = self._find_category(cat, type)
if not cat_iter:
cat_iter = self._create_category(cat, type)
@ -1389,7 +1392,7 @@ class MucBrowser(AgentBrowser):
def __init__(self, *args, **kwargs):
AgentBrowser.__init__(self, *args, **kwargs)
self.join_button = None
def _create_treemodel(self):
# JID, node, name, users, description, fetched
# This is rather long, I'd rather not use a data_func here though.
@ -1437,9 +1440,9 @@ class MucBrowser(AgentBrowser):
self.vadj.disconnect(self.vadj_cbid)
self.vadj_cbid = None
AgentBrowser._clean_treemodel(self)
def _add_actions(self):
self.join_button = gtk.Button(label=_("_Join"), use_underline=True)
self.join_button = gtk.Button(label=_('_Join'), use_underline=True)
self.join_button.connect('clicked', self.on_join_button_clicked)
self.window.action_buttonbox.add(self.join_button)
self.join_button.show_all()

View File

@ -185,7 +185,7 @@ class RosterWindow:
typestr = 'contact'
if g == _('Transports'):
typestr = 'agent'
# we add some values here. see draw_contact for more
model.append(iterG, (None, user.name,
typestr, user.jid, account, False, None))
@ -351,15 +351,15 @@ class RosterWindow:
def on_delete_motd_menuitem_activate(self, widget, account):
server = gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd/delete'
gajim.connections[account].send_motd(server)
gajim.connections[account].send_motd(server)
def on_online_users_menuitem_activate(self, widget, account):
pass #FIXME: impement disco in users for 0.9
def get_and_connect_advanced_menuitem_menu(self, account):
xml = gtk.glade.XML(GTKGUI_GLADE, 'advanced_menuitem_menu', APP)
advanced_menuitem_menu = xml.get_widget('advanced_menuitem_menu')
send_single_message_menuitem = xml.get_widget(
'send_single_message_menuitem')
xml_console_menuitem = xml.get_widget('xml_console_menuitem')
@ -370,7 +370,7 @@ class RosterWindow:
set_motd_menuitem = xml.get_widget('set_motd_menuitem')
update_motd_menuitem = xml.get_widget('update_motd_menuitem')
delete_motd_menuitem = xml.get_widget('delete_motd_menuitem')
send_single_message_menuitem.connect('activate',
self.on_send_single_message_menuitem_activate, account)
@ -391,12 +391,12 @@ class RosterWindow:
update_motd_menuitem.connect('activate',
self.on_update_motd_menuitem_activate, account)
delete_motd_menuitem.connect('activate',
self.on_delete_motd_menuitem_activate, account)
advanced_menuitem_menu.show_all()
return advanced_menuitem_menu
def make_menu(self):
@ -409,7 +409,7 @@ class RosterWindow:
show_offline_contacts_menuitem = self.xml.get_widget(
'show_offline_contacts_menuitem')
profile_avatar_menuitem = self.xml.get_widget('profile_avatar_menuitem')
# make it sensitive. it is insensitive only if no accounts are *available*
advanced_menuitem.set_sensitive(True)
@ -423,12 +423,12 @@ class RosterWindow:
service_disco_menuitem.handler_disconnect(
self.service_disco_handler_id)
self.service_disco_handler_id = None
if self.new_message_menuitem_handler_id:
new_message_menuitem.handler_disconnect(
self.new_message_menuitem_handler_id)
self.new_message_menuitem_handler_id = None
#remove the existing submenus
add_new_contact_menuitem.remove_submenu()
service_disco_menuitem.remove_submenu()
@ -460,7 +460,7 @@ class RosterWindow:
item.add(label)
item.connect('state-changed', self.on_bm_header_changed_state)
sub_menu.append(item)
item = gtk.MenuItem(_('_Join New Room'))
item.connect('activate', self.on_join_gc_activate, account)
sub_menu.append(item)
@ -475,7 +475,7 @@ class RosterWindow:
#and make sure it works
newitem = gtk.SeparatorMenuItem() # seperator
sub_menu.append(newitem)
newitem = gtk.ImageMenuItem(_('Manage Bookmarks...'))
img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
gtk.ICON_SIZE_MENU)
@ -496,7 +496,7 @@ class RosterWindow:
item.connect('activate', self.on_add_new_contact, account)
add_new_contact_menuitem.set_submenu(sub_menu)
sub_menu.show_all()
#disco
sub_menu = gtk.Menu()
for account in gajim.connections:
@ -510,7 +510,7 @@ class RosterWindow:
service_disco_menuitem.set_submenu(sub_menu)
sub_menu.show_all()
#new message
sub_menu = gtk.Menu()
for account in gajim.connections:
@ -519,12 +519,12 @@ class RosterWindow:
continue
item = gtk.MenuItem(_('using account %s') % account)
sub_menu.append(item)
item.connect('activate', self.on_new_message_menuitem_activate,
item.connect('activate', self.on_new_message_menuitem_activate,
account)
new_message_menuitem.set_submenu(sub_menu)
sub_menu.show_all()
#Advanced Actions
sub_menu = gtk.Menu()
for account in gajim.connections:
@ -533,10 +533,10 @@ class RosterWindow:
advanced_menuitem_menu = self.get_and_connect_advanced_menuitem_menu(
account)
item.set_submenu(advanced_menuitem_menu)
advanced_menuitem.set_submenu(sub_menu)
sub_menu.show_all()
else:
if len(gajim.connections) == 1: # user has only one account
#add
@ -545,13 +545,13 @@ class RosterWindow:
'activate', self.on_add_new_contact, gajim.connections.keys()[0])
#disco
if not self.service_disco_handler_id:
self.service_disco_handler_id = service_disco_menuitem.connect(
'activate', self.on_service_disco_menuitem_activate,
self.service_disco_handler_id = service_disco_menuitem.connect(
'activate', self.on_service_disco_menuitem_activate,
gajim.connections.keys()[0])
#new msg
if not self.new_message_menuitem_handler_id:
self.new_message_menuitem_handler_id = new_message_menuitem.\
connect('activate', self.on_new_message_menuitem_activate,
connect('activate', self.on_new_message_menuitem_activate,
gajim.connections.keys()[0])
#new msg accel
if not self.have_new_message_accel:
@ -559,7 +559,7 @@ class RosterWindow:
new_message_menuitem.add_accelerator('activate', ag,
gtk.keysyms.n, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
self.have_new_message_accel = True
account = gajim.connections.keys()[0]
advanced_menuitem_menu = self.get_and_connect_advanced_menuitem_menu(
account)
@ -567,11 +567,10 @@ class RosterWindow:
elif len(gajim.connections) == 0: # user has no accounts
advanced_menuitem.set_sensitive(False)
#FIXME: Gajim 0.9 should have this visible
profile_avatar_menuitem.set_no_show_all(True)
profile_avatar_menuitem.hide()
if at_least_one_account_connected:
new_message_menuitem.set_sensitive(True)
join_gc_menuitem.set_sensitive(True)
@ -704,7 +703,7 @@ class RosterWindow:
uf_show = helpers.get_uf_show(show)
gajim.interface.instances[account]['chats'][jid].print_conversation(
_('%s is now %s (%s)') % (name, uf_show, status), jid, 'status')
if contact == gajim.get_contact_instance_with_highest_priority(\
account, contact.jid):
gajim.interface.instances[account]['chats'][jid].draw_name_banner(contact)
@ -773,12 +772,12 @@ class RosterWindow:
contacts = []
connection = gajim.connections[account]
# get our current contact info
contact = Contact(jid = jid, name = account,
show = connection.get_status(),
contact = Contact(jid = jid, name = account,
show = connection.get_status(),
sub = 'both',
status = connection.status,
status = connection.status,
resource = gajim.config.get_per('accounts', connection.name,
'resource'),
'resource'),
priority = gajim.config.get_per('accounts', connection.name,
'priority'),
keyID = gajim.config.get_per('accounts', connection.name,
@ -794,9 +793,9 @@ class RosterWindow:
show = roster.getShow(jid+'/'+resource)
if not show:
show = 'online'
contact = Contact(jid=jid, name=account,
contact = Contact(jid=jid, name=account,
show=show,
status=roster.getStatus(jid+'/'+resource), resource=resource,
status=roster.getStatus(jid+'/'+resource), resource=resource,
priority=roster.getPriority(jid+'/'+resource))
contacts.append(contact)
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
@ -843,10 +842,10 @@ class RosterWindow:
# we then select Rename and focus-in
# focus-in callback checks on this var and if is NOT None
# it redraws the selected contact resulting in stopping our rename
# procedure. So set this to None to stop that
# procedure. So set this to None to stop that
self._last_selected_contact = None
model = self.tree.get_model()
row_type = model[iter][C_TYPE]
jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8')
@ -859,7 +858,7 @@ class RosterWindow:
model[iter][C_EDITABLE] = True # set 'editable' to True
self.tree.set_cursor(path, self.tree.get_column(0), True)
def on_assign_pgp_key(self, widget, user, account):
attached_keys = gajim.config.get_per('accounts', account,
'attached_gpg_keys').split()
@ -893,7 +892,7 @@ class RosterWindow:
def on_edit_groups(self, widget, user, account):
dlg = dialogs.EditGroupsDialog(user, account)
dlg.run()
def on_history(self, widget, contact, account):
'''When history menuitem is activated: call log window'''
if gajim.interface.instances['logs'].has_key(contact.jid):
@ -908,11 +907,11 @@ class RosterWindow:
dialogs.SingleMessageWindow(account, action = 'send')
else:
dialogs.SingleMessageWindow(account, contact.jid, 'send')
def on_send_file_menuitem_activate(self, widget, account, contact):
gajim.interface.instances['file_transfers'].show_file_send_request(
gajim.interface.instances['file_transfers'].show_file_send_request(
account, contact)
def mk_menu_user(self, event, iter):
'''Make contact's popup menu'''
model = self.tree.get_model()
@ -921,13 +920,13 @@ class RosterWindow:
account = model[iter][C_ACCOUNT].decode('utf-8')
contact = gajim.get_highest_prio_contact_from_contacts(
gajim.contacts[account][jid])
xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_contact_context_menu',
APP)
roster_contact_context_menu = xml.get_widget(
'roster_contact_context_menu')
childs = roster_contact_context_menu.get_children()
start_chat_menuitem = childs[0]
send_single_message_menuitem = childs[1]
rename_menuitem = childs[2]
@ -936,7 +935,7 @@ class RosterWindow:
assign_openpgp_separator = childs[4]
send_file_menuitem = childs[5]
assign_openpgp_key_menuitem = childs[6]
#skip a seperator
send_auth_menuitem, ask_auth_menuitem, revoke_auth_menuitem =\
childs[8].get_submenu().get_children()
@ -945,15 +944,15 @@ class RosterWindow:
#skip a seperator
information_menuitem = childs[12]
history_menuitem = childs[13]
if contact.resource:
send_file_menuitem.connect('activate',
self.on_send_file_menuitem_activate, account, contact)
else: # if we do not have resource we cannot send file
send_file_menuitem.hide()
send_file_menuitem.set_no_show_all(True)
start_chat_menuitem.connect('activate',
self.on_roster_treeview_row_activated, path)
send_single_message_menuitem.connect('activate',
@ -993,7 +992,7 @@ class RosterWindow:
else:
revoke_auth_menuitem.connect('activate', self.revoke_auth, jid,
account)
else: # contact is in group 'not in the roster'
add_to_roster_menuitem.set_no_show_all(False)
edit_groups_menuitem.hide()
@ -1003,7 +1002,7 @@ class RosterWindow:
assign_openpgp_separator.set_no_show_all(True)
assign_openpgp_key_menuitem.hide()
assign_openpgp_key_menuitem.set_no_show_all(True)
add_to_roster_menuitem.connect('activate',
self.on_add_to_roster, contact, account)
@ -1017,7 +1016,7 @@ class RosterWindow:
'''Make group's popup menu'''
model = self.tree.get_model()
path = model.get_path(iter)
menu = gtk.Menu()
rename_item = gtk.ImageMenuItem(_('Re_name'))
@ -1028,10 +1027,10 @@ class RosterWindow:
rename_item.connect('activate', self.on_rename, iter, path)
event_button = self.get_possible_button_event(event)
menu.popup(None, None, None, event_button, event.time)
menu.show_all()
def mk_menu_agent(self, event, iter):
'''Make agent's popup menu'''
model = self.tree.get_model()
@ -1040,7 +1039,7 @@ class RosterWindow:
account = model[iter][C_ACCOUNT].decode('utf-8')
user = gajim.get_contact_instance_with_highest_priority(account, jid)
menu = gtk.Menu()
item = gtk.ImageMenuItem(_('_Log on'))
icon = gtk.image_new_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)
item.set_image(icon)
@ -1085,14 +1084,14 @@ class RosterWindow:
else:
gajim.interface.instances[account]['account_modification'] = \
config.AccountModificationWindow(account)
def get_possible_button_event(self, event):
'''mouse or keyboard caused the event?'''
if event.type == gtk.gdk.KEY_PRESS:
event_button = 0 # no event.button so pass 0
else: # BUTTON_PRESS event, so pass event.button
event_button = event.button
return event_button
def on_change_status_message_activate(self, widget, account):
@ -1116,7 +1115,7 @@ class RosterWindow:
xml = gtk.glade.XML(GTKGUI_GLADE, 'account_context_menu', APP)
account_context_menu = xml.get_widget('account_context_menu')
childs = account_context_menu.get_children()
status_menuitem = childs[0]
# we skip the seperator
# skip advanced_actions_menuitem, childs[2]
@ -1129,7 +1128,7 @@ class RosterWindow:
add_contact_menuitem = childs[5]
join_group_chat_menuitem = childs[6]
new_message_menuitem = childs[7]
sub_menu = gtk.Menu()
status_menuitem.set_submenu(sub_menu)
@ -1312,7 +1311,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.tree.get_selection().select_path(path)
self.show_appropriate_context_menu(event, iter)
return True
def on_roster_treeview_button_press_event(self, widget, event):
@ -1320,7 +1319,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.tooltip.hide_tooltip()
if event.button == 3: # Right click
try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
self.tree.get_selection().unselect_all()
@ -1330,10 +1329,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
iter = model.get_iter(path)
self.show_appropriate_context_menu(event, iter)
return True
if event.button == 2: # Middle click
try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
self.tree.get_selection().unselect_all()
@ -1373,10 +1372,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
current_show = gajim.SHOW_LIST[gajim.connections[acct].connected]
self.send_status(acct, current_show, message)
return True
if event.button == 1: # Left click
try:
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
self.tree.get_selection().unselect_all()
@ -1411,9 +1410,9 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
user1 = Contact(jid = user.jid, name = user.name,
groups = [_('not in the roster')], show = 'not in the roster',
status = '', ask = 'none', keyID = user.keyID)
gajim.contacts[account][user.jid] = [user1]
self.add_contact_to_roster(user.jid, account)
gajim.contacts[account][user.jid] = [user1]
self.add_contact_to_roster(user.jid, account)
def forget_gpg_passphrase(self, keyid):
if self.gpg_passphrase.has_key(keyid):
del self.gpg_passphrase[keyid]
@ -1439,7 +1438,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
passphrase = ''
w = dialogs.PassphraseDialog(
_('Password Required'),
_('Enter your password for account %s') % account,
_('Enter your password for account %s') % account,
_('Save password'))
passphrase, save = w.run()
if passphrase == -1:
@ -1460,12 +1459,12 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
if use_gpg_agent:
save_gpg_pass = False
else:
save_gpg_pass = gajim.config.get_per('accounts', account,
save_gpg_pass = gajim.config.get_per('accounts', account,
'savegpgpass')
keyid = gajim.config.get_per('accounts', account, 'keyid')
if keyid and gajim.connections[account].connected < 2 and \
gajim.config.get('usegpg'):
if use_gpg_agent:
self.gpg_passphrase[keyid] = None
else:
@ -1478,7 +1477,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
else:
w = dialogs.PassphraseDialog(
_('Passphrase Required'),
_('Enter GPG key passphrase for account %s') % account,
_('Enter GPG key passphrase for account %s') % account,
_('Save passphrase'))
passphrase, save = w.run()
if passphrase == -1:
@ -1488,14 +1487,14 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
if save:
gajim.config.set_per('accounts', account, 'savegpgpass', True)
gajim.config.set_per('accounts', account, 'gpgpassword',
gajim.config.set_per('accounts', account, 'gpgpassword',
passphrase)
gajim.connections[account].gpg_passphrase(passphrase)
for room_jid in gajim.interface.instances[account]['gc']:
if room_jid != 'tabbed':
nick = gajim.interface.instances[account]['gc'][room_jid].nicks[room_jid]
gajim.connections[account].send_gc_status(nick, room_jid, status,
gajim.connections[account].send_gc_status(nick, room_jid, status,
txt)
gajim.connections[account].change_status(status, txt, sync, auto)
if status == 'online' and gajim.interface.sleeper.getState() != \
@ -1573,7 +1572,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
bug_user = False
for acct in accounts:
if not one_connected or gajim.connections[acct].connected > 1:
if not gajim.config.get_per('accounts', acct,
if not gajim.config.get_per('accounts', acct,
'sync_with_global_status'):
continue
# We're going to change our status to invisible
@ -1599,7 +1598,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
if not one_connected or gajim.connections[acct].connected > 1:
self.send_status(acct, status, message)
self.update_status_combobox()
def update_status_combobox(self):
# table to change index in connection.connected to index in combobox
table = {'offline':9, 'connecting':9, 'online':0, 'chat':1, 'away':2,
@ -1633,7 +1632,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.chg_contact_status(user, 'offline', 'Disconnected', account)
self.update_status_combobox()
self.make_menu()
def new_chat(self, contact, account):
chats = gajim.interface.instances[account]['chats']
if gajim.config.get('usetabbedchat'):
@ -1661,7 +1660,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
groups = [_('not in the roster')], show = 'not in the roster',
status = '', sub = 'none', keyID = keyID)
gajim.contacts[account][jid] = [contact]
self.add_contact_to_roster(contact.jid, account)
self.add_contact_to_roster(contact.jid, account)
if not gajim.interface.instances[account]['chats'].has_key(jid):
self.new_chat(contact, account)
@ -1693,7 +1692,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
user1 = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('not in the roster')], show = 'not in the roster',
status = '', ask = 'none', keyID = keyID, resource = resource)
gajim.contacts[account][jid] = [user1]
gajim.contacts[account][jid] = [user1]
self.add_contact_to_roster(jid, account)
iters = self.get_contact_iter(jid, account)
@ -1721,7 +1720,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
action = 'receive', from_whom = jid, subject = subject,
message = msg, resource = resource)
return
# We print if window is opened and it's not a single message
if gajim.interface.instances[account]['chats'].has_key(jid) and \
msg_type != 'normal':
@ -1792,10 +1791,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
def on_new_message_menuitem_activate(self, widget, account):
dialogs.NewMessageDialog(account)
def on_contents_menuitem_activate(self, widget):
helpers.launch_browser_mailer('url', 'http://trac.gajim.org/wiki')
def on_faq_menuitem_activate(self, widget):
helpers.launch_browser_mailer('url', 'http://trac.gajim.org/wiki/GajimFaq')
@ -1806,7 +1805,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
if gajim.interface.instances.has_key('accounts'):
gajim.interface.instances['accounts'].window.present()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
gajim.interface.instances['accounts'] = config.AccountsWindow()
def on_file_transfers_menuitem_activate(self, widget):
if gajim.interface.instances['file_transfers'].window.get_property('visible'):
@ -1824,7 +1823,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.close_all(w)
else:
w.window.destroy()
def on_roster_window_delete_event(self, widget, event):
'''When we want to close the window'''
if gajim.interface.systray_enabled and not gajim.config.get('quit_on_roster_x_button'):
@ -1854,7 +1853,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
if widget.props.urgency_hint:
widget.props.urgency_hint = False
# if a contact row is selected, update colors (eg. for status msg)
# because gtk engines may differ in bg when window is selected
# or not
@ -1942,7 +1941,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
return
if recent:
dialog = dialogs.ConfirmationDialog(_('You have unread messages'),
dialog = dialogs.ConfirmationDialog(_('You have unread messages'),
_('Messages will only be available for reading them later if you have history enabled.'))
if dialog.get_response() != gtk.RESPONSE_OK:
return
@ -2060,7 +2059,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
''' start editing a cell in the tree '''
path = self.tree.get_cursor()[0]
self.editing_path = path
def on_editing_canceled(self, cell):
'''editing has been canceled'''
path = self.tree.get_cursor()[0]
@ -2121,10 +2120,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
user.groups.remove(old_name)
user.groups.append(new_text)
self.add_contact_to_roster(user.jid, account)
gajim.connections[account].update_contact(user.jid, user.name,
gajim.connections[account].update_contact(user.jid, user.name,
user.groups)
model.set_value(iter, 5, False)
def on_service_disco_menuitem_activate(self, widget, account):
server_jid = gajim.config.get_per('accounts', account, 'hostname')
if gajim.interface.instances[account]['disco'].has_key(server_jid):
@ -2142,7 +2141,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
'dnd', 'invisible', 'offline', 'error', 'requested',
'message', 'opened', 'closed', 'not in the roster',
'muc_active'):
# try to open a pixfile with the correct method
state_file = state.replace(' ', '_')
files = []
@ -2185,7 +2184,8 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
# Update opened chat windows
for jid in gajim.interface.instances[account]['chats']:
if jid != 'tabbed':
gajim.interface.instances[account]['chats'][jid].set_state_image(jid)
gajim.interface.instances[account]['chats'][jid].set_state_image(
jid)
# Update opened groupchat windows
gcs = gajim.interface.instances[account]['gc']
if gcs.has_key('tabbed'):
@ -2244,7 +2244,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
renderer.set_property('cell-background', None)
renderer.set_property('xalign', 1)
renderer.set_property('width', 20)
def nameCellDataFunc(self, column, renderer, model, iter, data = None):
'''When a row is added, set properties for name renderer'''
theme = gajim.config.get('roster_theme')
@ -2259,7 +2259,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
renderer.set_property('cell-background', color)
else:
renderer.set_property('cell-background', None)
renderer.set_property('font',
renderer.set_property('font',
gtkgui_helpers.get_theme_font_for_option(theme, 'accountfont'))
renderer.set_property('xpad', 0)
renderer.set_property('width', 3)
@ -2468,7 +2468,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
elif self.nb_unread == 1:
start = '* '
self.window.set_title(start + 'Gajim')
gtkgui_helpers.set_unset_urgency_hint(self.window, self.nb_unread)
def iter_is_separator(self, model, iter):
@ -2520,7 +2520,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.tree = self.xml.get_widget('roster_treeview')
self.tree.get_selection().connect('changed',
self._on_treeview_selection_changed)
self._last_selected_contact = None # None or holds jid, account tupple
self.nb_unread = 0
self.last_save_dir = None
@ -2551,14 +2551,14 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
model.set_sort_column_id(1, gtk.SORT_ASCENDING)
self.tree.set_model(model)
self.make_jabber_state_images()
#FIXME: why do we init this dict of dicts here?
#for loop below does it. maybe so we're sure we always have the keys?
#eventhough childs can be empty? I don't get it
self.transports_state_images = { 'aim': {}, 'gadugadu': {}, 'irc': {},
'icq': {}, 'msn': {}, 'sms': {}, 'tlen': {}, 'weather': {},
'yahoo': {} }
path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports')
folders = os.listdir(path)
for transport in folders:
@ -2574,7 +2574,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
cell = cell_renderer_image.CellRendererImage()
self.status_combobox.pack_start(cell, False)
# img to show is in in 2nd column of liststore
self.status_combobox.add_attribute(cell, 'image', 1)
# if it will be sensitive or not it is in the fourth column
@ -2610,15 +2610,15 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
uf_show = helpers.get_uf_show('offline')
liststore.append([uf_show, self.jabber_state_images['offline'],
'offline', True])
status_combobox_items = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible',
'separator1', 'change_status_msg', 'separator2', 'offline']
self.status_combobox.set_model(liststore)
# default to offline
number_of_menuitem = status_combobox_items.index('offline')
self.status_combobox.set_active(number_of_menuitem)
# holds index to previously selected item so if "change status message..."
# is selected we can fallback to previously selected item and not stay
# with that item selected
@ -2629,10 +2629,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
showOffline)
# columns
# this col has two cells: first one img, second one text
col = gtk.TreeViewColumn()
render_image = cell_renderer_image.CellRendererImage() # show img or +-
col.pack_start(render_image, expand = False)
col.add_attribute(render_image, 'image', C_IMG)
@ -2646,7 +2646,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
col.add_attribute(render_text, 'markup', C_NAME) # where we hold the name
col.add_attribute(render_text, 'editable', C_EDITABLE) # where we hold if the row is editable
col.set_cell_data_func(render_text, self.nameCellDataFunc, None)
render_pixbuf = gtk.CellRendererPixbuf() # tls or avatar img
col.pack_start(render_pixbuf, expand = False)
col.add_attribute(render_pixbuf, 'pixbuf', C_SECPIXBUF)
@ -2654,7 +2654,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
None)
self.tree.append_column(col)
#do not show gtk arrows workaround
col = gtk.TreeViewColumn()
render_pixbuf = gtk.CellRendererPixbuf()

View File

@ -296,7 +296,8 @@ class SystrayWin32(systray.Systray):
self.systray_winapi.notify_icon.set_tooltip(text)
def set_img(self):
self.tray_ico_imgs = self.load_icos()
self.tray_ico_imgs = self.load_icos() #FIXME: do not do this here
# see gajim.interface.roster.reload_jabber_state_images() to merge
self.systray_winapi.remove_notify_icon()
if len(self.jids) > 0:
state = 'message'