New to gui-coding and have 2 questions :)

Hi,
I started to code my first gui with ruby and gtk with the help of glade.
Now everything works fine but I have two problems:

1.) If I exit my program via the X in the window-border (I hope you
understand what I mean. The X which is in every window in the
right-upper border) the window closes but the program keeps running. So
if I execute it in the console I have to push strg+c to make my process
end. How can I make my program finish if I push the X on the window?

2.) How do I invoka an error-dialog box? I know how to create one with
glade but how can I call it?

Any help is really welcome :slight_smile:

greets

kazaam [email protected]

kazaam
escribió:> Hi,

I started to code my first gui with ruby and gtk with the help of glade. Now everything works fine but I have two problems:

1.) If I exit my program via the X in the window-border (I hope you understand what I mean. The X which is in every window in the right-upper border) the window closes but the program keeps running. So if I execute it in the console I have to push strg+c to make my process end. How can I make my program finish if I push the X on the window?

That X in the right-upper corner triggers a delete-event.

In glade-2, in the signals tab of your main window, add an event for the
signal delete_event, then add in your ruby file a code similar to:

def on_YOURWINDOW_delete_event widget, event, data = nil
    Gtk.main_quit
end

where YOURWINDOW is the widget name (in this case the main window)

2.) How do I invoka an error-dialog box? I know how to create one with glade but how can I call it?

glade-2 allows to create Dialogs, in the same way as you create Windows.
Try YOURDIALOG.run for showing it as explained in
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ADialog#run

For error/warn/info dialogs, the best way seems to create a
Gtk::MessageDialog, as shown in
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AMessageDialog

Any help is really welcome :slight_smile:

greets

–

Regards,
Cro

On Sat, 17 Nov 2007 12:34:19 -0300
El Croata [email protected] wrote:

def on_YOURWINDOW_delete_event widget, event, data = nil
    Gtk.main_quit
end

where YOURWINDOW is the widget name (in this case the main window)

Ahh thanks I tried it with the destroy-signal but with the delete one it
works now :slight_smile:

glade-2 allows to create Dialogs, in the same way as you create Windows.
Try YOURDIALOG.run for showing it as explained in
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ADialog#run

For error/warn/info dialogs, the best way seems to create a
Gtk::MessageDialog, as shown in
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3AMessageDialog

I created now a dialog with one button with glade and set it to
invisible. If I wanna raise it I just call it with dialog1.show which
work correctly.

thanks for your help

greets

kazaam [email protected]