deskbar-applet r2324 - in trunk: . deskbar/core deskbar/handlers doc
- From: kamstrup svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2324 - in trunk: . deskbar/core deskbar/handlers doc
- Date: Wed, 13 Aug 2008 23:08:13 +0000 (UTC)
Author: kamstrup
Date: Wed Aug 13 23:08:12 2008
New Revision: 2324
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2324&view=rev
Log:
2008-08-14 Mikkel Kamstrup Erlandsen <kamstrup cvs gnome org>
* deskbar/handlers/twitter.py
Some refactoring needed to properly use the GnomeURLopener in cases
where the proxy changes
* deskbar/core/Web.py
Add automatic support for using the Gnome proxy in GnomeURLopener.
Twiddle with the way modality of the account dialog is done
* doc/README
Add notes on asciidoc
Modified:
trunk/ChangeLog
trunk/deskbar/core/Web.py
trunk/deskbar/handlers/twitter.py
trunk/doc/README
Modified: trunk/deskbar/core/Web.py
==============================================================================
--- trunk/deskbar/core/Web.py (original)
+++ trunk/deskbar/core/Web.py Wed Aug 13 23:08:12 2008
@@ -1,4 +1,5 @@
from deskbar.defs import VERSION
+from deskbar.core.Utils import get_proxy
from gettext import gettext as _
import base64
import deskbar
@@ -71,8 +72,18 @@
"server": self._host,
"protocol": self._protocol,
}
- gnomekeyring.item_create_sync(gnomekeyring.get_default_keyring_sync(),
- gnomekeyring.ITEM_NETWORK_PASSWORD, self._realm, attrs, pw, True)
+
+ keyring = gnomekeyring.get_default_keyring_sync()
+ result = gnomekeyring.item_create_sync(keyring,
+ gnomekeyring.ITEM_NETWORK_PASSWORD,
+ self._realm, attrs, pw, True)
+
+ if result == 0:
+ LOGGER.debug ("Credential update success (keyring=%s)" % keyring)
+ elif result == 7:
+ LOGGER.debug ("Credential update cancelled (keyring=%s)" % keyring)
+ else:
+ LOGGER.debug ("Credential update failed. Keyring: %s. Result: %s" % (keyring,result))
class AccountDialog (gtk.MessageDialog):
"""
@@ -84,13 +95,18 @@
dialog.destroy()
"""
- def __init__ (self, parent, account, dialog_type=gtk.MESSAGE_QUESTION):
+ def __init__ (self,
+ account,
+ dialog_parent=None,
+ dialog_type=gtk.MESSAGE_QUESTION,
+ dialog_flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT):
"""
@param account: L{Account} to manage
"""
- gtk.MessageDialog.__init__(self, parent=parent,
- flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MessageDialog.__init__(self,
+ parent=dialog_parent,
type=dialog_type,
+ flags=dialog_flags,
buttons=gtk.BUTTONS_OK_CANCEL)
self._account = account
@@ -178,6 +194,10 @@
A subclass of C{urllib.URLopener} able to intercept user/password requests
and pass them through an L{Account}, displaying a L{AccountDialog} if
necessary.
+
+ Note on proxies: The GnomeURLopener will not react to any subsequent changes
+ to the Gnome proxy settings. Therefore preferably create
+ a new fresh GnomeURLopener each time you need one
"""
__gsignals__ = {
@@ -185,13 +205,16 @@
}
def __init__ (self, account):
- urllib.FancyURLopener.__init__ (self)
+ proxies = get_proxy()
+ urllib.FancyURLopener.__init__ (self, proxies)
gobject.GObject.__init__ (self)
self._account = account
self._thread = None
self._authentication_retries = 0
self._success = True
+ LOGGER.debug ("Using proxies: %s" % proxies)
+
def prompt_user_passwd (self, host, realm):
"""
Override of the same method in C{urllib.FancyURLopener} to display
Modified: trunk/deskbar/handlers/twitter.py
==============================================================================
--- trunk/deskbar/handlers/twitter.py (original)
+++ trunk/deskbar/handlers/twitter.py Wed Aug 13 23:08:12 2008
@@ -35,17 +35,39 @@
VERSION = "0.3"
MIN_MESSAGE_LEN = 2
-
+
+# Translators: The escaped characters are the standard UTF-8 bullet
_FAIL_POST = _(
-"""Failed to post update to %(domain)s. Please make sure that:
+"""Failed to post update to %(domain)s.
+Please make sure that:
- - Your internet connection is working
- - You can connect to <i>http://%(domain)s</i> in your web browser
- - Your credentials in the preferences are correct
-"""
+ \342\200\242 Your internet connection is working
+ \342\200\242 You can connect to <i>http://%(domain)s</i> in
+ your web browser
+ \342\200\242 Your credentials in the preferences are correct"""
)
+
+class TwitterClientFactory :
+ """
+ A factory to help instantiating C{TwitterClient}s.
+ """
+ def __init__ (self, domain="twitter.com", update_url=TWITTER_UPDATE_URL, realm="Twitter API"):
+ self._domain = domain
+ self._update_url = update_url
+ self._realm = realm
+
+ def create_client (self):
+ return TwitterClient(domain=self._domain, update_url=self._update_url, realm=self._realm)
class TwitterClient :
+ """
+ Client capable of talking to a twitter-like API.
+
+ Note on proxies: The URLopener used here will not reflect changes done
+ to the Gnome proxy configuration. Therefore preferably
+ use the TwitterClientFactory and create a new TwitterClient
+ instance each time you need it
+ """
def __init__ (self, domain="twitter.com", update_url=TWITTER_UPDATE_URL, realm="Twitter API"):
self._account = Account (domain, realm)
self._opener = GnomeURLopener (self._account)
@@ -85,13 +107,13 @@
class TwitterUpdateAction(deskbar.interfaces.Action):
- def __init__(self, msg, client, domain="twitter.com", service="Twitter", pixbuf=None):
+ def __init__(self, msg, client_factory, domain="twitter.com", service="Twitter", pixbuf=None):
deskbar.interfaces.Action.__init__ (self, msg)
global _twitter_pixbuf
self._msg = msg
- self._client = client
+ self._client_factory = client_factory
self._domain = domain
self._service = service
@@ -111,7 +133,9 @@
def activate(self, text=None):
LOGGER.info ("Posting: '%s'" % self._msg)
try:
- self._client.update (self._msg)
+ # Create the client on-demand to make sure proxy info is up to date
+ client = self._client_factory.create_client()
+ client.update (self._msg)
except IOError, e:
LOGGER.warning ("Failed to post to %s: %s" % (self._domain,e))
error = gtk.MessageDialog (None,
@@ -137,7 +161,7 @@
class TwitterMatch(deskbar.interfaces.Match):
- def __init__(self, msg, client, domain="twitter.com", service="Twitter", pixbuf=None, **args):
+ def __init__(self, msg, client_factory, domain="twitter.com", service="Twitter", pixbuf=None, **args):
global _twitter_pixbuf
self._service = service
@@ -152,7 +176,7 @@
pixbuf=self._pixbuf,
**args)
- action = TwitterUpdateAction(self.get_name(), client,
+ action = TwitterUpdateAction(self.get_name(), client_factory,
domain=self._domain,
service=self._service,
pixbuf=self._pixbuf)
@@ -180,13 +204,15 @@
if pixbuf : self._pixbuf = pixbuf
else : self._pixbuf = _twitter_pixbuf
- self._client = TwitterClient(domain=self._domain, update_url=update_url, realm=self._realm)
+ self._client_factory = TwitterClientFactory(domain=self._domain,
+ update_url=update_url,
+ realm=self._realm)
def query(self, qstring):
if len (qstring) <= MIN_MESSAGE_LEN and \
len (qstring) > 140: return None
- match = TwitterMatch(qstring, self._client,
+ match = TwitterMatch(qstring, self._client_factory,
domain=self._domain,
service=self._service,
pixbuf=self._pixbuf)
@@ -197,10 +223,9 @@
return True
def show_config(self, parent):
- LOGGER.debug ("Showing config")
account = Account (self._domain, self._realm)
-
- login_dialog = AccountDialog(parent, account)
+ LOGGER.debug ("Showing config")
+ login_dialog = AccountDialog(account, dialog_parent=parent)
login_dialog.show_all()
login_dialog.run()
login_dialog.destroy()
Modified: trunk/doc/README
==============================================================================
--- trunk/doc/README (original)
+++ trunk/doc/README Wed Aug 13 23:08:12 2008
@@ -1,5 +1,8 @@
The file new-style_modules.txt is written in a layout language called ascidoc.
-To compile it into a html document call:
+To compile a html document from it you also need the package called
+source-highlight.
+
+To compile a html document call:
a2x --icons --icons-dir=images/icons new-style_modules.txt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]