Well, I don't really care about investing, but this seemed like a python
example for an applet which I wanted to study - so after some fiddling
around, I finally got (at least) the `/usr/lib/gnome-applets/invest-
applet -d --window` to show an icon and preference window. (goddamn
capitalists, using my labor, hehe :) ) Here's a pic:

http://sdaaubckp.sourceforge.net/post/gnome/invest-applet-natty.png


The thing is - I basically went along with errors I saw, and tried to modify 
them. First of, I got a working Python applet example from here: 
http://www.znasibov.info/blog/post/gnome-applet-with-python-part-1.html
... and changed `PanelApplet.Applet()` into `gnomeapplet.Applet()`; apart from 
that, there are modifications going from `Gtk.` to `gtk.` (e.g. `app = 
Gtk.Window(Gtk.WindowType.TOPLEVEL)` -> `app = gtk.Window()`). 

Then, I found this, where it seems that someone already tried to patch
`invest-applet` for natty:

https://code.launchpad.net/~rodrigo-moya/ubuntu/natty/gnome-applets/no-
more-deprecated/+merge/41494

.... but seemingly, I had _reverted_ some of those changes - to get it
working again with my 11.04 Natty?

I'm not sure if this is  due to different gtk bindings for different
Pythons; I think I may have seen somewhere, that `Gtk` is for Python 3 -
however, that makes the above `no-more-deprecated` posting a little
weird, because the default Python in Natty is 2.7 ???!

Therefore - the patch is *really* nasty, as it mixes `gi.repository` and
`gtk` imports - but it's basically a "proof of concept", I guess... Also
- I just tried to add this patched version to panel; again there is no
icon visible on panel (that could be due to me not converting every
single pixbuf call; see patch) - however, one positive thing is that
after that attempt, while `ps axf | grep invest` does still show the
process in the background, it takes only a single `kill $pid` in order
to get it removed (so no single user mode mess like in previous post).
With the original version, even the standalone debug couldn't be killed
with Ctrl-C (I had to do a `ps axf` and `kill $pid` in another terminal,
to stop the process).

I didn't try fixing anything beyond the starting icon in standalone
debug mode, and the preferences window which is raised upon click of
that icon (as shown in screenshot). Still, hope this will be helpful to
others...


PS: I'll dump a few dev notes (obtained during patch development) here
as well:

invest-applet works w/
from gi.repository import GObject, Gtk, PanelApplet

others: import gnomeapplet

$ activation-client -q -s "iid.defined()" | grep ^IID | grep -i invest
IID OAFIID:Invest_Applet_Factory, type exe, location 
/usr/lib/gnome-applets/invest-applet
IID OAFIID:Invest_Applet, type factory, location OAFIID:Invest_Applet_Factory
IID OAFIID:GNOME_GtikApplet, type factory, location OAFIID:Invest_Applet_Factory

$ find / -xdev -name '*invest*' 2>/dev/null | grep py
/usr/lib/pymodules/python2.7/invest
/usr/share/pyshared/invest

$ ls -la /usr/lib/pymodules/python2.7/invest
total 96
drwxr-xr-x  2 root root  4096 2011-04-25 20:57 .
drwxr-xr-x 66 root root  4096 2013-03-26 17:39 ..
lrwxrwxrwx  1 root root    35 2011-04-25 20:57 about.py -> 
/usr/share/pyshared/invest/about.py
-rw-r--r--  1 root root  1568 2011-04-25 20:57 about.pyc
lrwxrwxrwx  1 root root    36 2011-04-25 20:57 applet.py -> 
/usr/share/pyshared/invest/applet.py
-rw-r--r--  1 root root  7052 2011-04-25 20:57 applet.pyc
lrwxrwxrwx  1 root root    35 2011-04-25 20:57 chart.py -> 
/usr/share/pyshared/invest/chart.py
-rw-r--r--  1 root root  8066 2011-04-25 20:57 chart.pyc
lrwxrwxrwx  1 root root    40 2011-04-25 20:57 currencies.py -> 
/usr/share/pyshared/invest/currencies.py
-rw-r--r--  1 root root  5548 2011-04-25 20:57 currencies.pyc
lrwxrwxrwx  1 root root    34 2011-04-25 20:57 defs.py -> 
/usr/share/pyshared/invest/defs.py
-rw-r--r--  1 root root   486 2011-04-25 20:57 defs.pyc
lrwxrwxrwx  1 root root    34 2011-04-25 20:57 help.py -> 
/usr/share/pyshared/invest/help.py
-rw-r--r--  1 root root   676 2011-04-25 20:57 help.pyc
lrwxrwxrwx  1 root root    38 2011-04-25 20:57 __init__.py -> 
/usr/share/pyshared/invest/__init__.py
-rw-r--r--  1 root root  5205 2011-04-25 20:57 __init__.pyc
lrwxrwxrwx  1 root root    44 2011-04-25 20:57 networkmanager.py -> 
/usr/share/pyshared/invest/networkmanager.py
-rw-r--r--  1 root root  2463 2011-04-25 20:57 networkmanager.pyc
lrwxrwxrwx  1 root root    41 2011-04-25 20:57 preferences.py -> 
/usr/share/pyshared/invest/preferences.py
-rw-r--r--  1 root root 10982 2011-04-25 20:57 preferences.pyc
lrwxrwxrwx  1 root root    36 2011-04-25 20:57 quotes.py -> 
/usr/share/pyshared/invest/quotes.py
-rw-r--r--  1 root root 12786 2011-04-25 20:57 quotes.pyc
lrwxrwxrwx  1 root root    37 2011-04-25 20:57 widgets.py -> 
/usr/share/pyshared/invest/widgets.py
-rw-r--r--  1 root root  8547 2011-04-25 20:57 widgets.pyc

# so in /usr/share/pyshared/invest/

$ grep -r PanelApplet /usr/share/pyshared/invest
/usr/share/pyshared/invest/widgets.py:from gi.repository import PanelApplet, 
Gtk, Gdk, GConf, GObject, Pango
/usr/share/pyshared/invest/applet.py:from gi.repository import Gdk, GdkPixbuf, 
Gtk, PanelApplet, GObject, GConf
/usr/share/pyshared/invest/applet.py:class InvestApplet(PanelApplet.Applet):
/usr/share/pyshared/invest/applet.py:           if self.alignment == 
PanelApplet.ORIENT_LEFT:
/usr/share/pyshared/invest/quotes.py:from gi.repository import PanelApplet, 
Gtk, Gdk, GConf, GObject

# changed in applet.py: class InvestApplet(gnome.applet.Applet): 
#(PanelApplet.Applet):
now in
$ /usr/lib/gnome-applets/invest-applet -d --window
  ...
  File "/usr/lib/python2.7/dist-packages/gi/overrides/__init__.py", line 38, in 
register
    self[override_class] = override_class
  File "/usr/lib/python2.7/dist-packages/gi/overrides/__init__.py", line 20, in 
__setitem__
    info = getattr(value, '__info__')
AttributeError: type object 'FontDescription' has no attribute '__info__'

# the pasted imports have to be after the old ones; then FontDescription 
disappears,
# and now:

$ /usr/lib/gnome-applets/invest-applet -d --window
Traceback (most recent call last):
  File "/usr/lib/gnome-applets/invest-applet", line 5, in <module>
    from invest.applet import InvestApplet
  File "/usr/lib/pymodules/python2.7/invest/applet.py", line 18, in <module>
    class InvestApplet(gnome.applet.Applet): #(PanelApplet.Applet):
NameError: name 'gnome' is not defined

gnome-python-desktop-2.32.0/gnomeapplet/applet.defs:
(define-object Applet
  (in-module "Panel")
  (parent "GtkEventBox")
  (c-name "PanelApplet")
  (gtype-id "PANEL_TYPE_APPLET")

# save original version for diffing: 
sudo cp /usr/lib/gnome-applets/invest-applet 
/usr/lib/gnome-applets/invest-applet.orig
sudo cp /usr/share/pyshared/invest/applet.py 
/usr/share/pyshared/invest/applet.py,orig
sudo cp /usr/share/pyshared/invest/quotes.py 
/usr/share/pyshared/invest/quotes.py.orig
sudo cp /usr/share/pyshared/invest/widgets.py 
/usr/share/pyshared/invest/widgets.py.orig
sudo cp /usr/share/pyshared/invest/preferences.py 
/usr/share/pyshared/invest/preferences.py.orig


** Patch added: "partial patch, to get `/usr/lib/gnome-applets/invest-applet -d 
--window` to show an icon and prefs window under Natty only (rest is not fixed)"
   
https://bugs.launchpad.net/ubuntu/+source/gnome-applets/+bug/775387/+attachment/3602279/+files/investapplet-natty.patch

-- 
You received this bug notification because you are a member of Ubuntu
Desktop Bugs, which is subscribed to gnome-applets in Ubuntu.
https://bugs.launchpad.net/bugs/775387

Title:
  Invest-applet fails to start after upgrade to Natty

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnome-applets/+bug/775387/+subscriptions

-- 
desktop-bugs mailing list
desktop-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/desktop-bugs

Reply via email to