Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Transparent Python Home applet for n900

    Reply
    daperl | # 1 | 2010-01-28, 06:50 | Report

    Name:  Screenshot-20100127-222641.jpg
Views: 1764
Size:  22.7 KB

    Here's the code (/usr/lib/hildon-desktop/hw_home_applet_c.py):

    Code:
    #! /usr/bin/env python
    
    from math import pi
    import cairo
    import gtk
    import hildondesktop
    
    class hw_home_applet_c(hildondesktop.HomePluginItem):
        '''
        __gsignals__ = {
            'realize' : 'override',
            'expose-event' : 'override',
            }
        '''
        def __init__(s):
            hildondesktop.HomePluginItem.__init__(s)
            pb = gtk.gdk.pixbuf_new_from_file('/home/user/src/demos/images/gnome-gimp.png')
            i = gtk.Image()
            s.set_size_request(90,90)
            i.set_from_pixbuf(pb)
            i.show_all()
            s.add(i)
    
        def do_expose_event(s, e):
            a = e.area
            cr = s.window.cairo_create()
            cr.arc(a.width/2,a.height/2,a.width/2,0,2*pi)
            cr.set_source_rgba(1.0,0.0,0.0,0.625)
            cr.fill()
            hildondesktop.HomePluginItem.do_expose_event(s,e)
    
        def do_realize(s):
            scn = s.get_screen()
            cm = scn.get_rgba_colormap()
            s.set_colormap(scn.get_rgba_colormap())
            s.set_app_paintable(True)
            hildondesktop.HomePluginItem.do_realize(s)
    
    hd_plugin_type = hw_home_applet_c
    
    if __name__ == '__main__':
        import gobject
        gobject.type_register(hd_plugin_type)
        obj = gobject.new(hd_plugin_type, plugin_id='plugin_id')
        obj.show_all()
        gtk.main()
    Here's the desktop file (/usr/share/applications/hildon-home/hw_home_applet_c.desktop):

    Code:
    [Desktop Entry]
    Name=hw_home_applet_c
    Comment=Description of the Hello World Home Applet c
    Type=python
    X-Path=hw_home_applet_c.py
    But you're gonna have to BYOIP (Bring Your Own Image Path).

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 7 Users Say Thank You to daperl For This Useful Post:
    andrei1089, codeMonkey, danielwilms, Helmuth, iKneaDough, mccarmo, noobmonkey

     
    daperl | # 2 | 2010-01-28, 06:59 | Report

    Oh, and don't forget to do this if you haven't already done so:

    Code:
    apt-get install python-hildondesktop hildon-desktop-python-loader
    Further information can be found here and here.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    lizardo | # 3 | 2010-01-29, 15:42 | Report

    Originally Posted by daperl View Post
    Oh, and don't forget to do this if you haven't already done so:

    Code:
    apt-get install python-hildondesktop hildon-desktop-python-loader
    You forgot to mention "python-cairo" above

    Also see these two links:
    • http://lists.maemo.org/pipermail/mae...er/023206.html
    • http://lists.maemo.org/pipermail/mae...er/023207.html

    For important notes when mixing python-hildondesktop and python-cairo.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to lizardo For This Useful Post:
    daperl

     
    mu_mind | # 4 | 2010-05-04, 16:12 | Report

    I've just uploaded a project to http://gitorious.org/python-hildonhomepluginitem to ease creating semi-transparent home applets. It won't do everything yet, but I intend it to be built up it into a base for most common styles of home applets, and make the level of transparency and most of the other styling optional/selectable.

    Please consider updating it to support what you want if you need a transparent applet, or file a bug for what knobs you'd like to see on it.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 5 Users Say Thank You to mu_mind For This Useful Post:
    daperl, erniadeldesktop, iKneaDough, mikec, noobmonkey

     
vBulletin® Version 3.8.8
Normal Logout