changeset 99da57220c15 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=99da57220c15
description: New portion of doc-string refactoring
diffstat:
src/disco.py | 388 +++++++++++++++++++++++++++++++++--------------
src/features_window.py | 4 +-
src/filetransfers_window.py | 85 +++++++---
src/gajim-remote.py | 36 +++-
src/gajim_themes_window.py | 31 ++-
src/groups.py | 13 +-
src/gtkgui_helpers.py | 196 ++++++++++++++++--------
src/gui_interface.py | 83 ++++++----
src/gui_menu_builder.py | 22 +-
src/history_manager.py | 49 +++--
10 files changed, 614 insertions(+), 293 deletions(-)
diffs (truncated from 2120 to 300 lines):
diff -r 291a8d7f1410 -r 99da57220c15 src/disco.py
--- a/src/disco.py Wed Nov 25 16:51:26 2009 +0100
+++ b/src/disco.py Wed Nov 25 19:52:56 2009 +0200
@@ -124,16 +124,21 @@
class CacheDictionary:
- '''A dictionary that keeps items around for only a specific time.
- Lifetime is in minutes. Getrefresh specifies whether to refresh when
- an item is merely accessed instead of set aswell.'''
+ """
+ A dictionary that keeps items around for only a specific time. Lifetime is
+ in minutes. Getrefresh specifies whether to refresh when an item is merely
+ accessed instead of set aswell
+ """
+
def __init__(self, lifetime, getrefresh = True):
self.lifetime = lifetime * 1000 * 60
self.getrefresh = getrefresh
self.cache = {}
class CacheItem:
- '''An object to store cache items and their timeouts.'''
+ """
+ An object to store cache items and their timeouts
+ """
def __init__(self, value):
self.value = value
self.source = None
@@ -149,13 +154,17 @@
del self.cache[key]
def _expire_timeout(self, key):
- '''The timeout has expired, remove the object.'''
+ """
+ The timeout has expired, remove the object
+ """
if key in self.cache:
del self.cache[key]
return False
def _refresh_timeout(self, key):
- '''The object was accessed, refresh the timeout.'''
+ """
+ The object was accessed, refresh the timeout
+ """
item = self.cache[key]
if item.source:
gobject.source_remove(item.source)
@@ -187,20 +196,25 @@
_icon_cache = CacheDictionary(15)
def get_agent_address(jid, node = None):
- '''Returns an agent's address for displaying in the GUI.'''
+ """
+ Get an agent's address for displaying in the GUI
+ """
if node:
return '%s@%s' % (node, str(jid))
else:
return str(jid)
class Closure(object):
- '''A weak reference to a callback with arguments as an object.
+ """
+ A weak reference to a callback with arguments as an 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.'''
+ Userargs and removeargs must be tuples.
+ """
+
def __init__(self, cb, userargs = (), remove = None, removeargs = ()):
self.userargs = userargs
self.remove = remove
@@ -229,8 +243,11 @@
class ServicesCache:
- '''Class that caches our query results. Each connection will have it's own
- ServiceCache instance.'''
+ """
+ Class that caches our query results. Each connection will have it's own
+ ServiceCache instance
+ """
+
def __init__(self, account):
self.account = account
self._items = CacheDictionary(0, getrefresh = False)
@@ -256,7 +273,9 @@
del self._cbs[cbkey]
def get_icon(self, identities = []):
- '''Return the icon for an agent.'''
+ """
+ Return the icon for an agent
+ """
# Grab the first identity with an icon
for identity in identities:
try:
@@ -284,7 +303,9 @@
return pix
def get_browser(self, identities=[], features=[]):
- '''Return the browser class for an agent.'''
+ """
+ Return the browser class for an agent
+ """
# First pass, we try to find a ToplevelAgentBrowser
for identity in identities:
try:
@@ -316,7 +337,9 @@
return None
def get_info(self, jid, node, cb, force = False, nofetch = False, args = ()):
- '''Get info for an agent.'''
+ """
+ Get info for an agent
+ """
addr = get_agent_address(jid, node)
# Check the cache
if addr in self._info:
@@ -338,7 +361,9 @@
gajim.connections[self.account].discoverInfo(jid, node)
def get_items(self, jid, node, cb, force = False, nofetch = False, args = ()):
- '''Get a list of items in an agent.'''
+ """
+ Get a list of items in an agent
+ """
addr = get_agent_address(jid, node)
# Check the cache
if addr in self._items:
@@ -360,7 +385,9 @@
gajim.connections[self.account].discoverItems(jid, node)
def agent_info(self, jid, node, identities, features, data):
- '''Callback for when we receive an agent's info.'''
+ """
+ Callback for when we receive an agent's info
+ """
addr = get_agent_address(jid, node)
# Store in cache
@@ -376,7 +403,9 @@
del self._cbs[cbkey]
def agent_items(self, jid, node, items):
- '''Callback for when we receive an agent's items.'''
+ """
+ Callback for when we receive an agent's items
+ """
addr = get_agent_address(jid, node)
# Store in cache
@@ -392,8 +421,10 @@
del self._cbs[cbkey]
def agent_info_error(self, jid):
- '''Callback for when a query fails. (even after the browse and agents
- namespaces)'''
+ """
+ Callback for when a query fails. Even after the browse and agents
+ namespaces
+ """
addr = get_agent_address(jid)
# Call callbacks
@@ -406,8 +437,10 @@
del self._cbs[cbkey]
def agent_items_error(self, jid):
- '''Callback for when a query fails. (even after the browse and agents
- namespaces)'''
+ """
+ Callback for when a query fails. Even after the browse and agents
+ namespaces
+ """
addr = get_agent_address(jid)
# Call callbacks
@@ -421,7 +454,10 @@
# object is needed so that @property works
class ServiceDiscoveryWindow(object):
- '''Class that represents the Services Discovery window.'''
+ """
+ Class that represents the Services Discovery window
+ """
+
def __init__(self, account, jid = '', node = '',
address_entry = False, parent = None):
self.account = account
@@ -510,8 +546,10 @@
self.browser.account = value
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.'''
+ """
+ Set some initial state on the window. Separated in a method because it's
+ handy to use within browser's cleanup method
+ """
self.progressbar.hide()
title_text = _('Service Discovery using account %s') % self.account
self.window.set_title(title_text)
@@ -550,7 +588,9 @@
self.banner.set_markup(markup)
def paint_banner(self):
- '''Repaint the banner with theme color'''
+ """
+ Repaint the banner with theme color
+ """
theme = gajim.config.get('roster_theme')
bgcolor = gajim.config.get_per('themes', theme, 'bannerbgcolor')
textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor')
@@ -584,10 +624,11 @@
self._on_style_set_event, set_fg, set_bg)
def _on_style_set_event(self, widget, style, *opts):
- ''' set style of widget from style class *.Frame.Eventbox
+ """
+ Set style of widget from style class *.Frame.Eventbox
opts[0] == True -> set fg color
- opts[1] == True -> set bg color '''
-
+ opts[1] == True -> set bg color
+ """
self.disconnect_style_event()
if opts[1]:
bg_color = widget.style.bg[gtk.STATE_SELECTED]
@@ -599,9 +640,11 @@
self.connect_style_event(opts[0], opts[1])
def destroy(self, chain = False):
- '''Close the browser. This can optionally close its children and
- propagate to the parent. This should happen on actions like register,
- or join to kill off the entire browser chain.'''
+ """
+ Close the browser. This can optionally close its children and propagate
+ to the parent. This should happen on actions like register, or join to
+ kill off the entire browser chain
+ """
if self.dying:
return
self.dying = True
@@ -632,7 +675,9 @@
self.cache.cleanup()
def travel(self, jid, node):
- '''Travel to an agent within the current services window.'''
+ """
+ Travel to an agent within the current services window
+ """
if self.browser:
self.browser.cleanup()
self.browser = None
@@ -649,7 +694,9 @@
self.cache.get_info(jid, node, self._travel)
def _travel(self, jid, node, identities, features, data):
- '''Continuation of travel.'''
+ """
+ Continuation of travel
+ """
if self.dying or jid != self.jid or node != self.node:
return
if not identities:
@@ -671,7 +718,9 @@
self.browser.browse()
def open(self, jid, node):
- '''Open an agent. By default, this happens in a new window.'''
+ """
+ Open an agent. By default, this happens in a new window
+ """
try:
win = gajim.interface.instances[self.account]['disco']\
[get_agent_address(jid, node)]
@@ -737,10 +786,13 @@
class AgentBrowser:
- '''Class that deals with browsing agents and appearance of the browser
- window. This class and subclasses should basically be treated as "part"
- of the ServiceDiscoveryWindow class, but had to be separated because this part
- is dynamic.'''
+ """
+ Class that deals with browsing agents and appearance of the browser window.
+ This class and subclasses should basically be treated as "part" of the
+ ServiceDiscoveryWindow class, but had to be separated because this part is
+ dynamic
+ """
+
def __init__(self, account, jid, node):
self.account = account
changeset 291a8d7f1410 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=291a8d7f1410
description: merge local diff
diffstat:
src/atom_window.py | 18 +-
src/config.py | 138 +++++++++++++------
src/conversation_textview.py | 75 ++++++----
src/dataforms_widget.py | 64 ++++++--
src/dialogs.py | 304 +++++++++++++++++++++++++++++++------------
5 files changed, 417 insertions(+), 182 deletions(-)
diffs (truncated from 1400 to 300 lines):
diff -r 1d5573944c76 -r 291a8d7f1410 src/atom_window.py
--- a/src/atom_window.py Wed Nov 25 16:50:49 2009 +0100
+++ b/src/atom_window.py Wed Nov 25 16:51:26 2009 +0100
@@ -35,7 +35,9 @@
@classmethod
def newAtomEntry(cls, entry):
- ''' Queue new entry, open window if there's no one opened. '''
+ """
+ Queue new entry, open window if there's no one opened
+ """
cls.entries.append(entry)
if cls.window is None:
@@ -48,7 +50,9 @@
cls.window = None
def __init__(self):
- ''' Create new window... only if we have anything to show. '''
+ """
+ Create new window... only if we have anything to show
+ """
assert len(self.__class__.entries)>0
self.entry = None # the entry actually displayed
@@ -69,7 +73,9 @@
self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
def displayNextEntry(self):
- ''' Get next entry from the queue and display it in the window. '''
+ """
+ Get next entry from the queue and display it in the window
+ """
assert len(self.__class__.entries)>0
newentry = self.__class__.entries.pop(0)
@@ -103,8 +109,10 @@
self.entry = newentry
def updateCounter(self):
- ''' We display number of events on the top of window, sometimes it needs to be
- changed...'''
+ """
+ Display number of events on the top of window, sometimes it needs to be
+ changed
+ """
count = len(self.__class__.entries)
if count>0:
self.new_entry_label.set_text(i18n.ngettext(
diff -r 1d5573944c76 -r 291a8d7f1410 src/config.py
--- a/src/config.py Wed Nov 25 16:50:49 2009 +0100
+++ b/src/config.py Wed Nov 25 16:51:26 2009 +0100
@@ -63,17 +63,23 @@
#---------- PreferencesWindow class -------------#
class PreferencesWindow:
- '''Class for Preferences window'''
+ """
+ Class for Preferences window
+ """
def on_preferences_window_destroy(self, widget):
- '''close window'''
+ """
+ Close window
+ """
del gajim.interface.instances['preferences']
def on_close_button_clicked(self, widget):
self.window.destroy()
def __init__(self):
- '''Initialize Preferences window'''
+ """
+ Initialize Preferences window
+ """
self.xml = gtkgui_helpers.get_glade('preferences_window.glade')
self.window = self.xml.get_widget('preferences_window')
self.window.set_transient_for(gajim.interface.roster.window)
@@ -495,8 +501,10 @@
self.window.hide()
def get_per_account_option(self, opt):
- '''Return the value of the option opt if it's the same in all accounts
- else returns "mixed"'''
+ """
+ Return the value of the option opt if it's the same in all accounts else
+ returns "mixed"
+ """
if len(gajim.connections) == 0:
# a non existant key return default value
return gajim.config.get_per('accounts', '__default__', opt)
@@ -585,7 +593,9 @@
self.toggle_emoticons()
def toggle_emoticons(self):
- '''Update emoticons state in Opened Chat Windows'''
+ """
+ Update emoticons state in Opened Chat Windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.toggle_emoticons()
@@ -779,7 +789,9 @@
self.sounds_preferences.window.present()
def update_text_tags(self):
- '''Update color tags in Opened Chat Windows'''
+ """
+ Update color tags in opened chat windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.update_tags()
@@ -800,7 +812,9 @@
gajim.interface.save_config()
def update_text_font(self):
- '''Update text font in Opened Chat Windows'''
+ """
+ Update text font in opened chat windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.update_font()
@@ -879,7 +893,9 @@
gajim.interface.save_config()
def _set_color(self, state, widget_name, option):
- ''' set color value in prefs and update the UI '''
+ """
+ Set color value in prefs and update the UI
+ """
if state:
color = self.xml.get_widget(widget_name).get_color()
color_string = gtkgui_helpers.make_color_string(color)
@@ -1346,7 +1362,10 @@
#---------- AccountsWindow class -------------#
class AccountsWindow:
- '''Class for accounts window: list of accounts'''
+ """
+ Class for accounts window: list of accounts
+ """
+
def on_accounts_window_destroy(self, widget):
del gajim.interface.instances['accounts']
@@ -1414,7 +1433,9 @@
iter_ = model.iter_next(iter_)
def init_accounts(self):
- '''initialize listStore with existing accounts'''
+ """
+ Initialize listStore with existing accounts
+ """
self.remove_button.set_sensitive(False)
self.rename_button.set_sensitive(False)
self.current_account = None
@@ -1440,7 +1461,9 @@
elif self.need_relogin and self.current_account and \
gajim.connections[self.current_account].connected > 0:
def login(account, show_before, status_before):
- ''' login with previous status'''
+ """
+ Login with previous status
+ """
# first make sure connection is really closed,
# 0.5 may not be enough
gajim.connections[account].disconnect(True)
@@ -1473,7 +1496,9 @@
self.resend_presence = False
def on_accounts_treeview_cursor_changed(self, widget):
- '''Activate modify buttons when a row is selected, update accounts info'''
+ """
+ Activate modify buttons when a row is selected, update accounts info
+ """
sel = self.accounts_treeview.get_selection()
(model, iter_) = sel.get_selected()
if iter_:
@@ -1739,7 +1764,9 @@
gajim.config.get_per('accounts', account, 'use_ft_proxies'))
def on_add_button_clicked(self, widget):
- '''When add button is clicked: open an account information window'''
+ """
+ When add button is clicked: open an account information window
+ """
if 'account_creation_wizard' in gajim.interface.instances:
gajim.interface.instances['account_creation_wizard'].window.present()
else:
@@ -1747,8 +1774,10 @@
AccountCreationWizardWindow()
def on_remove_button_clicked(self, widget):
- '''When delete button is clicked:
- Remove an account from the listStore and from the config file'''
+ """
+ When delete button is clicked: Remove an account from the listStore and
+ from the config file
+ """
if not self.current_account:
return
account = self.current_account
@@ -2409,8 +2438,11 @@
'zeroconf_email', email)
class FakeDataForm(gtk.Table, object):
- '''Class for forms that are in XML format <entry1>value1</entry1>
- infos in a table {entry1: value1, }'''
+ """
+ Class for forms that are in XML format <entry1>value1</entry1> infos in a
+ table {entry1: value1}
+ """
+
def __init__(self, infos):
gtk.Table.__init__(self)
self.infos = infos
@@ -2418,7 +2450,9 @@
self._draw_table()
def _draw_table(self):
- '''Draw the table'''
+ """
+ Draw the table
+ """
nbrow = 0
if 'instructions' in self.infos:
nbrow = 1
@@ -2452,9 +2486,11 @@
return self.infos
class ServiceRegistrationWindow:
- '''Class for Service registration window:
- Window that appears when we want to subscribe to a service
- if is_form we use dataforms_widget else we use service_registarion_window'''
+ """
+ Class for Service registration window. Window that appears when we want to
+ subscribe to a service if is_form we use dataforms_widget else we use
+ service_registarion_window
+ """
def __init__(self, service, infos, account, is_form):
self.service = service
self.account = account
@@ -2501,7 +2537,7 @@
self.window.destroy()
class GroupchatConfigWindow:
- '''GroupchatConfigWindow class'''
+
def __init__(self, account, room_jid, form = None):
self.account = account
self.room_jid = room_jid
@@ -2654,7 +2690,9 @@
self.remove_button[affiliation].set_sensitive(True)
def affiliation_list_received(self, users_dict):
- '''Fill the affiliation treeview'''
+ """
+ Fill the affiliation treeview
+ """
for jid in users_dict:
affiliation = users_dict[jid]['affiliation']
if affiliation not in self.affiliation_labels.keys():
@@ -2703,8 +2741,10 @@
#---------- RemoveAccountWindow class -------------#
class RemoveAccountWindow:
- '''ask for removing from gajim only or from gajim and server too
- and do removing of the account given'''
+ """
+ Ask for removing from gajim only or from gajim and server too and do
+ removing of the account given
+ """
def on_remove_account_window_destroy(self, widget):
if self.account in gajim.interface.instances:
@@ -2904,7 +2944,9 @@
del gajim.interface.instances['manage_bookmarks']
def on_add_bookmark_button_clicked(self, widget):
- '''Add a new bookmark.'''
+ """
+ Add a new bookmark
+ """
# Get the account that is currently used
# (the parent of the currently selected item)
(model, iter_) = self.selection.get_selected()
@@ -2929,9 +2971,9 @@
self.view.set_cursor(model.get_path(iter_))
def on_remove_bookmark_button_clicked(self, widget):
- '''
- Remove selected bookmark.
- '''
+ """
+ Remove selected bookmark
+ """
(model, iter_) = self.selection.get_selected()
changeset 1d5573944c76 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=1d5573944c76
description: prevent showing error message when we receive a PEP error message and really ignore it
diffstat:
src/common/connection_handlers.py | 7 +++++--
src/common/pep.py | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diffs (29 lines):
diff -r 6395d52bd201 -r 1d5573944c76 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Wed Nov 25 16:50:15 2009 +0100
+++ b/src/common/connection_handlers.py Wed Nov 25 16:50:49 2009 +0100
@@ -2733,8 +2733,11 @@
con.RegisterHandler('message', self._messageCB)
con.RegisterHandler('presence', self._presenceCB)
con.RegisterHandler('presence', self._capsPresenceCB)
- con.RegisterHandler('message', self._pubsubEventCB,
- ns=common.xmpp.NS_PUBSUB_EVENT)
+ # We use makefirst so that this handler is called before _messageCB, and
+ # can prevent calling it when it's not needed.
+ # We also don't check for namespace, else it cannot stop _messageCB to be
+ # called
+ con.RegisterHandler('message', self._pubsubEventCB, makefirst=True)
con.RegisterHandler('iq', self._vCardCB, 'result',
common.xmpp.NS_VCARD)
con.RegisterHandler('iq', self._rosterSetCB, 'set',
diff -r 6395d52bd201 -r 1d5573944c76 src/common/pep.py
--- a/src/common/pep.py Wed Nov 25 16:50:15 2009 +0100
+++ b/src/common/pep.py Wed Nov 25 16:50:49 2009 +0100
@@ -454,6 +454,8 @@
def _pubsubEventCB(self, xmpp_dispatcher, msg):
''' Called when we receive <message /> with pubsub event. '''
+ if not msg.getTag('event'):
+ return
if msg.getTag('error'):
log.debug('PubsubEventCB received error stanza. Ignoring')
raise xmpp.NodeProcessed
changeset 078ae96fbbf7 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=078ae96fbbf7
description: One more portion of doc-strings refactoring
diffstat:
src/atom_window.py | 18 +-
src/config.py | 138 +++++++++++++------
src/conversation_textview.py | 75 ++++++----
src/dataforms_widget.py | 64 ++++++--
src/dialogs.py | 304 +++++++++++++++++++++++++++++++------------
5 files changed, 417 insertions(+), 182 deletions(-)
diffs (truncated from 1400 to 300 lines):
diff -r 192a3fb88bfb -r 078ae96fbbf7 src/atom_window.py
--- a/src/atom_window.py Wed Nov 25 16:29:33 2009 +0100
+++ b/src/atom_window.py Wed Nov 25 17:45:05 2009 +0200
@@ -35,7 +35,9 @@
@classmethod
def newAtomEntry(cls, entry):
- ''' Queue new entry, open window if there's no one opened. '''
+ """
+ Queue new entry, open window if there's no one opened
+ """
cls.entries.append(entry)
if cls.window is None:
@@ -48,7 +50,9 @@
cls.window = None
def __init__(self):
- ''' Create new window... only if we have anything to show. '''
+ """
+ Create new window... only if we have anything to show
+ """
assert len(self.__class__.entries)>0
self.entry = None # the entry actually displayed
@@ -69,7 +73,9 @@
self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
def displayNextEntry(self):
- ''' Get next entry from the queue and display it in the window. '''
+ """
+ Get next entry from the queue and display it in the window
+ """
assert len(self.__class__.entries)>0
newentry = self.__class__.entries.pop(0)
@@ -103,8 +109,10 @@
self.entry = newentry
def updateCounter(self):
- ''' We display number of events on the top of window, sometimes it needs to be
- changed...'''
+ """
+ Display number of events on the top of window, sometimes it needs to be
+ changed
+ """
count = len(self.__class__.entries)
if count>0:
self.new_entry_label.set_text(i18n.ngettext(
diff -r 192a3fb88bfb -r 078ae96fbbf7 src/config.py
--- a/src/config.py Wed Nov 25 16:29:33 2009 +0100
+++ b/src/config.py Wed Nov 25 17:45:05 2009 +0200
@@ -63,17 +63,23 @@
#---------- PreferencesWindow class -------------#
class PreferencesWindow:
- '''Class for Preferences window'''
+ """
+ Class for Preferences window
+ """
def on_preferences_window_destroy(self, widget):
- '''close window'''
+ """
+ Close window
+ """
del gajim.interface.instances['preferences']
def on_close_button_clicked(self, widget):
self.window.destroy()
def __init__(self):
- '''Initialize Preferences window'''
+ """
+ Initialize Preferences window
+ """
self.xml = gtkgui_helpers.get_glade('preferences_window.glade')
self.window = self.xml.get_widget('preferences_window')
self.window.set_transient_for(gajim.interface.roster.window)
@@ -495,8 +501,10 @@
self.window.hide()
def get_per_account_option(self, opt):
- '''Return the value of the option opt if it's the same in all accounts
- else returns "mixed"'''
+ """
+ Return the value of the option opt if it's the same in all accounts else
+ returns "mixed"
+ """
if len(gajim.connections) == 0:
# a non existant key return default value
return gajim.config.get_per('accounts', '__default__', opt)
@@ -585,7 +593,9 @@
self.toggle_emoticons()
def toggle_emoticons(self):
- '''Update emoticons state in Opened Chat Windows'''
+ """
+ Update emoticons state in Opened Chat Windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.toggle_emoticons()
@@ -779,7 +789,9 @@
self.sounds_preferences.window.present()
def update_text_tags(self):
- '''Update color tags in Opened Chat Windows'''
+ """
+ Update color tags in opened chat windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.update_tags()
@@ -800,7 +812,9 @@
gajim.interface.save_config()
def update_text_font(self):
- '''Update text font in Opened Chat Windows'''
+ """
+ Update text font in opened chat windows
+ """
for win in gajim.interface.msg_win_mgr.windows():
win.update_font()
@@ -879,7 +893,9 @@
gajim.interface.save_config()
def _set_color(self, state, widget_name, option):
- ''' set color value in prefs and update the UI '''
+ """
+ Set color value in prefs and update the UI
+ """
if state:
color = self.xml.get_widget(widget_name).get_color()
color_string = gtkgui_helpers.make_color_string(color)
@@ -1346,7 +1362,10 @@
#---------- AccountsWindow class -------------#
class AccountsWindow:
- '''Class for accounts window: list of accounts'''
+ """
+ Class for accounts window: list of accounts
+ """
+
def on_accounts_window_destroy(self, widget):
del gajim.interface.instances['accounts']
@@ -1414,7 +1433,9 @@
iter_ = model.iter_next(iter_)
def init_accounts(self):
- '''initialize listStore with existing accounts'''
+ """
+ Initialize listStore with existing accounts
+ """
self.remove_button.set_sensitive(False)
self.rename_button.set_sensitive(False)
self.current_account = None
@@ -1440,7 +1461,9 @@
elif self.need_relogin and self.current_account and \
gajim.connections[self.current_account].connected > 0:
def login(account, show_before, status_before):
- ''' login with previous status'''
+ """
+ Login with previous status
+ """
# first make sure connection is really closed,
# 0.5 may not be enough
gajim.connections[account].disconnect(True)
@@ -1473,7 +1496,9 @@
self.resend_presence = False
def on_accounts_treeview_cursor_changed(self, widget):
- '''Activate modify buttons when a row is selected, update accounts info'''
+ """
+ Activate modify buttons when a row is selected, update accounts info
+ """
sel = self.accounts_treeview.get_selection()
(model, iter_) = sel.get_selected()
if iter_:
@@ -1739,7 +1764,9 @@
gajim.config.get_per('accounts', account, 'use_ft_proxies'))
def on_add_button_clicked(self, widget):
- '''When add button is clicked: open an account information window'''
+ """
+ When add button is clicked: open an account information window
+ """
if 'account_creation_wizard' in gajim.interface.instances:
gajim.interface.instances['account_creation_wizard'].window.present()
else:
@@ -1747,8 +1774,10 @@
AccountCreationWizardWindow()
def on_remove_button_clicked(self, widget):
- '''When delete button is clicked:
- Remove an account from the listStore and from the config file'''
+ """
+ When delete button is clicked: Remove an account from the listStore and
+ from the config file
+ """
if not self.current_account:
return
account = self.current_account
@@ -2409,8 +2438,11 @@
'zeroconf_email', email)
class FakeDataForm(gtk.Table, object):
- '''Class for forms that are in XML format <entry1>value1</entry1>
- infos in a table {entry1: value1, }'''
+ """
+ Class for forms that are in XML format <entry1>value1</entry1> infos in a
+ table {entry1: value1}
+ """
+
def __init__(self, infos):
gtk.Table.__init__(self)
self.infos = infos
@@ -2418,7 +2450,9 @@
self._draw_table()
def _draw_table(self):
- '''Draw the table'''
+ """
+ Draw the table
+ """
nbrow = 0
if 'instructions' in self.infos:
nbrow = 1
@@ -2452,9 +2486,11 @@
return self.infos
class ServiceRegistrationWindow:
- '''Class for Service registration window:
- Window that appears when we want to subscribe to a service
- if is_form we use dataforms_widget else we use service_registarion_window'''
+ """
+ Class for Service registration window. Window that appears when we want to
+ subscribe to a service if is_form we use dataforms_widget else we use
+ service_registarion_window
+ """
def __init__(self, service, infos, account, is_form):
self.service = service
self.account = account
@@ -2501,7 +2537,7 @@
self.window.destroy()
class GroupchatConfigWindow:
- '''GroupchatConfigWindow class'''
+
def __init__(self, account, room_jid, form = None):
self.account = account
self.room_jid = room_jid
@@ -2654,7 +2690,9 @@
self.remove_button[affiliation].set_sensitive(True)
def affiliation_list_received(self, users_dict):
- '''Fill the affiliation treeview'''
+ """
+ Fill the affiliation treeview
+ """
for jid in users_dict:
affiliation = users_dict[jid]['affiliation']
if affiliation not in self.affiliation_labels.keys():
@@ -2703,8 +2741,10 @@
#---------- RemoveAccountWindow class -------------#
class RemoveAccountWindow:
- '''ask for removing from gajim only or from gajim and server too
- and do removing of the account given'''
+ """
+ Ask for removing from gajim only or from gajim and server too and do
+ removing of the account given
+ """
def on_remove_account_window_destroy(self, widget):
if self.account in gajim.interface.instances:
@@ -2904,7 +2944,9 @@
del gajim.interface.instances['manage_bookmarks']
def on_add_bookmark_button_clicked(self, widget):
- '''Add a new bookmark.'''
+ """
+ Add a new bookmark
+ """
# Get the account that is currently used
# (the parent of the currently selected item)
(model, iter_) = self.selection.get_selected()
@@ -2929,9 +2971,9 @@
self.view.set_cursor(model.get_path(iter_))
def on_remove_bookmark_button_clicked(self, widget):
- '''
- Remove selected bookmark.
- '''
+ """
+ Remove selected bookmark
+ """
(model, iter_) = self.selection.get_selected()
changeset 04a843a42cf7 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=04a843a42cf7
description: More doc-string refactoring
diffstat:
src/adhoc_commands.py | 105 ++++++++++++++++++++++++++++++++++++----------------
1 files changed, 73 insertions(+), 32 deletions(-)
diffs (203 lines):
diff -r 76256088742d -r 04a843a42cf7 src/adhoc_commands.py
--- a/src/adhoc_commands.py Wed Nov 25 15:24:48 2009 +0200
+++ b/src/adhoc_commands.py Wed Nov 25 15:52:32 2009 +0200
@@ -35,17 +35,22 @@
import dataforms_widget
class CommandWindow:
- '''Class for a window for single ad-hoc commands session. Note, that
- there might be more than one for one account/jid pair in one moment.
+ """
+ Class for a window for single ad-hoc commands session
- TODO: maybe put this window into MessageWindow? consider this when
- TODO: it will be possible to manage more than one window of one
- TODO: account/jid pair in MessageWindowMgr.
+ Note, that there might be more than one for one account/jid pair in one
+ moment.
- TODO: gtk 2.10 has a special wizard-widget, consider using it...'''
+ TODO: Maybe put this window into MessageWindow? consider this when it will
+ be possible to manage more than one window of one.
+ TODO: Account/jid pair in MessageWindowMgr.
+ TODO: GTK 2.10 has a special wizard-widget, consider using it...
+ """
def __init__(self, account, jid, commandnode=None):
- '''Create new window.'''
+ """
+ Create new window
+ """
# an account object
self.account = gajim.connections[account]
@@ -89,16 +94,29 @@
self.xml.signal_autoconnect(self)
self.window.show_all()
-# these functions are set up by appropriate stageX methods
- def stage_finish(self, *anything): pass
- def stage_back_button_clicked(self, *anything): assert False
- def stage_forward_button_clicked(self, *anything): assert False
- def stage_execute_button_clicked(self, *anything): assert False
- def stage_close_button_clicked(self, *anything): assert False
- def stage_adhoc_commands_window_delete_event(self, *anything): assert False
- def do_nothing(self, *anything): return False
+ # These functions are set up by appropriate stageX methods.
+ def stage_finish(self, *anything):
+ pass
-# widget callbacks
+ def stage_back_button_clicked(self, *anything):
+ assert False
+
+ def stage_forward_button_clicked(self, *anything):
+ assert False
+
+ def stage_execute_button_clicked(self, *anything):
+ assert False
+
+ def stage_close_button_clicked(self, *anything):
+ assert False
+
+ def stage_adhoc_commands_window_delete_event(self, *anything):
+ assert False
+
+ def do_nothing(self, *anything):
+ return False
+
+ # Widget callbacks...
def on_back_button_clicked(self, *anything):
return self.stage_back_button_clicked(*anything)
@@ -123,8 +141,10 @@
# stage 1: waiting for command list
def stage1(self):
- '''Prepare the first stage. Request command list,
- set appropriate state of widgets.'''
+ """
+ Prepare the first stage. Request command list, set appropriate state of
+ widgets
+ """
# close old stage...
self.stage_finish()
@@ -164,9 +184,12 @@
# stage 2: choosing the command to execute
def stage2(self):
- '''Populate the command list vbox with radiobuttons
- (FIXME: if there is more commands, maybe some kind of list?),
- set widgets' state.'''
+ """
+ Populate the command list vbox with radiobuttons
+
+ FIXME: If there is more commands, maybe some kind of list, set widgets
+ state
+ """
# close old stage
self.stage_finish()
@@ -198,7 +221,9 @@
self.stage_adhoc_commands_window_delete_event = self.do_nothing
def stage2_finish(self):
- '''Remove widgets we created. Not needed when the window is destroyed.'''
+ """
+ Remove widgets we created. Not needed when the window is destroyed
+ """
def remove_widget(widget):
self.command_list_vbox.remove(widget)
self.command_list_vbox.foreach(remove_widget)
@@ -247,8 +272,10 @@
pass
def stage3_close_button_clicked(self, widget):
- ''' We are in the middle of executing command. Ask user if he really want to cancel
- the process, then... cancel it. '''
+ """
+ We are in the middle of executing command. Ask user if he really want to
+ cancel the process, then cancel it
+ """
# this works also as a handler for window_delete_event, so we have to return appropriate
# values
if self.form_status == 'completed':
@@ -362,7 +389,9 @@
# stage 4: no commands are exposed
def stage4(self):
- '''Display the message. Wait for user to close the window'''
+ """
+ Display the message. Wait for user to close the window
+ """
# close old stage
self.stage_finish()
@@ -387,7 +416,9 @@
# stage 5: an error has occured
def stage5(self, error=None, errorid=None, senderror=False):
- '''Display the error message. Wait for user to close the window'''
+ """
+ Display the error message. Wait for user to close the window
+ """
# FIXME: sending error to responder
# close old stage
self.stage_finish()
@@ -430,8 +461,10 @@
# helpers to handle pulsing in progressbar
def setup_pulsing(self, progressbar):
- '''Set the progressbar to pulse. Makes a custom
- function to repeatedly call progressbar.pulse() method.'''
+ """
+ Set the progressbar to pulse. Makes a custom function to repeatedly call
+ progressbar.pulse() method
+ """
assert not self.pulse_id
assert isinstance(progressbar, gtk.ProgressBar)
@@ -443,14 +476,18 @@
self.pulse_id = gobject.timeout_add(80, callback)
def remove_pulsing(self):
- '''Stop pulsing, useful when especially when removing widget.'''
+ """
+ Stop pulsing, useful when especially when removing widget
+ """
if self.pulse_id:
gobject.source_remove(self.pulse_id)
self.pulse_id=None
# handling xml stanzas
def request_command_list(self):
- '''Request the command list. Change stage on delivery.'''
+ """
+ Request the command list. Change stage on delivery
+ """
query = xmpp.Iq(typ='get', to=xmpp.JID(self.jid), queryNS=xmpp.NS_DISCO_ITEMS)
query.setQuerynode(xmpp.NS_COMMANDS)
@@ -481,7 +518,9 @@
self.account.connection.SendAndCallForResponse(query, callback)
def send_command(self, action='execute'):
- '''Send the command with data form. Wait for reply.'''
+ """
+ Send the command with data form. Wait for reply
+ """
# create the stanza
assert isinstance(self.commandnode, unicode)
assert action in ('execute', 'prev', 'next', 'complete')
@@ -510,7 +549,9 @@
self.account.connection.SendAndCallForResponse(stanza, callback)
def send_cancel(self):
- '''Send the command with action='cancel'. '''
+ """
+ Send the command with action='cancel'
+ """
assert self.commandnode
if self.sessionid and self.account.connection:
# we already have sessionid, so the service sent at least one reply.
changeset 76256088742d in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=76256088742d
description: More doc-string refactoring
diffstat:
src/groupchat_control.py | 212 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 142 insertions(+), 70 deletions(-)
diffs (truncated from 496 to 300 lines):
diff -r d49c1c384960 -r 76256088742d src/groupchat_control.py
--- a/src/groupchat_control.py Wed Nov 25 15:01:40 2009 +0200
+++ b/src/groupchat_control.py Wed Nov 25 15:24:48 2009 +0200
@@ -64,7 +64,9 @@
) = range(5)
def set_renderer_color(treeview, renderer, set_background=True):
- '''set style for group row, using PRELIGHT system color'''
+ """
+ Set style for group row, using PRELIGHT system color
+ """
if set_background:
bgcolor = treeview.style.bg[gtk.STATE_PRELIGHT]
renderer.set_property('cell-background-gdk', bgcolor)
@@ -141,7 +143,9 @@
self.TYPE_ID = 'pm'
def send_message(self, message, xhtml=None, process_commands=True):
- '''call this function to send our message'''
+ """
+ Call this method to send the message
+ """
if not message:
return
@@ -383,7 +387,9 @@
self.widget.show_all()
def tree_compare_iters(self, model, iter1, iter2):
- '''Compare two iters to sort them'''
+ """
+ Compare two iters to sort them
+ """
type1 = model[iter1][C_TYPE]
type2 = model[iter2][C_TYPE]
if not type1 or not type2:
@@ -422,8 +428,10 @@
return locale.strcoll(name1.lower(), name2.lower())
def on_msg_textview_populate_popup(self, textview, menu):
- '''we override the default context menu and we prepend Clear
- and the ability to insert a nick'''
+ """
+ Override the default context menu and we prepend Clear
+ and the ability to insert a nick
+ """
ChatControlBase.on_msg_textview_populate_popup(self, textview, menu)
item = gtk.SeparatorMenuItem()
menu.prepend(item)
@@ -452,7 +460,9 @@
gobject.idle_add(reset_flag)
def on_treeview_size_allocate(self, widget, allocation):
- '''The MUC treeview has resized. Move the hpaned in all tabs to match'''
+ """
+ The MUC treeview has resized. Move the hpaned in all tabs to match
+ """
if self.resize_from_another_muc:
# Don't send the event to other MUC
return
@@ -467,7 +477,9 @@
ctrl.resize_occupant_treeview(hpaned_position)
def iter_contact_rows(self):
- '''iterate over all contact rows in the tree model'''
+ """
+ Iterate over all contact rows in the tree model
+ """
model = self.list_treeview.get_model()
role_iter = model.get_iter_root()
while role_iter:
@@ -478,7 +490,9 @@
role_iter = model.iter_next(role_iter)
def on_list_treeview_style_set(self, treeview, style):
- '''When style (theme) changes, redraw all contacts'''
+ """
+ When style (theme) changes, redraw all contacts
+ """
# Get the room_jid from treeview
for contact in self.iter_contact_rows():
nick = contact[C_NICK].decode('utf-8')
@@ -500,10 +514,11 @@
self.draw_contact(nick, selected=True, focus=True)
def get_tab_label(self, chatstate):
- '''Markup the label if necessary. Returns a tuple such as:
- (new_label_str, color)
- either of which can be None
- if chatstate is given that means we have HE SENT US a chatstate'''
+ """
+ Markup the label if necessary. Returns a tuple such as: (new_label_str,
+ color) either of which can be None if chatstate is given that means we
+ have HE SENT US a chatstate
+ """
has_focus = self.parent_win.window.get_property('has-toplevel-focus')
current_tab = self.parent_win.get_active_control() == self
@@ -588,10 +603,10 @@
banner_status_img.set_from_pixbuf(scaled_pix)
def get_continued_conversation_name(self):
- '''Get the name of a continued conversation.
- Will return Continued Conversation if there isn't any other
- contact in the room
- '''
+ """
+ Get the name of a continued conversation. Will return Continued
+ Conversation if there isn't any other contact in the room
+ """
nicks = []
for nick in gajim.contacts.get_nick_list(self.account,
self.room_jid):
@@ -605,9 +620,10 @@
return title
def draw_banner_text(self):
- '''Draw the text in the fat line at the top of the window that
- houses the room jid, subject.
- '''
+ """
+ Draw the text in the fat line at the top of the window that houses the
+ room jid, subject
+ """
self.name_label.set_ellipsize(pango.ELLIPSIZE_END)
self.banner_status_label.set_ellipsize(pango.ELLIPSIZE_END)
font_attrs, font_attrs_small = self.get_font_attrs()
@@ -641,7 +657,9 @@
self.banner_status_label.set_markup(subject_text)
def prepare_context_menu(self, hide_buttonbar_items=False):
- '''sets sensitivity state for configure_room'''
+ """
+ Set sensitivity state for configure_room
+ """
xml = gtkgui_helpers.get_glade('gc_control_popup_menu.glade')
menu = xml.get_widget('gc_control_popup_menu')
@@ -745,7 +763,7 @@
return menu
def destroy_menu(self, menu, change_nick_menuitem, change_subject_menuitem,
- bookmark_room_menuitem, history_menuitem):
+ bookmark_room_menuitem, history_menuitem):
# destroy accelerators
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
change_nick_menuitem.remove_accelerator(ag, gtk.keysyms.n,
@@ -760,7 +778,7 @@
menu.destroy()
def on_message(self, nick, msg, tim, has_timestamp=False, xhtml=None,
- status_code=[]):
+ status_code=[]):
if '100' in status_code:
# Room is not anonymous
self.is_anonymous = False
@@ -776,8 +794,8 @@
else:
self.print_conversation(msg, nick, tim, xhtml)
- def on_private_message(self, nick, msg, tim, xhtml, session,
- msg_id=None, encrypted=False):
+ def on_private_message(self, nick, msg, tim, xhtml, session, msg_id=None,
+ encrypted=False):
# Do we have a queue?
fjid = self.room_jid + '/' + nick
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
@@ -835,8 +853,7 @@
fin = True
return None
- def print_old_conversation(self, text, contact='', tim=None,
- xhtml = None):
+ def print_old_conversation(self, text, contact='', tim=None, xhtml = None):
if isinstance(text, str):
text = unicode(text, 'utf-8')
if contact:
@@ -855,11 +872,14 @@
small_attr + ['restored_message'], count_as_new=False, xhtml=xhtml)
def print_conversation(self, text, contact='', tim=None, xhtml=None,
- graphics=True):
- '''Print a line in the conversation:
- if contact is set: it's a message from someone or an info message (contact
- = 'info' in such a case)
- if contact is not set: it's a message from the server or help'''
+ graphics=True):
+ """
+ Print a line in the conversation
+
+ If contact is set: it's a message from someone or an info message
+ (contact = 'info' in such a case).
+ If contact is not set: it's a message from the server or help.
+ """
if isinstance(text, str):
text = unicode(text, 'utf-8')
other_tags_for_name = []
@@ -938,8 +958,10 @@
return nb
def highlighting_for_message(self, text, tim):
- '''Returns a 2-Tuple. The first says whether or not to highlight the
- text, the second, what sound to play.'''
+ """
+ Returns a 2-Tuple. The first says whether or not to highlight the text,
+ the second, what sound to play
+ """
highlight, sound = (None, None)
# Are any of the defined highlighting words in the text?
@@ -961,10 +983,11 @@
return (highlight, sound)
def check_and_possibly_add_focus_out_line(self):
- '''checks and possibly adds focus out line for room_jid if it needs it
- and does not already have it as last event. If it goes to add this line
- it removes previous line first'''
-
+ """
+ Check and possibly add focus out line for room_jid if it needs it and
+ does not already have it as last event. If it goes to add this line
+ - remove previous line first
+ """
win = gajim.interface.msg_win_mgr.get_window(self.room_jid, self.account)
if win and self.room_jid == win.get_active_jid() and\
win.window.get_property('has-toplevel-focus') and\
@@ -976,9 +999,10 @@
self.conv_textview.show_focus_out_line()
def needs_visual_notification(self, text):
- '''checks text to see whether any of the words in (muc_highlight_words
- and nick) appear.'''
-
+ """
+ Check text to see whether any of the words in (muc_highlight_words and
+ nick) appear
+ """
special_words = gajim.config.get('muc_highlight_words').split(';')
special_words.append(self.nick)
# Strip empties: ''.split(';') == [''] and would highlight everything.
@@ -1072,9 +1096,11 @@
self.list_treeview.columns_autosize()
def on_send_pm(self, widget=None, model=None, iter_=None, nick=None,
- msg=None):
- '''opens a chat window and if msg is not None sends private message to a
- contact in a room'''
+ msg=None):
+ """
+ Open a chat window and if msg is not None - send private message to a
+ contact in a room
+ """
if nick is None:
nick = model[iter_][C_NICK].decode('utf-8')
@@ -1083,7 +1109,9 @@
ctrl.send_message(msg)
def on_send_file(self, widget, gc_contact):
- '''sends a file to a contact in the room'''
+ """
+ Send a file to a contact in the room
+ """
self._on_send_file(gc_contact)
def draw_contact(self, nick, selected=False, focus=False):
@@ -1168,8 +1196,10 @@
self.draw_role(role)
def chg_contact_status(self, nick, show, status, role, affiliation, jid,
- reason, actor, statusCode, new_nick, avatar_sha, tim=None):
- '''When an occupant changes his or her status'''
+ reason, actor, statusCode, new_nick, avatar_sha, tim=None):
+ """
+ When an occupant changes his or her status
+ """
if show == 'invisible':
return
@@ -1448,7 +1478,7 @@
self.print_conversation(st, tim=tim, graphics=False)
def add_contact_to_roster(self, nick, show, role, affiliation, status,
- jid=''):
+ jid=''):
model = self.list_treeview.get_model()
role_name = helpers.get_uf_role(role, plural=True)
@@ -1514,7 +1544,9 @@
return None
def remove_contact(self, nick):
- '''Remove a user from the contacts_list'''
+ """
+ Remove a user from the contacts_list
+ """
model = self.list_treeview.get_model()
iter_ = self.get_contact_iter(nick)
if not iter_:
@@ -1529,7 +1561,9 @@