Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Putting any gtk.Widget inside a gtk.Menu works, somewhat, by putting an empty gtk.MenuItem in first. It doesn't seem to be reliable - but it basically works. With an appindicator.Indicator, it doesn't work. The entry just stays empty. Even if you set the child[border_size] to 32, for example.

The only widget that works is a gtk.Label (plus the MenuItem, ImageMenuItem and so on of course).

Now the Me Menu has got a gtk.Entry in it, so it must surely be possible to do this Properly. How do I do it?

Here's some example code to explain what I'm on about:

    self.item = gtk.MenuItem()
    self.item.add(gtk.Label("hello world!"))
    self.menu.append(self.item)

The above code works, this however doesn't:

    self.item = gtk.MenuItem()
    self.item.add(gtk.Entry())
    self.menu.append(self.item)

Where self.menu is an appindicator.Indicator, if it were a gtk.Menu, the Entry would be at least displayed.

Here's some working code:

import gtk
import appindicator

class AppIndicator (object):

    def __init__(self):
        self.ind = appindicator.Indicator("hello world client",
            "distributor-logo", appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status (appindicator.STATUS_ACTIVE)
        self.menu = gtk.Menu()
        item = gtk.MenuItem()

        item.add(gtk.Label("hello world"))
        # item.add(gtk.Entry())

        self.menu.append(item)
        self.menu.show_all()
        self.ind.set_menu(self.menu)


indicator = AppIndicator()
gtk.main()
share|improve this question
    
As @MarcoCeppi reminded me, yes - this isn't supposed to work. I'm just hoping and dreaming, maybe it can. Since the Me Menu does something seemingly similar. –  Stefano Palazzo Dec 6 '10 at 14:47
1  
I'm pretty sure that the Me Menu makes use of libido (Indicator Display Objects) to do that. See: launchpad.net/ido In particular, idoentrymenuitem.c (bazaar.launchpad.net/~canonical-dx-team/ido/trunk/annotate/…). Unfortunately, I don't think there are python bindings. You might want to ask on the ayatana-dev email list. –  andrewsomething Dec 21 '10 at 16:22
    
Did you find out how to do this? I am facing the same problem. Thanks. –  Benjamin Oct 6 '13 at 16:22
add comment

1 Answer 1

up vote 6 down vote accepted

The Application Indicator menu support is based on D-Bus menus, which are limited in what they support - they only support basic menu functionality, not more exotic things such as arbitrary widgets.

One significant roadblock to them ever supporting such things is the fact that the application indicator menu is rendered by a different process, the application indicator process, so your program doesn't have access to directly draw anything on it. Overcoming this would require either supporting something like X-Embed in D-Bus menus or allowing all of GTK to work over D-Bus.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.