diff options
21 files changed, 118 insertions, 119 deletions
diff --git a/configure.in b/configure.in index 5692356b..935a4f92 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl *************************************************************************** dnl *** configure.in for MATE-APPLETS *** dnl *************************************************************************** -AC_INIT(mate-applets, 1.1.1) +AC_INIT(mate-applets, 1.1.3) AC_PREREQ(2.59) AM_CONFIG_HEADER(config.h) @@ -31,7 +31,6 @@ PYGOBJECT_REQUIRED=2.6 MATE_PYTHON_REQUIRED=1.1.0 MATE_ICON_THEME_REQUIRED=1.1.0 LIBXML_REQUIRED=2.5.0 -MATEWEATHER_REQUIRED=1.1.0 GUCHARMAP2_REQUIRED=2.23.0 GUCHARMAP_REQUIRED=1.4.0 POLKIT_REQUIRED=0.92 @@ -268,7 +267,7 @@ AC_SUBST(XML2_LIBS) dnl -- check for libmateweather (required for mateweather applet) ------------------ build_libmateweather_applets=false -PKG_CHECK_MODULES(LIBMATEWEATHER, mateweather >= $MATEWEATHER_REQUIRED, +PKG_CHECK_MODULES(LIBMATEWEATHER, mateweather, build_libmateweather_applets=true, AC_MSG_WARN([libmateweather not found. Not building the weather applet.])) AC_SUBST(LIBMATEWEATHER_CFLAGS) diff --git a/distro/archlinux/PKGBUILD b/distro/archlinux/PKGBUILD index 294a98f9..92cd1ba0 100644 --- a/distro/archlinux/PKGBUILD +++ b/distro/archlinux/PKGBUILD @@ -1,5 +1,5 @@ pkgname=mate-applets -pkgver=1.1.1 +pkgver=1.1.3 pkgrel=1 pkgdesc="Applets for MATE panel" arch=(i686 x86_64) diff --git a/distro/ubuntu/build b/distro/ubuntu/build index ed5c5569..772cda64 100755 --- a/distro/ubuntu/build +++ b/distro/ubuntu/build @@ -2,7 +2,7 @@ # fill it pkgname=mate-applets -pkgver=1.1.1 +pkgver=1.1.3 pkgrel=1 pkgdesc="MATE Applets" depends=('gstreamer0.10-plugins-base' 'mate-panel' 'mate-character-map' 'libgtop2-7' 'libmatenotify' 'cpufrequtils') diff --git a/invest-applet/data/Invest_Applet.server.in.in b/invest-applet/data/Invest_Applet.server.in.in index b2861c28..fe4c6da5 100644 --- a/invest-applet/data/Invest_Applet.server.in.in +++ b/invest-applet/data/Invest_Applet.server.in.in @@ -19,7 +19,7 @@ <oaf_attribute name="name" type="string" _value="Invest"/> <oaf_attribute name="description" type="string" _value="Track your invested money."/> <oaf_attribute name="panel:category" type="string" value="Accessories"/> - <oaf_attribute name="panel:icon" type="string" value="invest-applet"/> + <oaf_attribute name="panel:icon" type="string" value="mate-invest-applet"/> </oaf_server> </oaf_info> diff --git a/invest-applet/data/art/Makefile.am b/invest-applet/data/art/Makefile.am index 7f304f4a..1a5585e5 100644 --- a/invest-applet/data/art/Makefile.am +++ b/invest-applet/data/art/Makefile.am @@ -1,7 +1,7 @@ # ****************************************************************************** # Images and icon # ****************************************************************************** -icons = invest-applet.16.png invest-applet.22.png invest-applet.48.png invest-applet.svg +icons = mate-invest-applet.16.png mate-invest-applet.22.png mate-invest-applet.48.png mate-invest-applet.svg artdir = $(pkgdatadir)/invest-applet art_DATA = invest-16_neutral.png invest-22_neutral.png invest_neutral.svg \ diff --git a/invest-applet/data/art/invest-applet.16.png b/invest-applet/data/art/mate-invest-applet.16.png Binary files differindex c5d6f815..c5d6f815 100644 --- a/invest-applet/data/art/invest-applet.16.png +++ b/invest-applet/data/art/mate-invest-applet.16.png diff --git a/invest-applet/data/art/invest-applet.22.png b/invest-applet/data/art/mate-invest-applet.22.png Binary files differindex eba0caff..eba0caff 100644 --- a/invest-applet/data/art/invest-applet.22.png +++ b/invest-applet/data/art/mate-invest-applet.22.png diff --git a/invest-applet/data/art/invest-applet.48.png b/invest-applet/data/art/mate-invest-applet.48.png Binary files differindex 14e2f9ec..14e2f9ec 100644 --- a/invest-applet/data/art/invest-applet.48.png +++ b/invest-applet/data/art/mate-invest-applet.48.png diff --git a/invest-applet/data/art/invest-applet.svg b/invest-applet/data/art/mate-invest-applet.svg index b5808216..b5808216 100644 --- a/invest-applet/data/art/invest-applet.svg +++ b/invest-applet/data/art/mate-invest-applet.svg diff --git a/invest-applet/invest/Makefile.am b/invest-applet/invest/Makefile.am index 286b974c..7ab75594 100644 --- a/invest-applet/invest/Makefile.am +++ b/invest-applet/invest/Makefile.am @@ -1,11 +1,11 @@ invest-applet: invest-applet.py sed -e "s|\@PYTHONDIR\@|$(pythondir)/|" $< > $@ -bin_SCRIPTS = invest-chart +bin_SCRIPTS = mate-invest-chart libexec_SCRIPTS = invest-applet -investdir = $(pythondir)/invest +investdir = $(pythondir)/mate_invest invest_PYTHON = \ __init__.py \ about.py \ @@ -33,7 +33,7 @@ DISTCLEANFILES = \ EXTRA_DIST = \ defs.py.in \ invest-applet.py \ - invest-chart \ + mate-invest-chart \ test.py #TESTS = test.py diff --git a/invest-applet/invest/about.py b/invest-applet/invest/about.py index e2829e86..2b7293f4 100644 --- a/invest-applet/invest/about.py +++ b/invest-applet/invest/about.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- from os.path import join from gettext import gettext as _ -from invest.defs import VERSION -import invest +from mate_invest.defs import VERSION +import mate_invest import gtk, gtk.gdk invest_logo = None try: - invest_logo = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest_neutral.svg"), 96, 96) + invest_logo = gtk.gdk.pixbuf_new_from_file_at_size(join(mate_invest.ART_DATA_DIR, "invest_neutral.svg"), 96, 96) except Exception, msg: pass diff --git a/invest-applet/invest/applet.py b/invest-applet/invest/applet.py index c1689586..8b134e67 100644 --- a/invest-applet/invest/applet.py +++ b/invest-applet/invest/applet.py @@ -5,11 +5,11 @@ gobject.threads_init() from gettext import gettext as _ import mateconf -import invest, invest.about, invest.chart, invest.preferences, invest.defs -from invest.quotes import QuoteUpdater -from invest.widgets import * +import mate_invest, mate_invest.about, mate_invest.chart, mate_invest.preferences, mate_invest.defs +from mate_invest.quotes import QuoteUpdater +from mate_invest.widgets import * -gtk.window_set_default_icon_from_file(join(invest.ART_DATA_DIR, "invest_neutral.svg")) +gtk.window_set_default_icon_from_file(join(mate_invest.ART_DATA_DIR, "invest_neutral.svg")) class InvestApplet: def __init__(self, applet): @@ -45,9 +45,9 @@ class InvestApplet: def button_clicked(self, widget,event): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: # Three cases... - if len (invest.STOCKS) == 0: + if len (mate_invest.STOCKS) == 0: # a) We aren't configured yet - invest.preferences.show_preferences(self, _("<b>You have not entered any stock information yet</b>")) + mate_invest.preferences.show_preferences(self, _("<b>You have not entered any stock information yet</b>")) self.reload_ilw() elif not self.quotes_updater.quotes_valid: # b) We can't get the data (e.g. offline) @@ -61,13 +61,13 @@ class InvestApplet: self.ilw.toggle_show() def on_about(self, component, verb): - invest.about.show_about() + mate_invest.about.show_about() def on_help(self, component, verb): - invest.help.show_help() + mate_invest.help.show_help() def on_preferences(self, component, verb): - invest.preferences.show_preferences(self) + mate_invest.preferences.show_preferences(self) self.reload_ilw() def on_refresh(self, component, verb): @@ -75,11 +75,11 @@ class InvestApplet: def set_applet_icon(self, change): if change == 1: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_up.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate_invest.ART_DATA_DIR, "invest-22_up.png"), -1,-1) elif change == 0: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_neutral.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate_invest.ART_DATA_DIR, "invest-22_neutral.png"), -1,-1) else: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_down.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate_invest.ART_DATA_DIR, "invest-22_down.png"), -1,-1) self.applet_icon.set_from_pixbuf(pixbuf) def set_applet_tooltip(self, text): diff --git a/invest-applet/invest/chart.py b/invest-applet/invest/chart.py index c6caff74..358c51df 100644 --- a/invest-applet/invest/chart.py +++ b/invest-applet/invest/chart.py @@ -3,9 +3,9 @@ import gtk, gtk.gdk import gobject import os -import invest +import mate_invest from gettext import gettext as _ -from invest import * +from mate_invest import * import sys from os.path import join import urllib @@ -48,9 +48,9 @@ class ImageRetriever(Thread, _IdleObject): def run(self): self.image = gtk.Image() - try: sock = urllib.urlopen(self.image_url, proxies = invest.PROXY) + try: sock = urllib.urlopen(self.image_url, proxies = mate_invest.PROXY) except Exception, msg: - invest.debug("Error while opening %s: %s" % (self.image_url, msg)) + mate_invest.debug("Error while opening %s: %s" % (self.image_url, msg)) else: loader = gtk.gdk.PixbufLoader() loader.connect("closed", lambda loader: self.image.set_from_pixbuf(loader.get_pixbuf())) @@ -107,10 +107,10 @@ class FinancialChart: win.set_title(_("Financial Chart")) try: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest_neutral.svg"), 96,96) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate_invest.ART_DATA_DIR, "invest_neutral.svg"), 96,96) self.ui.get_object("plot").set_from_pixbuf(pixbuf) except Exception, msg: - invest.debug("Could not load 'invest-neutral.svg' file: %s" % msg) + mate_invest.debug("Could not load 'invest-neutral.svg' file: %s" % msg) pass # Defaut comboboxes values @@ -249,7 +249,7 @@ class FinancialChart: def show_chart(tickers): ui = gtk.Builder(); - ui.add_from_file(os.path.join(invest.BUILDER_DATA_DIR, "financialchart.ui")) + ui.add_from_file(os.path.join(mate_invest.BUILDER_DATA_DIR, "financialchart.ui")) chart = FinancialChart(ui) ui.get_object("s").set_text(' '.join(tickers)) chart.on_refresh_chart() diff --git a/invest-applet/invest/invest-applet.py b/invest-applet/invest/invest-applet.py index 884bcba8..1e08c5ab 100755 --- a/invest-applet/invest/invest-applet.py +++ b/invest-applet/invest/invest-applet.py @@ -19,20 +19,20 @@ else: sys.path.insert(0, abspath("@PYTHONDIR@")) # Now the path is set, import our applet -import invest, invest.applet, invest.defs, invest.help +import mate_invest, mate_invest.applet, mate_invest.defs, mate_invest.help # Prepare i18n import gettext, locale -gettext.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -gettext.textdomain(invest.defs.GETTEXT_PACKAGE) -locale.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -locale.textdomain(invest.defs.GETTEXT_PACKAGE) +gettext.bindtextdomain(mate_invest.defs.GETTEXT_PACKAGE, mate_invest.defs.MATELOCALEDIR) +gettext.textdomain(mate_invest.defs.GETTEXT_PACKAGE) +locale.bindtextdomain(mate_invest.defs.GETTEXT_PACKAGE, mate_invest.defs.MATELOCALEDIR) +locale.textdomain(mate_invest.defs.GETTEXT_PACKAGE) from gettext import gettext as _ def applet_factory(applet, iid): - invest.debug('Starting invest instance: %s %s'% ( applet, iid )) - invest.applet.InvestApplet(applet) + mate_invest.debug('Starting invest instance: %s %s'% ( applet, iid )) + mate_invest.applet.InvestApplet(applet) return True # Return a standalone window that holds the applet @@ -77,12 +77,12 @@ if __name__ == "__main__": if o in ("-h", "--help"): usage() elif o in ("-d", "--debug"): - invest.DEBUGGING = True - invest.debug("Debugging enabled") - # these messages cannot be turned by invest.DEBUGGING at their originating location, + mate_invest.DEBUGGING = True + mate_invest.debug("Debugging enabled") + # these messages cannot be turned by mate_invest.DEBUGGING at their originating location, # because that variable was set here to be True - invest.debug("Data Dir: %s" % invest.SHARED_DATA_DIR) - invest.debug("Detected PROXY: %s" % invest.PROXY) + mate_invest.debug("Data Dir: %s" % mate_invest.SHARED_DATA_DIR) + mate_invest.debug("Detected PROXY: %s" % mate_invest.PROXY) elif o in ("-w", "--window"): standalone = True @@ -93,6 +93,6 @@ if __name__ == "__main__": mateapplet.matecomponent_factory( "OAFIID:Invest_Applet_Factory", mateapplet.Applet.__gtype__, - invest.defs.PACKAGE, - invest.defs.VERSION, + mate_invest.defs.PACKAGE, + mate_invest.defs.VERSION, applet_factory) diff --git a/invest-applet/invest/invest-chart b/invest-applet/invest/invest-chart deleted file mode 100755 index 37df77cb..00000000 --- a/invest-applet/invest/invest-chart +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import sys, invest.chart, gtk - -# Prepare i18n -import gettext, locale -gettext.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -gettext.textdomain(invest.defs.GETTEXT_PACKAGE) -locale.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -locale.textdomain(invest.defs.GETTEXT_PACKAGE) - -if __name__ == "__main__": - win = invest.chart.show_chart(sys.argv[1:]) - win.connect("destroy", lambda x: gtk.main_quit()) - gtk.main() diff --git a/invest-applet/invest/mate-invest-chart b/invest-applet/invest/mate-invest-chart new file mode 100755 index 00000000..ea025de8 --- /dev/null +++ b/invest-applet/invest/mate-invest-chart @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import sys, mate_invest.chart, gtk + +# Prepare i18n +import gettext, locale +gettext.bindtextdomain(mate_invest.defs.GETTEXT_PACKAGE, mate_invest.defs.MATELOCALEDIR) +gettext.textdomain(mate_invest.defs.GETTEXT_PACKAGE) +locale.bindtextdomain(mate_invest.defs.GETTEXT_PACKAGE, mate_invest.defs.MATELOCALEDIR) +locale.textdomain(mate_invest.defs.GETTEXT_PACKAGE) + +if __name__ == "__main__": + win = mate_invest.chart.show_chart(sys.argv[1:]) + win.connect("destroy", lambda x: gtk.main_quit()) + gtk.main() diff --git a/invest-applet/invest/networkmanager.py b/invest-applet/invest/networkmanager.py index 415e9ce4..152cd862 100644 --- a/invest-applet/invest/networkmanager.py +++ b/invest-applet/invest/networkmanager.py @@ -1,4 +1,4 @@ -import invest +import mate_invest from dbus.mainloop.glib import DBusGMainLoop import dbus @@ -19,7 +19,7 @@ class NetworkManager: loop = DBusGMainLoop() # get the NetworkManager object from D-Bus - invest.debug("Connecting to Network Manager via D-Bus") + mate_invest.debug("Connecting to Network Manager via D-Bus") bus = dbus.SystemBus(mainloop=loop) nmobj = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') nm = dbus.Interface(nmobj, 'org.freedesktop.NetworkManager') @@ -32,9 +32,9 @@ class NetworkManager: # get the current status of the network manager self.state = nm.state() - invest.debug("Current Network Manager status is %d" % self.state) + mate_invest.debug("Current Network Manager status is %d" % self.state) except Exception, msg: - invest.error("Could not connect to the Network Manager: %s" % msg ) + mate_invest.error("Could not connect to the Network Manager: %s" % msg ) def online(self): return self.state == STATE_UNKNOWN or self.state == STATE_CONNECTED @@ -47,7 +47,7 @@ class NetworkManager: if isinstance(signal, dict): state = signal.get('State') if state != None: - invest.debug("Network Manager change state %d => %d" % (self.state, state) ); + mate_invest.debug("Network Manager change state %d => %d" % (self.state, state) ); self.state = state # notify about state change diff --git a/invest-applet/invest/preferences.py b/invest-applet/invest/preferences.py index 3c48ee42..03a9147f 100644 --- a/invest-applet/invest/preferences.py +++ b/invest-applet/invest/preferences.py @@ -2,14 +2,14 @@ from gettext import gettext as _ import locale from os.path import join import gtk, gobject, mateconf -import invest +import mate_invest import currencies import cPickle class PrefsDialog: def __init__(self, applet): self.ui = gtk.Builder() - self.ui.add_from_file(join(invest.BUILDER_DATA_DIR, "prefs-dialog.ui")) + self.ui.add_from_file(join(mate_invest.BUILDER_DATA_DIR, "prefs-dialog.ui")) self.dialog = self.ui.get_object("preferences") self.treeview = self.ui.get_object("stocks") @@ -44,8 +44,8 @@ class PrefsDialog: completion.set_match_func(self.match_func, 0) completion.connect("match-selected", self.on_completion_selection, 1) - if invest.CONFIG.has_key("currency"): - code = invest.CONFIG["currency"]; + if mate_invest.CONFIG.has_key("currency"): + code = mate_invest.CONFIG["currency"]; if self.currencies.has_key(code): self.currency_code = code; currency = self.format_currency(self.currencies[self.currency_code], self.currency_code) @@ -56,7 +56,7 @@ class PrefsDialog: if self.currency_code != None: self.add_exchange_column() - stock_items = invest.STOCKS.items () + stock_items = mate_invest.STOCKS.items () stock_items.sort () for key, data in stock_items: label = data["label"] @@ -80,7 +80,7 @@ class PrefsDialog: value = locale.atof(new_text) self.model[path][col] = value except Exception, msg: - invest.error('Exception while processing cell change: %s' % msg) + mate_invest.error('Exception while processing cell change: %s' % msg) pass def format(self, fmt, value): @@ -138,16 +138,16 @@ class PrefsDialog: pass self.dialog.destroy() - invest.STOCKS = {} + mate_invest.STOCKS = {} def save_symbol(model, path, iter): #if int(model[iter][1]) == 0 or float(model[iter][2]) < 0.0001: # return - if not model[iter][0] in invest.STOCKS: - invest.STOCKS[model[iter][0]] = { 'label': model[iter][1], 'purchases': [] } + if not model[iter][0] in mate_invest.STOCKS: + mate_invest.STOCKS[model[iter][0]] = { 'label': model[iter][1], 'purchases': [] } - invest.STOCKS[model[iter][0]]["purchases"].append({ + mate_invest.STOCKS[model[iter][0]]["purchases"].append({ "amount": float(model[iter][2]), "bought": float(model[iter][3]), "comission": float(model[iter][4]), @@ -155,19 +155,19 @@ class PrefsDialog: }) self.model.foreach(save_symbol) try: - cPickle.dump(invest.STOCKS, file(invest.STOCKS_FILE, 'w')) - invest.debug('Stocks written to file') + cPickle.dump(mate_invest.STOCKS, file(mate_invest.STOCKS_FILE, 'w')) + mate_invest.debug('Stocks written to file') except Exception, msg: - invest.error('Could not save stocks file: %s' % msg) + mate_invest.error('Could not save stocks file: %s' % msg) - invest.CONFIG = {} + mate_invest.CONFIG = {} if self.currency_code != None and len(self.currency_code) == 3: - invest.CONFIG['currency'] = self.currency_code + mate_invest.CONFIG['currency'] = self.currency_code try: - cPickle.dump(invest.CONFIG, file(invest.CONFIG_FILE, 'w')) - invest.debug('Configuration written to file') + cPickle.dump(invest.CONFIG, file(mate_invest.CONFIG_FILE, 'w')) + mate_invest.debug('Configuration written to file') except Exception, msg: - invest.debug('Could not save configuration file: %s' % msg) + mate_invest.debug('Could not save configuration file: %s' % msg) def sync_ui(self): pass @@ -183,7 +183,7 @@ class PrefsDialog: model.remove(model.get_iter(path)) def on_help(self, w): - invest.help.show_help_section("invest-applet-usage") + mate_invest.help.show_help_section("invest-applet-usage") def on_tree_keypress(self, w, event): if event.keyval == 65535: diff --git a/invest-applet/invest/quotes.py b/invest-applet/invest/quotes.py index e8f6145b..0d8e028e 100644 --- a/invest-applet/invest/quotes.py +++ b/invest-applet/invest/quotes.py @@ -7,7 +7,7 @@ from urllib import urlopen import datetime from threading import Thread -import invest, invest.about, invest.chart +import mate_invest, mate_invest.about, mate_invest.chart import currencies CHUNK_SIZE = 512*1024 # 512 kB @@ -55,11 +55,11 @@ class QuotesRetriever(Thread, _IdleObject): def run(self): quotes_url = QUOTES_URL % {"s": self.tickers} try: - quotes_file = urlopen(quotes_url, proxies = invest.PROXY) + quotes_file = urlopen(quotes_url, proxies = mate_invest.PROXY) self.data = quotes_file.readlines () quotes_file.close () except Exception, msg: - invest.debug("Error while retrieving quotes data (url = %s): %s" % (quotes_url, msg)) + mate_invest.debug("Error while retrieving quotes data (url = %s): %s" % (quotes_url, msg)) else: self.retrieved = True self.emit("completed") @@ -80,37 +80,37 @@ class QuoteUpdater(gtk.ListStore): self.refresh() # tell the network manager to notify me when network status changes - invest.nm.set_statechange_callback(self.nm_state_changed) + mate_invest.nm.set_statechange_callback(self.nm_state_changed) def set_update_interval(self, interval): if self.timeout_id != None: - invest.debug("Canceling refresh timer") + mate_invest.debug("Canceling refresh timer") gobject.source_remove(self.timeout_id) self.timeout_id = None if interval > 0: - invest.debug("Setting refresh timer to %s:%02d.%03d" % ( interval / 60000, interval % 60000 / 1000, interval % 1000) ) + mate_invest.debug("Setting refresh timer to %s:%02d.%03d" % ( interval / 60000, interval % 60000 / 1000, interval % 1000) ) self.timeout_id = gobject.timeout_add(interval, self.refresh) def nm_state_changed(self): # when nm is online but we do not have an update timer, create it and refresh - if invest.nm.online(): + if mate_invest.nm.online(): if self.timeout_id == None: self.set_update_interval(AUTOREFRESH_TIMEOUT) self.refresh() def refresh(self): - invest.debug("Refreshing") + mate_invest.debug("Refreshing") # when nm tells me I am offline, stop the update interval - if invest.nm.offline(): - invest.debug("We are offline, stopping update timer") + if mate_invest.nm.offline(): + mate_invest.debug("We are offline, stopping update timer") self.set_update_interval(0) return False - if len(invest.STOCKS) == 0: + if len(mate_invest.STOCKS) == 0: return True - tickers = '+'.join(invest.STOCKS.keys()) + tickers = '+'.join(mate_invest.STOCKS.keys()) quotes_retriever = QuotesRetriever(tickers) quotes_retriever.connect("completed", self.on_retriever_completed) quotes_retriever.start() @@ -141,7 +141,7 @@ class QuoteUpdater(gtk.ListStore): def on_currency_retriever_completed(self, retriever): if retriever.retrieved == False: - invest.error("Failed to retrieve currency rates!") + mate_invest.error("Failed to retrieve currency rates!") else: self.convert_currencies(self.parse_yahoo_csv(csv.reader(retriever.data))) self.update_tooltip() @@ -239,7 +239,7 @@ class QuoteUpdater(gtk.ListStore): pb = None # get the label of this stock for later reuse - label = invest.STOCKS[ticker]["label"] + label = mate_invest.STOCKS[ticker]["label"] if len(label) == 0: if len(val["label"]) != 0: label = val["label"] @@ -260,7 +260,7 @@ class QuoteUpdater(gtk.ListStore): # sometimes, funny currencies are returned (special characters), only consider known currencies if len(val["currency"]) > 0 and val["currency"] not in currencies.Currencies.currencies: - invest.debug("Currency '%s' is not known, dropping" % val["currency"]) + mate_invest.debug("Currency '%s' is not known, dropping" % val["currency"]) val["currency"] = "" # if this is a currency not yet seen and different from the target currency, memorize it @@ -269,7 +269,7 @@ class QuoteUpdater(gtk.ListStore): # Check whether the symbol is a simple quote, or a portfolio value is_simple_quote = True - for purchase in invest.STOCKS[ticker]["purchases"]: + for purchase in mate_invest.STOCKS[ticker]["purchases"]: if purchase["amount"] != 0: is_simple_quote = False break @@ -279,7 +279,7 @@ class QuoteUpdater(gtk.ListStore): row = self.insert(0, [ticker, label, val["currency"], True, 0, 0, val["trade"], val["variation_pct"], pb]) simple_quotes_change += val['variation_pct'] else: - (balance, change) = self.balance(invest.STOCKS[ticker]["purchases"], val["trade"]) + (balance, change) = self.balance(mate_invest.STOCKS[ticker]["purchases"], val["trade"]) row = self.insert(0, [ticker, label, val["currency"], False, balance, change, val["trade"], val["variation_pct"], pb]) self.add_balance_change(balance, change, val["currency"]) @@ -288,7 +288,7 @@ class QuoteUpdater(gtk.ListStore): else: url = 'http://ichart.yahoo.com/h?s=%s' % ticker - image_retriever = invest.chart.ImageRetriever(url) + image_retriever = mate_invest.chart.ImageRetriever(url) image_retriever.connect("completed", self.set_pb_callback, row) image_retriever.start() @@ -313,21 +313,21 @@ class QuoteUpdater(gtk.ListStore): self.quotes_valid = True except Exception, msg: - invest.debug("Failed to populate quotes: %s" % msg) - invest.debug(quotes) + mate_invest.debug("Failed to populate quotes: %s" % msg) + mate_invest.debug(quotes) self.quotes_valid = False # start retrieving currency conversion rates - if invest.CONFIG.has_key("currency"): - target_currency = invest.CONFIG["currency"] + if mate_invest.CONFIG.has_key("currency"): + target_currency = mate_invest.CONFIG["currency"] symbols = [] - invest.debug("These currencies occur: %s" % self.currencies) + mate_invest.debug("These currencies occur: %s" % self.currencies) for currency in self.currencies: if currency == target_currency: continue - invest.debug("%s will be converted to %s" % ( currency, target_currency )) + mate_invest.debug("%s will be converted to %s" % ( currency, target_currency )) symbol = currency + target_currency + "=X" symbols.append(symbol) @@ -339,7 +339,7 @@ class QuoteUpdater(gtk.ListStore): def convert_currencies(self, quotes): # if there is no target currency, this method should never have been called - if not invest.CONFIG.has_key("currency"): + if not mate_invest.CONFIG.has_key("currency"): return # reset the overall balance @@ -353,7 +353,7 @@ class QuoteUpdater(gtk.ListStore): rates[currency] = rate # convert all non target currencies - target_currency = invest.CONFIG["currency"] + target_currency = mate_invest.CONFIG["currency"] iter = self.get_iter_first() while iter != None: currency = self.get_value(iter, self.CURRENCY) @@ -367,7 +367,7 @@ class QuoteUpdater(gtk.ListStore): if not self.get_value(iter, self.TICKER_ONLY): ticker = self.get_value(iter, self.SYMBOL) value = self.get_value(iter, self.VALUE) - (balance, change) = self.balance(invest.STOCKS[ticker]["purchases"], value, rates[currency]) + (balance, change) = self.balance(mate_invest.STOCKS[ticker]["purchases"], value, rates[currency]) self.set(iter, self.BALANCE, balance) self.set(iter, self.BALANCE_PCT, change) self.add_balance_change(balance, change, target_currency) @@ -402,7 +402,7 @@ class QuoteUpdater(gtk.ListStore): # check if we have only simple quotes def simple_quotes_only(self): res = True - for entry, data in invest.STOCKS.iteritems(): + for entry, data in mate_invest.STOCKS.iteritems(): purchases = data["purchases"] for purchase in purchases: if purchase["amount"] != 0: diff --git a/invest-applet/invest/test.py b/invest-applet/invest/test.py index aea5f5f3..046881bb 100755 --- a/invest-applet/invest/test.py +++ b/invest-applet/invest/test.py @@ -9,7 +9,7 @@ sys.path.insert(0, abspath(dirname(__file__) + "/..")) print sys.path import quotes -import invest +import mate_invest def null_function (*args): pass @@ -17,7 +17,7 @@ def null_function (*args): class TestQuotes (unittest.TestCase): def testQuoteUpdater_populate (self): qu = quotes.QuoteUpdater (null_function, null_function) - invest.STOCKS = {'GOGO': {'label': "Google Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}, 'JAVA': {'label':"Sun Microsystems Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}} + mate_invest.STOCKS = {'GOGO': {'label': "Google Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}, 'JAVA': {'label':"Sun Microsystems Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}} quote = { 'GOGO': { "ticker": 'GOGO', "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }} qu.populate (quote) self.assertEqual (qu.quotes_valid, True) diff --git a/invest-applet/invest/widgets.py b/invest-applet/invest/widgets.py index 3f5bc91b..0a897e30 100644 --- a/invest-applet/invest/widgets.py +++ b/invest-applet/invest/widgets.py @@ -4,7 +4,7 @@ import mateapplet, gtk, gtk.gdk, mateconf, gobject, pango from gettext import gettext as _ import locale import csv -import invest, invest.about, invest.chart +import mate_invest, mate_invest.about, mate_invest.chart COLORSCALE_POSITIVE = [ "white", @@ -154,7 +154,7 @@ class InvestWidget(gtk.TreeView): if ticker == None: return - invest.chart.show_chart([ticker]) + mate_invest.chart.show_chart([ticker]) #class InvestTicker(gtk.Label): # def __init__(self): @@ -215,7 +215,7 @@ class InvestTrend(gtk.Image): int(color.red*factor)<<24|int(color.green*factor)<<16|int(color.blue*factor)<<8|opacity) self.set_from_pixbuf(self.pixbuf) except Exception, msg: - invest.error("Could not set color: %s" % msg) + mate_invest.error("Could not set color: %s" % msg) def on_quotes_update(self, updater): start_total = 0 @@ -230,7 +230,7 @@ class InvestTrend(gtk.Image): start = now / (1 + var) - portfolio_number = sum([purchase["amount"] for purchase in invest.STOCKS[row[updater.SYMBOL]]["purchases"]]) + portfolio_number = sum([purchase["amount"] for purchase in mate_invest.STOCKS[row[updater.SYMBOL]]["purchases"]]) start_total += start * portfolio_number now_total += now * portfolio_number |