Re: [gtk-list] WindowToFront and modal dialogs questions



On Sat, 10 Oct 1998, Michal Kara wrote:

>      Hello!
> 
>      I am developping technical drawing program using GTK and I have following
> questions:
> 
>      1) User can have multiple sheets. Since there is nothing like MDI under
> Windows, I have decided to use separate window for each sheet. I want to give
> user easy shortcut to cycle through sheets. But for this, I need to be able to
> directively put sheet window to the front of all other windows. I have searched
> gtk include files and I have not found such function.

hm, i'm not exactly sure what you'd want to have. you can raise a window (put it
in front of all othe windows) by using
gdk_window_raise (GTK_WIDGET (dialog)->window);
and you can trap any keypresses you'd want by connecting to the
"key_press_event" signal of the windows.
but as i imagine it, the result would be pretty bad, since windows need not always
to be stacked (the user can just manually place them side by side), raising doesn't
actually give you much advantage. to cause another window to get the focus is
really a window manager dependant issue, for focus-follows-mouse you'd need
to also warp the pointer (which is one of the most evil and unintuitive things a
program could possibly do) and for click-to-focus, i don't even see an obvious
solution.
usually it's best to leave the decision on which window the user currently
wants to play with up to himself.
but maybe i'm just getting you utterly wrong...

>      2) When user exits program, I want to close all sheets. Of course, when
> sheet was changed, it asks before closing, whether to save changes, forget
> changes or canel operation. If user wants to save sheet which was not yet saved,
> file selection dialog pops up.

you need to connect to the "delete_event" of the dialogs, in the callback
you have the coice of invoking gtk_main_quit() which will end gtk's main loop
and usually exit the program, or to return FALSE which will just cause your window
to be destroyed, or - if you encounter unsaved dialog contents - popup a new
dialog window and return TRUE.

>      It would make good sense if both these dialogs were modal. It is much
> easier to program and it also limits unexpected user operations (trying to close
> again sheet for which there is pending save dialog etc.) which must be carefully
> tested for.
> 
>      So is it possible somehow to create modal dialogs?

for the development tree, you can use gtk_window_set_modal(), for the stable
1.0.x releases, you need to gtk_grab_add (dialog).

> 
>      (This was just an example. There are many more situations when modal
> dialogs come handy.)
> 
> 				Thanks in advance
> 					Michal Kara alias lemming
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]