Forum: Ruby-Gnome 2 question about modal window

Posted by hendra kusuma (Guest)
on 2011-11-17 07:03
(Received via mailing list)
Dear all,

I need to create a modal child window.
So far I use gtk_window, but it has one problem

usually I have *self.modal = true* in initialize method and *self.modal 
=
false* in close method.
problem is close method doesn't work if the child window is closed by
clicking x button at the frame,
so if a user click it, child window disappear but modal state doesn't
change to false so parent window can't be accessed

so my question is,

is it the right way to create a modal child window, if not, what widget
should I use?
or
if it is, what event can I use for changing modal state before close,
I already use *delete_event *and* destroy *but it doesn't work

Thanks
Posted by Carlo E. Prelz (Guest)
on 2011-11-17 07:42
(Received via mailing list)
Subject: [ruby-gnome2-devel-en] question about modal window
  Date: gio 17 nov 11 12:54:30 +0800

Quoting hendra kusuma (penguinroad@gmail.com):

> so my question is,
>
> is it the right way to create a modal child window, if not, what widget
> should I use?

When I need a modal window, I use Dialog:

dialog=Gtk::Dialog::new("Title",@parent_window,Gtk::Dialog::MODAL)

I pack dialog.vbox with whatever I want to show, and I add one or more
buttons - for example, if I just want the user to close the window I
write:

dialog.add_button('CLOSE',Gtk::Dialog::RESPONSE_CANCEL)
dialog.signal_connect('response') do |w,r|
  dialog.destroy()
end

and I complete with

dialog.show_all()

I hope this helps

Carlo

--
  *         Se la Strada e la sua Virtu' non fossero state messe da 
parte,
* K * Carlo E. Prelz - fluido@fluido.as             che bisogno ci 
sarebbe
  *               di parlare tanto di amore e di rettitudine? 
(Chuang-Tzu)
Posted by hendra kusuma (Guest)
on 2011-11-17 10:41
(Received via mailing list)
On Thu, Nov 17, 2011 at 2:41 PM, Carlo E. Prelz <fluido@fluido.as> 
wrote:

> > problem is close method doesn't work if the child window is closed by
>
>
> and I complete with
>
> dialog.show_all()
>
> I hope this helps
>
> Carlo
>

Thanks
I manage to get it right using dialog like your suggestion, although 
many
part of code needs to change
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.