Notices


Reply
Thread Tools
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,809 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#61
I've started using the battery applet and my new wlan applet in my Mer replacement desktop. Come over here to see the screenshots.

daperl, I would like to know how to make a dropdown menu appear from an applet icon, similar to the one that appears when you click the Home icon. I am thinking of making a list of applications in a text file, with two "fields" per line, something like:

label 1, command 1
label 2, command 2

Then I could use the CSV reading module to read in the values and build the menu from that...

I want an applet to replace the hideous menu that I'm using.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#62
Originally Posted by qole View Post
daperl, I would like to know how to make a dropdown menu appear from an applet icon, similar to the one that appears when you click the Home icon. I am thinking of making a list of applications in a text file, with two "fields" per line, something like:
I've solved qwerty12's tap-and-hold problem on a gtk.StatusIcon and I'm writing a standalone demo program. After it's working in Diablo I will verify that it works in Easy Debian. If all is good there, it should also work in Mer.

Regardless if you're looking for tap-and-hold functionality, this code will be easy to tailor to your needs.
__________________
N9: Go white or go home
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,809 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#63
daperl: So I've decided to jettison all sandbags and teach myself python.

I've stolen code from everywhere (including dbus-switchboard) and I've got my dropdown menu working!

I should have something to show very soon.

EDIT: Screenshot

__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!

Last edited by qole; 2009-04-15 at 07:08.
 

The Following User Says Thank You to qole For This Useful Post:
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#64
Originally Posted by qole View Post
daperl: So I've decided to ... teach myself python.

I've stolen code from everywhere (including dbus-switchboard) and I've got my dropdown menu working!
My opinion is that you've made the perfect decision for yourself. The menu looks good. You might think about catagorizing and creating submenus to keep the main menu from scrolling. Also, the gtk.ImageMenuItem in PyGTK wasn't ported correctly. I can send you some code later this week to add non-stock icons w/ labels to your menus. Again, way to bite the bullet; there will be no stopping you.
__________________
N9: Go white or go home
 

The Following User Says Thank You to daperl For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,809 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#65
daperl: Oh I would very much like to get non-stock icons in there.

I think the next step would be to figure out how to run .desktop files. Is there a command line that takes a .desktop file as a parameter and then executes the .desktop file?

And yes, nested menus are the logical continuation of this project. If I do a good enough job here, this could be useful in many places: it is a generic GTK python app that puts a menu in the system tray which can run arbitrary commands... I can see a few uses for that beyond my chroot-busting use-case.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#66
Originally Posted by qole View Post
daperl: Oh I would very much like to get non-stock icons in there.
I further hacked on the qwerty12 demo to show the only way I know how to get around the gtk.ImageMenuItem deficiencies. As for proper ways to find applications, icons and .desktop files, you know as much as I do. If you wanted to hack, the .desktop files can be parsed with the ConfigParser module.

Code:
#! /usr/bin/env python

import gobject
import gtk

class QoleImageMenuItem(gtk.ImageMenuItem):
    def __init__(self, widget):
        gtk.ImageMenuItem.__init__(self)
        self.add(widget)

class qole():
    tah_timeout = 1000
    icon_dir = '/usr/share/icons/hicolor/26x26/'
    app_icons = [\
        ('Mplayer', 'apps', 'mplayer.png'),\
        ('Terminal', 'hildon', 'qgn_list_xterm.png'),\
        ('Browser', 'hildon', 'qgn_list_browser.png'),\
        ('Chess', 'hildon', 'qgn_list_chess.png'),\
        ('File Manager', 'hildon', 'qgn_list_filemanager.png'),\
        ('Mahjong', 'hildon', 'qgn_list_mahjong.png')\
        ]

    def __init__(self):
        self.screen = None
        self.root_win = None
        self.rec = None
        self.mapped = False
        self.is_icon_on_top = True
        self.press_event = None
        self.last_tah_press_num = -1
        self.press_num = 0
        self.pressing = False
        gtk.gdk.event_handler_set(self.on_any_event)
        self.i = 5
        self.statusIcon = gtk.StatusIcon()
        self.statusIcon.set_from_stock(gtk.STOCK_CONNECT)
        self.clicked_menu = gtk.Menu()
        self.clicked_menu.__dict__['mapped'] = False
        self.clicked_menu.connect('map-event', self.on_map_menu, True)
        self.clicked_menu.connect('unmap-event', self.on_map_menu, False)
        self.clicked_menu.append(gtk.MenuItem('Clicked 1'))
        self.clicked_menu.append(gtk.MenuItem('Clicked 2'))
        self.clicked_menu.append(gtk.MenuItem('Clicked 3'))
        for t in self.app_icons:
            try:
                lbl = gtk.Label(t[0])
                lbl.set_alignment(0.0, 0.5)
                imi = QoleImageMenuItem(lbl)
                path = self.icon_dir + t[1] + '/' + t[2]
                try:
                    pb = gtk.gdk.pixbuf_new_from_file_at_size (path, 26, 26)
                    img = gtk.image_new_from_pixbuf(pb)
                except:
                    img = gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_MENU)
                imi.set_image(img)
                self.clicked_menu.append(imi)
            except Exception, e: print e
        i = 1
        for c in self.clicked_menu.get_children():
            c.connect('activate', self.on_activate_mi, 'clicked '+str(i))
            c.connect('enter-notify-event', self.on_enter_mi, 'clicked '+str(i))
            i += 1
        self.clicked_menu.show_all()
        gtk.status_icon_position_menu(self.clicked_menu, self.statusIcon)
        self.tah_menu = gtk.Menu()
        self.tah_menu.__dict__['mapped'] = False
        self.tah_menu.connect('map-event', self.on_map_menu, True)
        self.tah_menu.connect('unmap-event', self.on_map_menu, False)
        self.tah_menu.append(gtk.MenuItem('TAH 1'))
        self.tah_menu.append(gtk.MenuItem('TAH 2'))
        self.tah_menu.append(gtk.MenuItem('TAH 3'))
        self.tah_menu.append(gtk.MenuItem('TAH 4'))
        self.tah_menu.append(gtk.MenuItem('TAH 5'))
        self.tah_menu.append(gtk.MenuItem('TAH 6'))
        self.tah_menu.append(gtk.MenuItem('TAH 7'))
        i = 1
        for c in self.tah_menu.get_children():
            c.connect('activate', self.on_activate_mi, 'tah '+str(i))
            c.connect('enter-notify-event', self.on_enter_mi, 'tah '+str(i))
            i += 1
        self.tah_menu.show_all()
        gtk.status_icon_position_menu(self.tah_menu, self.statusIcon)

    def on_activate_mi(self, mi, t):
        print 'activate mi',t,mi.get_name()
    def on_enter_mi(self, mi, event, t):
        #print 'enter mi',t
        p = mi.get_parent()
        p.deselect()
        p.select_item(mi)
    def on_map_menu(self, m, event, b):
        #print 'map menu before after',m.mapped,b
        m.mapped = b
    def tap_and_hold(self, event, tah_press_num):
        print 'num self.press_num',tah_press_num,self.press_num
        if self.pressing and tah_press_num == self.press_num:
            rec = self.rec
            x, y, m = self.root_win.get_pointer()
            print 'tah x y w h',x,y,rec.x,rec.y,rec.width,rec.height
            self.last_tah_press_num = tah_press_num
            self.clicked_menu.popdown()
            #self.tah_menu.popup(None,None,gtk.status_icon_position_menu,1,gtk.get_current_event_time(),self.statusIcon)
            self.tah_menu.popup(None,None,gtk.status_icon_position_menu,1,event.time+self.tah_timeout,self.statusIcon)
        return False

    def is_icon_event(self):
        #x, y, m = self.root_win.get_pointer()
        self.screen, self.rec, o = self.statusIcon.get_geometry()
        x, y, m = self.screen.get_root_window().get_pointer()
        dx = x - self.rec.x
        dy = y - self.rec.y
        return dx >=0 and dx <= self.rec.width and dy >= 0 and dy <= self.rec.height

    def set_menu_pos(self, menu):
        mw, mh = menu.get_toplevel().get_size()
        x = 0
        y = 0
        if self.is_icon_on_top:
            pass
        else:
            #x = self.rec.x + self.rec.width - mw
            x = self.rec.x - mw
            y = self.rec.y - mh - 10
        print 'clicked menu x y',x,y,mw,mh
        return (x, y, False)

    def on_any_event(self, event):
        if event.type == gtk.gdk.MOTION_NOTIFY: return
        #print 'event',event.type
        if event.type == gtk.gdk.BUTTON_PRESS:
            if self.mapped and event.button == 1 and self.is_icon_event():
                self.press_event = event.copy()
                self.pressing = True
                self.press_num += 1
                gobject.timeout_add(self.tah_timeout, self.tap_and_hold, event, self.press_num)
            #print 'press',event.x,event.y,event.button
        elif event.type == gtk.gdk.BUTTON_RELEASE:
            self.pressing = False
            #print 'button release num last_num',self.press_num,self.last_tah_press_num
            #print 'release tma visible',self.tah_menu.props.visible
            if event.button == 1 and self.is_icon_event() and\
            self.press_num != self.last_tah_press_num and not self.tah_menu.mapped:
                if self.clicked_menu.mapped:
                    self.clicked_menu.popdown()
                else:
                    #self.clicked_menu.popup(None,None,self.set_menu_pos,1,event.time)
                    self.clicked_menu.popup(None,None,gtk.status_icon_position_menu,1,event.time,self.statusIcon)
                #print 'time for clicked menu'
        elif event.type == gtk.gdk.LEAVE_NOTIFY:
            self.pressing = False
        elif event.type == gtk.gdk.MAP:
            if not self.mapped:
                self.screen, rec, o = self.statusIcon.get_geometry()
                self.root_win = self.screen.get_root_window()
                print 'rec',rec.x,rec.y,rec.width,rec.height
                self.rec = rec
                self.mapped = True
                self.is_icon_on_top = rec.y < rec.height
        gtk.main_do_event(event)

if __name__ == "__main__":
    q = qole()
    gtk.main()
__________________
N9: Go white or go home
 

The Following User Says Thank You to daperl For This Useful Post:
Posts: 183 | Thanked: 18 times | Joined on Jul 2009 @ italy
#67
hi qole, is there any upgrade for the lxde replacement??? I've discovered it few hours ago, but Trying it is very funny and I like t alot;
is there any progress about the battery icon, the maemo menu and the problems about sound and microphone???

thx

EDIT: can you link me a guide to have sounds working please??? because I cannot have the working from debian (the ones from maemo works well)

EDIT2: any way to stop the script to stop the media service????

Last edited by pinguino89; 2009-12-23 at 17:14.
 
Posts: 183 | Thanked: 18 times | Joined on Jul 2009 @ italy
#68
cannot help me?

when I plug the headsets, they are not recgnized under LXDE!!!!

the sistems goes via speaker as if I've never plugged the headsets!!!

or better, If I start lxde with eadsets plugged, the system remains "Plugged" evenif I unplug them (so speakers does not work) and the viceversa, If i start without, the eadsets will not work!!!
help!!!!

Last edited by pinguino89; 2009-12-24 at 00:14.
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,809 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#69
pinguino89: Try the gnome-alsa-mixer and try changing the checkboxes in the bottom area.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
Posts: 6 | Thanked: 0 times | Joined on Feb 2010
#70
Hi Qole,
thank you for easy-Debian project, i install it on my n810 - very happy .
can i ask a few questions?
1. when i update system(from oficial squeeze repo's), it's broke correctly boot on LXDE from launcher, i try in console:
$sudo hostwin LXDE
....
Error: Osso initialize failed.
$
cant goole and solve it,
but in chroot console "startlxde" launch LXDE panel side-by-side original maemo panel, and eat 100% cpu while i launch pcmanfm manually, then cpu is down o normal.
how to fix it "Osso initialize failed." ?

2. i want extract my system on partition from debian-img.ext2 (resize internal disc on 256vfat/1400ext/2xxlinswap) to speed boot up, did you have modified launch scripts? or some link what's/how do it?
sorry for bad english.
thank you.

Last edited by S_Paul; 2010-02-10 at 18:38.
 
Reply

Tags
chroot, debian, easy debian, lxde, replacement

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:23.