Forum: Ruby-Gnome 2 Panel Applet Menu

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Uwe K. (Guest)
on 2006-03-04 14:40
(Received via mailing list)
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 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...
Detlef R. (Guest)
on 2006-03-04 15:37
(Received via mailing list)
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 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...
Uwe K. (Guest)
on 2006-03-04 18:35
(Received via mailing list)
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 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...
Detlef R. (Guest)
on 2006-03-05 23:50
(Received via mailing list)
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 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...
Uwe K. (Guest)
on 2006-03-08 00:50
(Received via mailing list)
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 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...
Detlef R. (Guest)
on 2006-03-08 18:58
(Received via mailing list)
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 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...
This topic is locked and can not be replied to.