[gnome-applets] invest-applet: port invest applet to Gtk 3, see bug 619818 - this is a one-patch merge of branch wip
- From: Enrico Minack <eminack src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] invest-applet: port invest applet to Gtk 3, see bug 619818 - this is a one-patch merge of branch wip
- Date: Sat, 7 May 2011 22:12:03 +0000 (UTC)
commit 92d0dcf62dfcd60c8e87f64213c14f7f786627fe
Author: Enrico Minack <enrico-minack gmx de>
Date: Sat May 7 23:42:09 2011 +0200
invest-applet: port invest applet to Gtk 3, see bug 619818
- this is a one-patch merge of branch wip/dont-use-deprecated as of commit 83515e0a
- replaces old Bonobo-files with DBus and gnome-panel files
- moved to Gtk3 API and python GObject introspection
- added default exception handler to gracefully handle uncaught exceptions
- added some more high-level debug messages
- removed standalone mode from applet, this can be achieved via panel-applet-test
- had to explicitly state float values where expected (ints do not work anymore)
configure.in | 34 ++---
invest-applet/data/GNOME_GtikApplet.server | 18 --
invest-applet/data/Invest_Applet.server.in.in | 25 ---
invest-applet/data/Invest_Applet.xml | 10 -
invest-applet/data/Makefile.am | 52 +++---
invest-applet/data/financialchart.ui | 4 +-
invest-applet/data/invest-applet-menu.xml | 5 +
...g.gnome.applets.InvestApplet.panel-applet.in.in | 16 ++
...ome.panel.applet.InvestAppletFactory.service.in | 3 +
invest-applet/invest/__init__.py | 26 ++-
invest-applet/invest/about.py | 6 +-
invest-applet/invest/applet.py | 184 ++++++++++----------
invest-applet/invest/chart.py | 25 ++--
invest-applet/invest/defs.py.in | 1 +
invest-applet/invest/help.py | 6 +-
invest-applet/invest/invest-applet.py | 60 +++----
invest-applet/invest/networkmanager.py | 6 +-
invest-applet/invest/preferences.py | 26 ++--
invest-applet/invest/quotes.py | 43 +++--
invest-applet/invest/widgets.py | 44 +++---
po/POTFILES.in | 3 +-
21 files changed, 285 insertions(+), 312 deletions(-)
---
diff --git a/configure.in b/configure.in
index 80d073c..02122fd 100644
--- a/configure.in
+++ b/configure.in
@@ -25,9 +25,7 @@ LIBNOTIFY_REQUIRED=0.7
HAL_REQUIRED=0.5.3
DBUS_REQUIRED=1.1.2
DBUS_GLIB_REQUIRED=0.74
-PYGTK_REQUIRED=2.6
-PYGOBJECT_REQUIRED=2.6
-GNOME_PYTHON_REQUIRED=2.10
+PYGOBJECT_REQUIRED=2.26
GNOME_ICON_THEME_REQUIRED=2.15.91
LIBXML_REQUIRED=2.5.0
GWEATHER_REQUIRED=2.91.0
@@ -235,16 +233,13 @@ AC_SUBST(GUCHARMAP_CFLAGS)
AC_SUBST(GUCHARMAP_LIBS)
dnl -- check for Python/GNOME modules (optional) ------------------------------
-#PYGTK_CFLAGS=
-#PYGTK_LIBS=
-#PKG_CHECK_MODULES(PYGTK,
-# pygtk-2.0 >= $PYGTK_REQUIRED
-# pygobject-2.0 >= $PYGOBJECT_REQUIRED
-# gnome-python-2.0 >= $GNOME_PYTHON_REQUIRED,
-# HAVE_PYGTK="yes", HAVE_PYGTK="no")
-#AC_SUBST(PYGTK_LIBS)
-#AC_SUBST(PYGTK_CFLAGS)
-HAVE_PYGTK=no
+PYGTK_CFLAGS=
+PYGTK_LIBS=
+PKG_CHECK_MODULES(PYGTK,
+ pygobject-2.0 >= $PYGOBJECT_REQUIRED,
+ HAVE_PYGTK="yes", HAVE_PYGTK="no")
+AC_SUBST(PYGTK_LIBS)
+AC_SUBST(PYGTK_CFLAGS)
dnl -- check for libxml2 (required) ------------------------------------------
PKG_CHECK_MODULES(XML2, libxml-2.0 >= $LIBXML_REQUIRED)
@@ -268,6 +263,7 @@ AC_ARG_ENABLE([networkmanager],
HAVE_NETWORKMANAGER=no
NETWORKMANAGER_VERSION=unkown
+AC_SUBST(NETWORKMANAGER_VERSION)
if test "x$ENABLE_NETWORKMANAGER" = "xyes"; then
PKG_CHECK_MODULES(NETWORKMANAGER, NetworkManager >= $NETWORKMANAGER_REQUIRED,
HAVE_NETWORKMANAGER=yes, HAVE_NETWORKMANAGER=no)
@@ -277,7 +273,6 @@ if test "x$ENABLE_NETWORKMANAGER" = "xyes"; then
NETWORKMANAGER_VERSION=`$PKG_CONFIG --modversion NetworkManager`
AC_SUBST(NETWORKMANAGER_CFLAGS)
AC_SUBST(NETWORKMANAGER_LIBS)
- AC_SUBST(NETWORKMANAGER_VERSION)
fi
fi
@@ -547,14 +542,7 @@ dnl ***************************************************************************
dnl *** invest-applet specific checks ***
dnl ***************************************************************************
-if test "x$HAVE_PYGTK" = "xyes" -a "x$HAVE_PYHDRS" = "xyes"; then
- AM_CHECK_PYMOD(gnomeapplet,,
- BUILD_INVEST_APPLET="yes", BUILD_INVEST_APPLET="no")
-else
- BUILD_INVEST_APPLET="no"
-fi
-
-AM_CONDITIONAL(BUILD_INVEST_APPLET, test "x$BUILD_INVEST_APPLET" = "xyes")
+AM_CONDITIONAL(BUILD_INVEST_APPLET, test "x$HAVE_PYGTK" = "xyes")
dnl ***************************************************************************
dnl *** Check if IPv6 is available ***
@@ -650,11 +638,13 @@ AC_DEFINE_DIR(LIBDIR, "${libdir}", [libdir])
AC_DEFINE_DIR(PREFIX, "$prefix", [install prefix])
AS_AC_EXPAND(DATADIR, "${datadir}")
+AS_AC_EXPAND(PKGDATADIR, "${pkgdatadir}")
AS_AC_EXPAND(PYTHONDIR, $pythondir)
AS_AC_EXPAND(BUILDERDIR, $builderdir)
AC_SUBST(VERSION)
AC_SUBST(PACKAGE)
+AC_SUBST(PKGDATADIR)
AC_SUBST(DATADIR)
AC_SUBST(LIBDIR)
AC_SUBST(PYTHONDIR)
diff --git a/invest-applet/data/Makefile.am b/invest-applet/data/Makefile.am
index 9a31989..d1ac0c0 100644
--- a/invest-applet/data/Makefile.am
+++ b/invest-applet/data/Makefile.am
@@ -1,28 +1,36 @@
SUBDIRS = art
# ******************************************************************************
-# Panel applet bonobo stuff
+# Panel Applet stuff
# ******************************************************************************
-serverdir = $(libdir)/bonobo/servers
-server_in_files = Invest_Applet.server.in
-server_DATA = \
- $(server_in_files:.server.in=.server) \
- GNOME_GtikApplet.server
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.InvestAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.InvestAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+appletdir = $(LIBPANEL_APPLET_DIR)
+applet_in_files = org.gnome.applets.InvestApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
+
+$(applet_in_files): $(applet_in_files).in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
+
+%.panel-applet: %.panel-applet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
-# ******************************************************************************
-# GConf Schemas
-# ******************************************************************************
-# GConf Preference Schemas
-#schemadir = $(GCONF_SCHEMA_FILE_DIR)
-#schema_in_files = deskbar-applet.schemas.in
-#schema_DATA = $(schema_in_files:.schemas.in=.schemas)
# ******************************************************************************
# Misc data
# ******************************************************************************
-uidir = $(datadir)/gnome-2.0/ui
+uidir = $(pkgdatadir)/ui
ui_DATA = \
- Invest_Applet.xml
+ invest-applet-menu.xml
builder_DATA = \
prefs-dialog.ui \
financialchart.ui
@@ -35,23 +43,17 @@ investbindir = $(libdir)/invest-applet
@INTLTOOL_SERVER_RULE@
@INTLTOOL_SCHEMAS_RULE@
-$(server_in_files): $(server_in_files:.server.in=.server.in.in)
- sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
-#if GCONF_SCHEMAS_INSTALL
-#install-data-local: install-schemas
-#install-schemas:
-# GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
-# $(GCONFTOOL) --makefile-install-rule $(schema_DATA)
-#endif
+
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
DISTCLEANFILES = \
$(server_in_files) \
$(server_in_files:.server.in=.server)
EXTRA_DIST = \
- Invest_Applet.server.in.in \
- GNOME_GtikApplet.server \
+ org.gnome.applets.InvestApplet.panel-applet.in.in \
+ $(service_in_files) \
$(ui_DATA) \
$(builder_DATA)
diff --git a/invest-applet/data/financialchart.ui b/invest-applet/data/financialchart.ui
index 1de0f38..1f418d7 100644
--- a/invest-applet/data/financialchart.ui
+++ b/invest-applet/data/financialchart.ui
@@ -194,7 +194,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="t">
+ <object class="GtkComboBoxText" id="t">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
@@ -316,7 +316,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="q">
+ <object class="GtkComboBoxText" id="q">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
diff --git a/invest-applet/data/invest-applet-menu.xml b/invest-applet/data/invest-applet-menu.xml
new file mode 100644
index 0000000..d4a3e61
--- /dev/null
+++ b/invest-applet/data/invest-applet-menu.xml
@@ -0,0 +1,5 @@
+<menuitem name="Refresh" action="Refresh" />
+<menuitem name="Prefs" action="Prefs" />
+<separator/>
+<menuitem name="About" action="About" />
+<menuitem name="Help" action="Help" />
diff --git a/invest-applet/data/org.gnome.applets.InvestApplet.panel-applet.in.in b/invest-applet/data/org.gnome.applets.InvestApplet.panel-applet.in.in
new file mode 100644
index 0000000..60d4ffc
--- /dev/null
+++ b/invest-applet/data/org.gnome.applets.InvestApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=InvestAppletFactory
+Location= LIBEXECDIR@/invest-applet
+_Name=Invest Applet Factory
+_Description=Factory for creating the invest applet.
+
+[InvestApplet]
+_Name=Invest
+_Description=Track your invested money.
+Icon=invest-applet
+BonoboId=OAFIID:Invest_Applet_Factory
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=invest
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=invest-applet
diff --git a/invest-applet/data/org.gnome.panel.applet.InvestAppletFactory.service.in b/invest-applet/data/org.gnome.panel.applet.InvestAppletFactory.service.in
new file mode 100644
index 0000000..907f20b
--- /dev/null
+++ b/invest-applet/data/org.gnome.panel.applet.InvestAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.InvestAppletFactory
+Exec= LIBEXECDIR@/invest-applet
diff --git a/invest-applet/invest/__init__.py b/invest-applet/invest/__init__.py
index 29fb7d6..5f4f914 100644
--- a/invest-applet/invest/__init__.py
+++ b/invest-applet/invest/__init__.py
@@ -1,11 +1,9 @@
-import os, sys
+import os, sys, traceback
from os.path import join, exists, isdir, isfile, dirname, abspath, expanduser
from types import ListType
import datetime
-
-import gtk, gtk.gdk, gconf, gobject
+from gi.repository import GObject, Gtk, Gdk, GConf
import cPickle
-
import networkmanager
# Autotools set the actual data_dir in defs.py
@@ -22,6 +20,17 @@ def error(msg):
print "%s: ERROR: %s" % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), msg)
+def exceptionhandler(t, value, tb):
+ error("%s occurred: %s" % (t.__name__, value))
+ for elem in traceback.extract_tb(tb):
+ error("\t%s:%d in %s: %s" % (elem[0], elem[1], elem[2], elem[3]))
+
+# redirect uncaught exceptions to this exception handler
+debug("Installing default exception handler")
+sys.excepthook = exceptionhandler
+
+
+
# Allow to use uninstalled invest ---------------------------------------------
UNINSTALLED_INVEST = False
def _check(path):
@@ -55,7 +64,7 @@ if not exists(USER_INVEST_DIR):
os.chdir(expanduser("~"))
#Gconf client
-GCONF_CLIENT = gconf.client_get_default()
+GCONF_CLIENT = GConf.Client.get_default()
# GConf directory for invest in window mode and shared settings
GCONF_DIR = "/apps/invest"
@@ -152,6 +161,7 @@ CONFIG_FILE = join(USER_INVEST_DIR, "config.pickle")
try:
CONFIG = cPickle.load(file(CONFIG_FILE))
except Exception, msg:
+ error("Could not load the configuration from %s: %s" % (CONFIG_FILE, msg) )
CONFIG = {} # default configuration
@@ -202,12 +212,14 @@ def get_gnome_proxy_retry(client, attempts, sleep):
# we did not succeed, schedule retry
if attempts > 0:
error("Retrying to contact GConfd in %d seconds" % sleep)
- gobject.timeout_add(sleep * 1000, get_gnome_proxy_retry, client, attempts, sleep)
+ GObject.timeout_add(sleep * 1000, get_gnome_proxy_retry, client, attempts, sleep)
# use gconf to get proxy config
-client = gconf.client_get_default()
+debug("Detecting proxy settings")
+client = GConf.Client.get_default()
get_gnome_proxy(client)
# connect to Network Manager to identify current network connectivity
+debug("Connecting to the NetworkManager")
nm = networkmanager.NetworkManager()
diff --git a/invest-applet/invest/about.py b/invest-applet/invest/about.py
index e2829e8..7b3bd42 100644
--- a/invest-applet/invest/about.py
+++ b/invest-applet/invest/about.py
@@ -3,16 +3,16 @@ from os.path import join
from gettext import gettext as _
from invest.defs import VERSION
import invest
-import gtk, gtk.gdk
+from gi.repository import Gtk, Gdk, GdkPixbuf
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 = GdkPixbuf.Pixbuf.new_from_file_at_size(join(invest.ART_DATA_DIR, "invest_neutral.svg"), 96, 96)
except Exception, msg:
pass
def show_about():
- about = gtk.AboutDialog()
+ about = Gtk.AboutDialog()
infos = {
"program-name" : _("Invest"),
"logo" : invest_logo,
diff --git a/invest-applet/invest/applet.py b/invest-applet/invest/applet.py
index 4cd5ad7..6e199ba 100644
--- a/invest-applet/invest/applet.py
+++ b/invest-applet/invest/applet.py
@@ -1,34 +1,41 @@
import os, time
from os.path import *
-import gnomeapplet, gtk, gtk.gdk, gconf, gobject
-gobject.threads_init()
+
+from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, GConf, PanelApplet
+GObject.threads_init()
+
from gettext import gettext as _
-import gconf
import invest, invest.about, invest.chart, invest.preferences, invest.defs
from invest.quotes import QuoteUpdater
from 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(invest.ART_DATA_DIR, "invest_neutral.svg"))
-class InvestApplet:
+class InvestApplet(PanelApplet.Applet):
def __init__(self, applet):
+ invest.debug("init applet");
self.applet = applet
- self.applet.setup_menu_from_file (
- None, "Invest_Applet.xml",
- None, [("About", self.on_about),
- ("Help", self.on_help),
- ("Prefs", self.on_preferences),
- ("Refresh", self.on_refresh)
- ])
-
- evbox = gtk.HBox()
- self.applet_icon = gtk.Image()
+
+ # name, stock_id, label, accellerator, tooltip, callback
+ menu_actions = [("About", Gtk.STOCK_HELP, _("About"), None, None, self.on_about),
+ ("Help", Gtk.STOCK_HELP, _("Help"), None, None, self.on_help),
+ ("Prefs", Gtk.STOCK_PREFERENCES, _("Preferences"), None, None, self.on_preferences),
+ ("Refresh", Gtk.STOCK_REFRESH, _("Refresh"), None, None, self.on_refresh)
+ ]
+ actiongroup = Gtk.ActionGroup.new("InvestAppletActions")
+ actiongroup.set_translation_domain(invest.defs.GETTEXT_PACKAGE)
+ actiongroup.add_actions(menu_actions, None)
+ self.applet.setup_menu_from_file (join(invest.defs.PKGDATADIR, "ui/invest-applet-menu.xml"),
+ actiongroup);
+
+ evbox = Gtk.HBox()
+ self.applet_icon = Gtk.Image()
self.set_applet_icon(0)
self.applet_icon.show()
evbox.add(self.applet_icon)
self.applet.add(evbox)
- self.applet.connect("button-press-event",self.button_clicked)
+ self.applet.connect("button-press-event", self.button_clicked)
self.applet.show_all()
self.new_ilw()
@@ -43,7 +50,7 @@ class InvestApplet:
self.new_ilw()
def button_clicked(self, widget,event):
- if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
+ if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 1:
# Three cases...
if len (invest.STOCKS) == 0:
# a) We aren't configured yet
@@ -51,7 +58,7 @@ class InvestApplet:
self.reload_ilw()
elif not self.quotes_updater.quotes_valid:
# b) We can't get the data (e.g. offline)
- alert = gtk.MessageDialog(buttons=gtk.BUTTONS_CLOSE)
+ alert = Gtk.MessageDialog(buttons=Gtk.ButtonsType.CLOSE)
alert.set_markup(_("<b>No stock quotes are currently available</b>"))
alert.format_secondary_text(_("The server could not be contacted. The computer is either offline or the servers are down. Try again later."))
alert.run()
@@ -60,35 +67,35 @@ class InvestApplet:
# c) Everything is normal: pop-up the window
self.ilw.toggle_show()
- def on_about(self, component, verb):
+ def on_about(self, action, data):
invest.about.show_about()
- def on_help(self, component, verb):
+ def on_help(self, action, data):
invest.help.show_help()
- def on_preferences(self, component, verb):
+ def on_preferences(self, action, data):
invest.preferences.show_preferences(self)
self.reload_ilw()
- def on_refresh(self, component, verb):
+ def on_refresh(self, action, data):
self.quotes_updater.refresh()
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 = GdkPixbuf.Pixbuf.new_from_file_at_size(join(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 = GdkPixbuf.Pixbuf.new_from_file_at_size(join(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 = GdkPixbuf.Pixbuf.new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_down.png"), -1,-1)
self.applet_icon.set_from_pixbuf(pixbuf)
def set_applet_tooltip(self, text):
self.applet_icon.set_tooltip_text(text)
-class InvestmentsListWindow(gtk.Window):
+class InvestmentsListWindow(Gtk.Window):
def __init__(self, applet, list):
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
+ Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)
+ self.set_type_hint(Gdk.WindowTypeHint.DOCK)
self.stick()
self.set_resizable(False)
self.set_border_width(6)
@@ -118,68 +125,69 @@ class InvestmentsListWindow(gtk.Window):
"""
self.realize()
+ window = self.applet.get_window()
+ screen = window.get_screen()
+ monitor = screen.get_monitor_geometry (screen.get_monitor_at_window (window))
+
# Get our own dimensions & position
#(wx, wy) = self.get_origin()
- (ax, ay) = self.applet.window.get_origin()
-
- (ww, wh) = self.get_size ()
- (aw, ah) = self.applet.window.get_size ()
-
- screen = self.applet.window.get_screen()
- monitor = screen.get_monitor_geometry (screen.get_monitor_at_window (self.applet.window))
-
- if self.alignment == gnomeapplet.ORIENT_LEFT:
- x = ax - ww
- y = ay
-
- if (y + wh > monitor.y + monitor.height):
- y = monitor.y + monitor.height - wh
-
- if (y < 0):
- y = 0
-
- if (y + wh > monitor.height / 2):
- gravity = gtk.gdk.GRAVITY_SOUTH_WEST
- else:
- gravity = gtk.gdk.GRAVITY_NORTH_WEST
-
- elif self.alignment == gnomeapplet.ORIENT_RIGHT:
- x = ax + aw
- y = ay
-
- if (y + wh > monitor.y + monitor.height):
- y = monitor.y + monitor.height - wh
-
- if (y < 0):
- y = 0
-
- if (y + wh > monitor.height / 2):
- gravity = gtk.gdk.GRAVITY_SOUTH_EAST
- else:
- gravity = gtk.gdk.GRAVITY_NORTH_EAST
-
- elif self.alignment == gnomeapplet.ORIENT_DOWN:
- x = ax
- y = ay + ah
-
- if (x + ww > monitor.x + monitor.width):
- x = monitor.x + monitor.width - ww
-
- if (x < 0):
- x = 0
-
- gravity = gtk.gdk.GRAVITY_NORTH_WEST
- elif self.alignment == gnomeapplet.ORIENT_UP:
- x = ax
- y = ay - wh
-
- if (x + ww > monitor.x + monitor.width):
- x = monitor.x + monitor.width - ww
-
- if (x < 0):
- x = 0
-
- gravity = gtk.gdk.GRAVITY_SOUTH_WEST
+ (ret, ax, ay) = window.get_origin()
+
+ (ww, wh) = self.get_size()
+ (ignored, ignored, aw, ah) = window.get_geometry()
+
+ if self.alignment == PanelApplet.AppletOrient.LEFT:
+ x = ax - ww
+ y = ay
+
+ if (y + wh > monitor.y + monitor.height):
+ y = monitor.y + monitor.height - wh
+
+ if (y < 0):
+ y = 0
+
+ if (y + wh > monitor.height / 2):
+ gravity = Gdk.Gravity.SOUTH_WEST
+ else:
+ gravity = Gdk.Gravity.NORTH_WEST
+
+ elif self.alignment == PanelApplet.AppletOrient.RIGHT:
+ x = ax + aw
+ y = ay
+
+ if (y + wh > monitor.y + monitor.height):
+ y = monitor.y + monitor.height - wh
+
+ if (y < 0):
+ y = 0
+
+ if (y + wh > monitor.height / 2):
+ gravity = Gdk.Gravity.SOUTH_EAST
+ else:
+ gravity = Gdk.Gravity.NORTH_EAST
+
+ elif self.alignment == PanelApplet.AppletOrient.DOWN:
+ x = ax
+ y = ay + ah
+
+ if (x + ww > monitor.x + monitor.width):
+ x = monitor.x + monitor.width - ww
+
+ if (x < 0):
+ x = 0
+
+ gravity = Gdk.Gravity.NORTH_WEST
+ elif self.alignment == PanelApplet.AppletOrient.UP:
+ x = ax
+ y = ay - wh
+
+ if (x + ww > monitor.x + monitor.width):
+ x = monitor.x + monitor.width - ww
+
+ if (x < 0):
+ x = 0
+
+ gravity = Gdk.Gravity.SOUTH_WEST
self.move(x, y)
self.set_gravity(gravity)
diff --git a/invest-applet/invest/chart.py b/invest-applet/invest/chart.py
index 15803b6..991ba04 100644
--- a/invest-applet/invest/chart.py
+++ b/invest-applet/invest/chart.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-import gtk, gtk.gdk
-import gobject
+from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, Gio
import os
import invest
from gettext import gettext as _
@@ -15,16 +14,16 @@ import time
AUTOREFRESH_TIMEOUT = 20*60*1000 # 15 minutes
# based on http://www.johnstowers.co.nz/blog/index.php/2007/03/12/threading-and-pygtk/
-class _IdleObject(gobject.GObject):
+class _IdleObject(GObject.Object):
"""
- Override gobject.GObject to always emit signals in the main thread
+ Override GObject.Object to always emit signals in the main thread
by emmitting on an idle handler
"""
def __init__(self):
- gobject.GObject.__init__(self)
+ GObject.Object.__init__(self)
def emit(self, *args):
- gobject.idle_add(gobject.GObject.emit,self,*args)
+ GObject.idle_add(GObject.Object.emit,self,*args)
class ImageRetriever(Thread, _IdleObject):
"""
@@ -33,7 +32,7 @@ class ImageRetriever(Thread, _IdleObject):
"""
__gsignals__ = {
"completed": (
- gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, []),
# FIXME: should we be making use of this?
#"progress": (
# gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
@@ -47,12 +46,12 @@ class ImageRetriever(Thread, _IdleObject):
self.retrieved = False
def run(self):
- self.image = gtk.Image()
+ self.image = Gtk.Image()
try: sock = urllib.urlopen(self.image_url, proxies = invest.PROXY)
except Exception, msg:
invest.debug("Error while opening %s: %s" % (self.image_url, msg))
else:
- loader = gtk.gdk.PixbufLoader()
+ loader = GdkPixbuf.PixbufLoader()
loader.connect("closed", lambda loader: self.image.set_from_pixbuf(loader.get_pixbuf()))
loader.write(sock.read())
sock.close()
@@ -107,7 +106,7 @@ 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 = GdkPixbuf.Pixbuf.new_from_file_at_size(join(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)
@@ -241,14 +240,14 @@ class FinancialChart:
def on_autorefresh_toggled(self, autorefresh):
if self.autorefresh_id != 0:
- gobject.source_remove(self.autorefresh_id)
+ GObject.source_remove(self.autorefresh_id)
self.autorefresh_id = 0
if autorefresh.get_active():
- self.autorefresh_id = gobject.timeout_add(AUTOREFRESH_TIMEOUT, self.on_refresh_chart, True)
+ self.autorefresh_id = GObject.timeout_add(AUTOREFRESH_TIMEOUT, self.on_refresh_chart, True)
def show_chart(tickers):
- ui = gtk.Builder();
+ ui = Gtk.Builder();
ui.add_from_file(os.path.join(invest.BUILDER_DATA_DIR, "financialchart.ui"))
chart = FinancialChart(ui)
ui.get_object("s").set_text(' '.join(tickers))
diff --git a/invest-applet/invest/defs.py.in b/invest-applet/invest/defs.py.in
index 6bca4c7..5a2e732 100644
--- a/invest-applet/invest/defs.py.in
+++ b/invest-applet/invest/defs.py.in
@@ -2,6 +2,7 @@ DATA_DIR = "@DATADIR@"
LIB_DIR = "@LIBDIR@"
VERSION = "@VERSION@"
PACKAGE = "@PACKAGE@"
+PKGDATADIR = "@PKGDATADIR@"
PYTHONDIR = "@PYTHONDIR@"
GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"
GNOMELOCALEDIR = "@GNOMELOCALEDIR@"
diff --git a/invest-applet/invest/help.py b/invest-applet/invest/help.py
index 7dfaabf..2851e54 100644
--- a/invest-applet/invest/help.py
+++ b/invest-applet/invest/help.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-import gtk, gtk.gdk
+from gi.repository import Gtk, Gdk
def show_help():
- gtk.show_uri(None, "ghelp:invest-applet", gtk.gdk.CURRENT_TIME)
+ Gtk.show_uri(None, "ghelp:invest-applet", Gdk.CURRENT_TIME)
def show_help_section(id):
- gtk.show_uri(None, "ghelp:invest-applet?%s" % id, gtk.gdk.CURRENT_TIME)
+ Gtk.show_uri(None, "ghelp:invest-applet?%s" % id, Gdk.CURRENT_TIME)
diff --git a/invest-applet/invest/invest-applet.py b/invest-applet/invest/invest-applet.py
index da1fb05..9106c27 100755
--- a/invest-applet/invest/invest-applet.py
+++ b/invest-applet/invest/invest-applet.py
@@ -1,9 +1,6 @@
#!/usr/bin/env python
-#
-
-import gobject
-import gtk, gnomeapplet
+from gi.repository import GObject, Gtk, PanelApplet
import getopt, sys
from os.path import *
@@ -19,7 +16,7 @@ else:
sys.path.insert(0, abspath("@PYTHONDIR@"))
# Now the path is set, import our applet
-import invest, invest.applet, invest.defs, invest.help
+import invest, invest.applet, invest.defs, invest.help, invest.networkmanager
# Prepare i18n
import gettext, locale
@@ -30,26 +27,11 @@ locale.textdomain(invest.defs.GETTEXT_PACKAGE)
from gettext import gettext as _
-def applet_factory(applet, iid):
- invest.debug('Starting invest instance: %s %s'% ( applet, iid ))
+def applet_factory(applet, iid, data):
+ invest.debug('Starting invest instance: %s %s %s'% ( applet, iid, data ))
invest.applet.InvestApplet(applet)
return True
-# Return a standalone window that holds the applet
-def build_window():
- app = gtk.Window(gtk.WINDOW_TOPLEVEL)
- app.set_title(_("Invest Applet"))
- app.connect("destroy", gtk.main_quit)
- app.set_property('resizable', False)
-
- applet = gnomeapplet.Applet()
- applet_factory(applet, None)
- applet.reparent(app)
-
- app.show_all()
-
- return app
-
def usage():
print """=== Invest applet: Usage
@@ -58,17 +40,22 @@ $ invest-applet [OPTIONS]
OPTIONS:
-h, --help Print this help notice.
-d, --debug Enable debug output (default=off).
- -w, --window Launch the applet in a standalone window for test purposes (default=no).
+
+For test purposes, you can run the applet as a standalone window by running (e.g.)
+ /usr/libexec/invest-applet -d
+and executing the panel-applet-test application:
+ env panel-test-applets
+Click 'execute'. Make sure no invest applet is currently running in the panel.
+If invest is not installed to the system, instead execute
+ env GNOME_PANEL_APPLETS_DIR=/PATH/TO/INVEST_SOURCES/data panel-test-applets
"""
sys.exit()
if __name__ == "__main__":
- standalone = False
-
try:
opts, args = getopt.getopt(sys.argv[1:], "hdw", ["help", "debug", "window"])
except getopt.GetoptError:
- # Unknown args were passed, we fallback to bahave as if
+ # Unknown args were passed, we fallback to behave as if
# no options were passed
opts = []
args = sys.argv[1:]
@@ -83,16 +70,11 @@ if __name__ == "__main__":
# 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)
- elif o in ("-w", "--window"):
- standalone = True
-
- if standalone:
- build_window()
- gtk.main()
- else:
- gnomeapplet.bonobo_factory(
- "OAFIID:Invest_Applet_Factory",
- gnomeapplet.Applet.__gtype__,
- invest.defs.PACKAGE,
- invest.defs.VERSION,
- applet_factory)
+ invest.debug("Found NetworkManager spec %s (%s)" % (invest.networkmanager.spec, invest.networkmanager.version))
+
+ invest.debug("Starting applet factory, waiting for gnome-panel to connect ...")
+ PanelApplet.Applet.factory_main(
+ "InvestAppletFactory", # id
+ PanelApplet.Applet.__gtype__, # gtype
+ applet_factory, # factory callback
+ None) # factory data pointer
diff --git a/invest-applet/invest/networkmanager.py b/invest-applet/invest/networkmanager.py
index 58a52b2..34700ec 100644
--- a/invest-applet/invest/networkmanager.py
+++ b/invest-applet/invest/networkmanager.py
@@ -10,6 +10,10 @@ STATE_CONNECTING = dbus.UInt32(2)
STATE_CONNECTED = dbus.UInt32(3)
STATE_DISCONNEDTED = dbus.UInt32(4)
+# attributes of the network manager
+version = NETWORKMANAGER_VERSION
+spec = "0.8"
+
# numerical values of these states depend on the network manager version, they changed with 0.8.995
fields = NETWORKMANAGER_VERSION.split('.')
if len(fields) >= 2:
@@ -20,7 +24,7 @@ if len(fields) >= 2:
if major > 0 or major == 0 and (minor >= 9 or len(fields) > 2 and minor == 8 and micro >= 995):
# see http://projects.gnome.org/NetworkManager/developers/ -> spec 0.9 -> NM_STATE
- print("Found NetworkManager spec 0.9 (%s)" % NETWORKMANAGER_VERSION)
+ spec = "0.9"
STATE_UNKNOWN = dbus.UInt32(0)
STATE_ASLEEP = dbus.UInt32(10)
STATE_DISCONNECTED = dbus.UInt32(20)
diff --git a/invest-applet/invest/preferences.py b/invest-applet/invest/preferences.py
index 2485e16..0aadc63 100644
--- a/invest-applet/invest/preferences.py
+++ b/invest-applet/invest/preferences.py
@@ -1,14 +1,14 @@
from gettext import gettext as _
import locale
from os.path import join
-import gtk, gobject, gconf
+from gi.repository import GObject, Gtk, GConf
import invest
import currencies
import cPickle
class PrefsDialog:
def __init__(self, applet):
- self.ui = gtk.Builder()
+ self.ui = Gtk.Builder()
self.ui.add_from_file(join(invest.BUILDER_DATA_DIR, "prefs-dialog.ui"))
self.dialog = self.ui.get_object("preferences")
@@ -29,14 +29,14 @@ class PrefsDialog:
self.typs = (str, str, float, float, float, float)
self.names = (_("Symbol"), _("Label"), _("Amount"), _("Price"), _("Commission"), _("Currency Rate"))
- store = gtk.ListStore(*self.typs)
- store.set_sort_column_id(0, gtk.SORT_ASCENDING)
+ store = Gtk.ListStore(*self.typs)
+ store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
self.treeview.set_model(store)
self.model = store
- completion = gtk.EntryCompletion()
+ completion = Gtk.EntryCompletion()
self.currency.set_completion(completion)
- liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ liststore = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
completion.set_model(liststore)
completion.set_text_column(0)
for code, label in self.currencies.items():
@@ -66,7 +66,7 @@ class PrefsDialog:
exchange = purchase["exchange"]
else:
exchange = 0.0
- store.append([key, label, purchase["amount"], purchase["bought"], purchase["comission"], exchange])
+ store.append([key, label, float(purchase["amount"]), float(purchase["bought"]), float(purchase["comission"]), float(exchange)])
self.sync_ui()
@@ -107,14 +107,14 @@ class PrefsDialog:
return len(text) - text.find(".") - 1
def create_cell (self, view, column, name, typ):
- cell_description = gtk.CellRendererText ()
+ cell_description = Gtk.CellRendererText ()
if typ == float:
cell_description.set_property("xalign", 1.0)
cell_description.set_property("editable", True)
cell_description.connect("edited", self.on_cell_edited, column, typ)
- column_description = gtk.TreeViewColumn (name, cell_description)
+ column_description = Gtk.TreeViewColumn (name, cell_description)
if typ == str:
- column_description.set_attributes (cell_description, text=column)
+ column_description.add_attribute(cell_description, "text", column)
column_description.set_sort_column_id(column)
if typ == float:
column_description.set_cell_data_func(cell_description, self.get_cell_data, (float, column))
@@ -140,7 +140,7 @@ class PrefsDialog:
invest.STOCKS = {}
- def save_symbol(model, path, iter):
+ def save_symbol(model, path, iter, data):
#if int(model[iter][1]) == 0 or float(model[iter][2]) < 0.0001:
# return
@@ -153,7 +153,7 @@ class PrefsDialog:
"comission": float(model[iter][4]),
"exchange": float(model[iter][5])
})
- self.model.foreach(save_symbol)
+ self.model.foreach(save_symbol, None)
try:
cPickle.dump(invest.STOCKS, file(invest.STOCKS_FILE, 'w'))
invest.debug('Stocks written to file')
@@ -173,7 +173,7 @@ class PrefsDialog:
pass
def on_add_stock(self, w):
- iter = self.model.append(["GOOG", "Google Inc.", 0, 0, 0, 0])
+ iter = self.model.append(["GOOG", "Google Inc.", 0.0, 0.0, 0.0, 0.0])
path = self.model.get_path(iter)
self.treeview.set_cursor(path, self.treeview.get_column(0), True)
diff --git a/invest-applet/invest/quotes.py b/invest-applet/invest/quotes.py
index 2b8918f..ed85dcf 100644
--- a/invest-applet/invest/quotes.py
+++ b/invest-applet/invest/quotes.py
@@ -1,5 +1,5 @@
from os.path import join
-import gnomeapplet, gtk, gtk.gdk, gconf, gobject
+from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, GConf, PanelApplet
from gettext import gettext as _
import csv
import locale
@@ -19,16 +19,16 @@ QUOTES_URL="http://finance.yahoo.com/d/quotes.csv?s=%(s)s&f=snc4l1d1t1c1ohgv&e=.
QUOTES_CSV_FIELDS=["ticker", "label", "currency", ("trade", float), "date", "time", ("variation", float), ("open", float), ("high", float), ("low", float), ("volume", int)]
# based on http://www.johnstowers.co.nz/blog/index.php/2007/03/12/threading-and-pygtk/
-class _IdleObject(gobject.GObject):
+class _IdleObject(GObject.Object):
"""
- Override gobject.GObject to always emit signals in the main thread
+ Override gobject.Object to always emit signals in the main thread
by emmitting on an idle handler
"""
def __init__(self):
- gobject.GObject.__init__(self)
+ GObject.Object.__init__(self)
def emit(self, *args):
- gobject.idle_add(gobject.GObject.emit,self,*args)
+ GObject.idle_add(GObject.Object.emit,self,*args)
class QuotesRetriever(Thread, _IdleObject):
"""
@@ -37,7 +37,7 @@ class QuotesRetriever(Thread, _IdleObject):
"""
__gsignals__ = {
"completed": (
- gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, []),
# FIXME: We don't monitor progress, yet ...
#"progress": (
# gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
@@ -51,8 +51,10 @@ class QuotesRetriever(Thread, _IdleObject):
self.retrieved = False
self.data = []
self.currencies = []
+ invest.debug("QuotesRetriever created");
def run(self):
+ invest.debug("QuotesRetriever started");
quotes_url = QUOTES_URL % {"s": self.tickers}
try:
quotes_file = urlopen(quotes_url, proxies = invest.PROXY)
@@ -65,18 +67,18 @@ class QuotesRetriever(Thread, _IdleObject):
self.emit("completed")
-class QuoteUpdater(gtk.ListStore):
+class QuoteUpdater(Gtk.ListStore):
updated = False
last_updated = None
quotes_valid = False
timeout_id = None
SYMBOL, LABEL, CURRENCY, TICKER_ONLY, BALANCE, BALANCE_PCT, VALUE, VARIATION_PCT, PB = range(9)
def __init__ (self, change_icon_callback, set_tooltip_callback):
- gtk.ListStore.__init__ (self, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, bool, float, float, float, float, gtk.gdk.Pixbuf)
+ Gtk.ListStore.__init__ (self, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, bool, float, float, float, float, GdkPixbuf.Pixbuf)
self.set_update_interval(AUTOREFRESH_TIMEOUT)
self.change_icon_callback = change_icon_callback
self.set_tooltip_callback = set_tooltip_callback
- self.set_sort_column_id(1, gtk.SORT_ASCENDING)
+ self.set_sort_column_id(1, Gtk.SortType.ASCENDING)
self.refresh()
# tell the network manager to notify me when network status changes
@@ -85,11 +87,11 @@ class QuoteUpdater(gtk.ListStore):
def set_update_interval(self, interval):
if self.timeout_id != None:
invest.debug("Canceling refresh timer")
- gobject.source_remove(self.timeout_id)
+ 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) )
- self.timeout_id = gobject.timeout_add(interval, self.refresh)
+ 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
@@ -108,12 +110,16 @@ class QuoteUpdater(gtk.ListStore):
return False
if len(invest.STOCKS) == 0:
+ invest.debug("No stocks configured")
return True
tickers = '+'.join(invest.STOCKS.keys())
+ invest.debug("creating QuotesRetriever")
quotes_retriever = QuotesRetriever(tickers)
quotes_retriever.connect("completed", self.on_retriever_completed)
+ invest.debug("starting QuotesRetriever")
quotes_retriever.start()
+ invest.debug("started QuotesRetriever")
return True
@@ -128,12 +134,14 @@ class QuoteUpdater(gtk.ListStore):
def on_retriever_completed(self, retriever):
if retriever.retrieved == False:
+ invest.debug("QuotesRetriever failed");
tooltip = [_('Invest could not connect to Yahoo! Finance')]
if self.last_updated != None:
# Translators: %s is an hour (%H:%M)
tooltip.append(_('Updated at %s') % self.last_updated.strftime("%H:%M"))
self.set_tooltip_callback('\n'.join(tooltip))
else:
+ invest.debug("QuotesRetriever completed");
self.populate(self.parse_yahoo_csv(csv.reader(retriever.data)))
self.updated = True
self.last_updated = datetime.datetime.now()
@@ -275,7 +283,7 @@ class QuoteUpdater(gtk.ListStore):
break
if is_simple_quote:
- row = self.insert(0, [ticker, label, val["currency"], True, 0, 0, val["trade"], val["variation_pct"], pb])
+ row = self.insert(0, [ticker, label, val["currency"], True, 0.0, 0.0, val["trade"], val["variation_pct"], pb])
else:
(balance, change) = self.balance(invest.STOCKS[ticker]["purchases"], val["trade"])
row = self.insert(0, [ticker, label, val["currency"], False, balance, change, val["trade"], val["variation_pct"], pb])
@@ -362,15 +370,15 @@ class QuoteUpdater(gtk.ListStore):
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])
- self.set(iter, self.BALANCE, balance)
- self.set(iter, self.BALANCE_PCT, change)
+ self.set_value(iter, self.BALANCE, balance)
+ self.set_value(iter, self.BALANCE_PCT, change)
self.add_balance_change(balance, change, target_currency)
# now, convert the value
value = self.get_value(iter, self.VALUE)
value *= rates[currency]
- self.set(iter, self.VALUE, value)
- self.set(iter, self.CURRENCY, target_currency)
+ self.set_value(iter, self.VALUE, value)
+ self.set_value(iter, self.CURRENCY, target_currency)
else:
# consider non-converted stocks here
@@ -403,6 +411,3 @@ class QuoteUpdater(gtk.ListStore):
res = False
break
return res
-
-if gtk.pygtk_version < (2,8,0):
- gobject.type_register(QuoteUpdater)
diff --git a/invest-applet/invest/widgets.py b/invest-applet/invest/widgets.py
index 13a2ec9..0442e0f 100644
--- a/invest-applet/invest/widgets.py
+++ b/invest-applet/invest/widgets.py
@@ -1,6 +1,6 @@
import os, time
from os.path import *
-import gnomeapplet, gtk, gtk.gdk, gconf, gobject, pango
+from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, GConf, PanelApplet, Pango
from gettext import gettext as _
import locale
import csv
@@ -35,9 +35,9 @@ MEDIUM = -1
TICKER_TIMEOUT = 10000#3*60*1000#
-class InvestWidget(gtk.TreeView):
+class InvestWidget(Gtk.TreeView):
def __init__(self, quotes_updater):
- gtk.TreeView.__init__(self)
+ Gtk.TreeView.__init__(self)
self.set_property("rules-hint", True)
self.set_reorderable(True)
self.set_hover_selection(True)
@@ -54,10 +54,10 @@ class InvestWidget(gtk.TreeView):
self._getcelldata_balancepct]
for i, col_name in enumerate(col_names):
if i < 3:
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
if i > 0:
cell.set_property("xalign", 1.0)
- column = gtk.TreeViewColumn (col_name, cell)
+ column = Gtk.TreeViewColumn (col_name, cell)
if i == 0:
column.set_sort_column_id(quotes_updater.LABEL)
elif i == 2:
@@ -65,15 +65,15 @@ class InvestWidget(gtk.TreeView):
column.set_cell_data_func(cell, col_cellgetdata_functions[i])
self.append_column(column)
elif i == 3:
- cell_pb = gtk.CellRendererPixbuf()
- column = gtk.TreeViewColumn (col_name, cell_pb, pixbuf=quotes_updater.PB)
+ cell_pb = Gtk.CellRendererPixbuf()
+ column = Gtk.TreeViewColumn (col_name, cell_pb, pixbuf=quotes_updater.PB)
self.append_column(column)
else:
# add the last two column only if we have any positions
if simple_quotes_only == False:
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
cell.set_property("xalign", 1.0)
- column = gtk.TreeViewColumn (col_name, cell)
+ column = Gtk.TreeViewColumn (col_name, cell)
if i == 4:
column.set_sort_column_id(quotes_updater.BALANCE)
elif i == 5:
@@ -101,10 +101,10 @@ class InvestWidget(gtk.TreeView):
return locale.format("%+.2f", value, True, True) + " " + currency
- def _getcelldata_label(self, column, cell, model, iter):
+ def _getcelldata_label(self, column, cell, model, iter, userdata):
cell.set_property('text', model[iter][model.LABEL])
- def _getcelldata_value(self, column, cell, model, iter):
+ def _getcelldata_value(self, column, cell, model, iter, userdata):
cell.set_property('text', self.format_currency(model[iter][model.VALUE], model[iter][model.CURRENCY]))
def is_selected(self, model, iter):
@@ -120,14 +120,14 @@ class InvestWidget(gtk.TreeView):
intensity = LIGHT
return palette[intensity]
- def _getcelldata_variation(self, column, cell, model, iter):
+ def _getcelldata_variation(self, column, cell, model, iter, userdata):
color = self.get_color(model, iter, model.VARIATION_PCT)
change_pct = self.format_percent(model[iter][model.VARIATION_PCT])
cell.set_property('markup',
"<span foreground='%s'>%s</span>" %
(color, change_pct))
- def _getcelldata_balance(self, column, cell, model, iter):
+ def _getcelldata_balance(self, column, cell, model, iter, userdata):
is_ticker_only = model[iter][model.TICKER_ONLY]
color = self.get_color(model, iter, model.BALANCE)
if is_ticker_only:
@@ -138,7 +138,7 @@ class InvestWidget(gtk.TreeView):
"<span foreground='%s'>%s</span>" %
(color, balance))
- def _getcelldata_balancepct(self, column, cell, model, iter):
+ def _getcelldata_balancepct(self, column, cell, model, iter, userdata):
is_ticker_only = model[iter][model.TICKER_ONLY]
color = self.get_color(model, iter, model.BALANCE_PCT)
if is_ticker_only:
@@ -156,12 +156,12 @@ class InvestWidget(gtk.TreeView):
invest.chart.show_chart([ticker])
-#class InvestTicker(gtk.Label):
+#class InvestTicker(Gtk.Label):
# def __init__(self):
-# gtk.Label.__init__(self, _("Waiting..."))
+# Gtk.Label.__init__(self, _("Waiting..."))
#
# self.quotes = []
-# gobject.timeout_add(TICKER_TIMEOUT, self.scroll_quotes)
+# GObject.timeout_add(TICKER_TIMEOUT, self.scroll_quotes)
#
# get_quotes_updater().connect('quotes-updated', self.on_quotes_update)
#
@@ -190,9 +190,9 @@ class InvestWidget(gtk.TreeView):
#
#gobject.type_register(InvestTicker)
-class InvestTrend(gtk.Image):
+class InvestTrend(Gtk.Image):
def __init__(self):
- gtk.Image.__init__(self)
+ Gtk.Image.__init__(self)
self.pixbuf = None
self.previous_allocation = (0,0)
self.connect('size-allocate', self.on_size_allocate)
@@ -202,14 +202,14 @@ class InvestTrend(gtk.Image):
if self.previous_allocation == (allocation.width, allocation.height):
return
- self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, allocation.height, allocation.height)
+ self.pixbuf = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, True, 8, allocation.height, allocation.height)
self.set_color("grey")
self.previous_allocation = (allocation.width, allocation.height)
def set_color(self, color, opacity=0xFF):
if self.pixbuf != None:
try:
- color = pango.Color(color)
+ color = Pango.Color(color)
factor = float(0xFF)/0xFFFF
self.pixbuf.fill(
int(color.red*factor)<<24|int(color.green*factor)<<16|int(color.blue*factor)<<8|opacity)
@@ -247,4 +247,4 @@ class InvestTrend(gtk.Image):
self.set_color(color, opacity)
-gobject.type_register(InvestTrend)
+GObject.type_register(InvestTrend)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 28969be..3575328 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,8 +41,7 @@ gweather/gweather-dialog.c
gweather/gweather-pref.c
gweather/main.c
[type: gettext/ini]gweather/org.gnome.applets.GWeatherApplet.panel-applet.in.in
-invest-applet/data/Invest_Applet.server.in.in
-invest-applet/data/Invest_Applet.xml
+[type: gettext/ini]invest-applet/data/org.gnome.applets.InvestApplet.panel-applet.in.in
[type: gettext/glade]invest-applet/data/financialchart.ui
[type: gettext/glade]invest-applet/data/prefs-dialog.ui
invest-applet/invest/about.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]