Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking at writing a simple app indicator and I need it to update it's information whenever it's clicked on to open the menu. Is there any kind of on_click action thing?

Let me rephrase it then: How to perform an action (any action) when the user clicks on the appindicator to open its menu?

share|improve this question
up vote 3 down vote accepted

An app indicator can only open its menu. It can't perform any other action and your program doesn't get notified when the menu is displayed.

You could either include some kind of "Update" menu item or find other events that trigger the update.

share|improve this answer
    
Thanks, I was afraid that might be it. I'll look into other events that might trigger this instead. – DoGoDo Dec 2 '12 at 20:37
    
@DoGoDo, have you found any solution? – JellicleCat May 17 '15 at 19:02
    
So there is no click event emitted? That just seems odd. – Elijah Lynn Jan 28 at 12:25

Indeed, you may notice that some indicators (like volume or keyboard language ones) support middle mouse click. It can be done with set_secondary_activate_target(menu_item). My code snippet for pyGtk/pyGI:

    menu_items = Gtk.MenuItem("Toggle Floater")
    menu.append(menu_items)
    menu_items.connect("activate", self.toggleWindow)
    self.ind.set_secondary_activate_target(menu_items)

I found it here, but it's not described, I just tried it on chance, and it worked.

share|improve this answer

I have used the middle mouse click on one of my indicators to perform an action, so I think you could do the same...see related [answer[(http://askubuntu.com/a/501050/67335). Note it only seems to work on Ubuntu (not Lubuntu/Xubuntu).

share|improve this answer

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.