Re: GTK Modal dialog
- From: Carlo <carlo-ag libero it>
- To: John Cupitt <jcupitt gmail com>, gtk-list gnome org
- Cc:
- Subject: Re: GTK Modal dialog
- Date: Fri, 08 Oct 2004 19:04:37 +0200
I've written such a test program, generating it by Glade and reproducing
all the custom code from my main application, and ... *surprise*, it
worked as expected, that is the little window with the progress bar is
*modal*. The code snippet is as follows:
void UpdProgress (GtkWidget * dlg) {
gint i;
gdouble frac;
GtkWidget * pbar;
pbar = lookup_widget (dlg, "pbarProgress");
for (i = 0; i < 1000; i ++) {
g_usleep (10000);
frac = (gdouble)i/ 1000;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pbar), frac);
while (gtk_events_pending ()) {
gtk_main_iteration ();
}
}
}
void on_btnCallModal_clicked (GtkButton * button,
gpointer user_data) {
GtkWidget * parent,
* dlg;
parent = lookup_widget (GTK_WIDGET (button), "winMain");
/* activating progress window
*/
dlg = create_winDlg ();
gtk_window_set_title (GTK_WINDOW (dlg), "Simulating...");
gtk_window_set_position (GTK_WINDOW (dlg),
GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent));
gtk_widget_show (dlg);
UpdProgress (dlg);
gtk_widget_destroy (dlg);
}
But, this is exactly the same situation that I have in my simulator; so
the problem must reside elsewhere. By comparing the base code generated
by Glade I found:
*my simulator*
winProgress = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (winProgress, "winProgress");
gtk_widget_set_size_request (winProgress, 350, 77);
gtk_window_set_title (GTK_WINDOW (winProgress), _("Simulating..."));
gtk_window_set_modal (GTK_WINDOW (winProgress), TRUE);
gtk_window_set_resizable (GTK_WINDOW (winProgress), FALSE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (winProgress), TRUE);
*test program*
winDlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (winDlg), "Dialog window");
gtk_window_set_position (GTK_WINDOW (winDlg),
GTK_WIN_POS_CENTER_ON_PARENT);
After some attempt, I found that it is call to
*gtk_window_set_skip_taskbar_hint* that make the dialog lost its
"modality" (BTW, after calling gtk_window_set_modal the window losses
its taskbar button).
John Cupitt ha scritto lo scorso 08/10/2004 17.18:
Could you make a small test program that shows the problem?
On Fri, 08 Oct 2004 16:09:49 +0200, Carlo <carlo-ag libero it> wrote:
Apparently, it is exactly what I do, except for the fact that my modal
contains a progressbar and has been generated by Glade2; but, while your
code works as expected, my dialog *is not modal* (by focusing the parent
window, the dialog goes under it).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]