# Panel Applet Menu

**URL:** <https://www.ruby-forum.com/t/panel-applet-menu/54427>\
**Category:** Ruby-Gnome 2\
**Created:** [March 4, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427 "2006-03-04T13:40:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 4, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/1 "2006-03-04T13:40:13Z")

</div>

Hi all!

I have developed a panel applet, and it seems to work fine, but I am  
missing the popup menu when I right-click on the menu.

I do get the following warning after a while:

(simple\_applet.rb:4227): Bonobo-WARNING \*\*: Never got frame, control  
died - abnormal exit condition

What do I have to do to get the popup-menu working?

I there a tutorial for the panel applet? …or a sample panel applet?

Any help is greatly appreciated.

My code follows:

class SimpleApplet  
def initialize(applet, iid)  
@applet = applet  
@iid = iid

```
@label = Gtk::Label.new("Hello World")
@button = Gtk::Button.new
@button.relief = Gtk::RELIEF_NONE
@button.add(@label)
@applet.add(@button)
@applet.show_all

@button.signal_connect("clicked") do |w|
  Thread.start do
    do_stuff
  end
end

Thread.start do
  do_stuff
end

```

end

private  
def do\_stuff  
@label.label = “Working”  
# lots of nifty business logic here  
@label.label = “Done”  
end

end

init = proc do |applet, iid|  
SimpleApplet.new(applet, iid)  
true  
end

oafiid = OAFIID  
run\_in\_window = (ARGV.length == 1 && ARGV.first == “run-in-window”)  
oafiid += “\_debug” if run\_in\_window

PanelApplet.main(oafiid, “Simple Applet (Ruby-GNOME2)”, “0”, &init)

if run\_in\_window  
main\_window = Gtk::Window.new  
main\_window.set\_title “Simple Applet”  
main\_window.signal\_connect(“destroy”) { Gtk::main\_quit }  
app = PanelApplet.new  
init.call(app, oafiid)  
app.reparent(main\_window)  
main\_window.show\_all  
puts “Main Window”; STDOUT.flush  
Gtk::main  
puts “Finished Window”; STDOUT.flush  
end

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 4, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/2 "2006-03-04T14:37:33Z")

</div>

Am Samstag, den 04.03.2006, 13:39 +0100 schrieb Uwe K.:

> Hi all!
> 
> I have developed a panel applet, and it seems to work fine, but I am  
> missing the popup menu when I right-click on the menu.

Hi,

i’ve never made applets in ruby, only in C but i think your problem is  
the button, that fills the applet and which grabs the button-press  
events.

Try it only with the label and see if the menu then opens.

HTH  
detlef

> ```
> @button.add(@label)
> @applet.add(@button)
> 
> ```

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 5, 2006, 10:50pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/3 "2006-03-05T22:50:17Z")

</div>

Am Samstag, den 04.03.2006, 17:34 +0100 schrieb Uwe K.:

> Thanks a lot for your answer.
> 
> You were right. When I tried it with only the label, the menu opened  
> correctly. Do you know how I can combine a button with a menu? Is it  
> possible to forward the right-clicked event to the parent? …or maybe  
> not intercept it at all?

AFAIK you had to change the implementation of the Gtk Button and that  
would change the behaviour of all buttons.

For most applets you’ll don’t need this. If you only want to respond to  
left-clicks just enable the button-press-event in you label.

If you think that you’ll need a button, pleas explain what you want to  
do.

Cheers  
detlef

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 4, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/4 "2006-03-04T17:35:51Z")

</div>

On Sat, 2006-03-04 at 14:25 +0100, Detlef R. wrote:

> > I have developed a panel applet, and it seems to work fine, but I am  
> > missing the popup menu when I right-click on the menu.

> i’ve never made applets in ruby, only in C but i think your problem is  
> the button, that fills the applet and which grabs the button-press  
> events.
> 
> Try it only with the label and see if the menu then opens.

Thanks a lot for your answer.

You were right. When I tried it with only the label, the menu opened  
correctly. Do you know how I can combine a button with a menu? Is it  
possible to forward the right-clicked event to the parent? …or maybe  
not intercept it at all?

Uwe

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 8, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/5 "2006-03-08T17:58:03Z")

</div>

On Tue, 2006-03-07 at 23:48 +0100, Uwe K. wrote:

> I would like the same for my applet. Is it possible? If so, how?

Sure, that’s easy.

One way you can do this:

Put your label into a frame and the frame into a eventbox. Connect the  
eventbox to the button-press-, the enter- and the leave-event.

You need the eventbox, cause the label and the frame are both  
no-window-widgets. That means they don’t own an Gdk::Window but draw on  
there parent window and as a side effect can’t recive events.

Initialize the frame with ShadowType = None. The callback for your  
enter-event changes the ShadowType to In and the leave-event back to  
None.

In your button-press-event handler you have to check which button is  
pressed. If its the left one popup your window, for the right one you  
have to foreward the event to the original handler, else the menu would  
not appear.

Cheers  
detlef

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [March 7, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/panel-applet-menu/54427/6 "2006-03-07T23:50:10Z")

</div>

On Sat, 2006-03-04 at 23:39 +0100, Detlef R. wrote:

> > You were right. When I tried it with only the label, the menu opened  
> > correctly. Do you know how I can combine a button with a menu? Is it  
> > possible to forward the right-clicked event to the parent? …or maybe  
> > not intercept it at all?
> 
> AFAIK you had to change the implementation of the Gtk Button and that  
> would change the behaviour of all buttons.

Hopefully not 🙂

> For most applets you’ll don’t need this. If you only want to respond to  
> left-clicks just enable the button-press-event in you label.
> 
> If you think that you’ll need a button, pleas explain what you want to  
> do.

I would like to have my applet look and behave similarly to the Clock  
applet. When you let your mouse pointer hover over the Clock applet,  
the applet is outlined and you can press it like a button. I you  
right-click it, you get the context menu.

I would like the same for my applet. Is it possible? If so, how?

Uwe

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)
