[英]system modal dialog in GTK
I am trying to create GtkDialog with system wide Modal property ie when the dialog is opened no other window should get focus. 我正在尝试创建具有系统范围的Modal属性的GtkDialog,即,当打开对话框时,其他任何窗口都不应获得焦点。 There is an option for making it modal using GtkDialogFlag but that is not system wide modal.
有一个选项可以使用GtkDialogFlag使其成为模态,但这不是系统范围的模态。
This is an utterly horrible idea, but you can override the "focus-out-event" handler for your window and have it call gtk_window_present
. 这是一个非常可怕的想法,但是您可以为窗口覆盖“焦点事件”处理程序,并将其调用
gtk_window_present
。
Something like gksu does: 像gksu一样:
static gboolean focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { gtk_window_present (GTK_WINDOW(widget)); return TRUE; } //in your initialization code for your window... /* make sure that our window will always have the focus */ g_signal_connect (G_OBJECT(mywindow), "focus-out-event", G_CALLBACK(focus_out_cb), NULL);
This hopefully has the added benefit of if your application does freeze, the signal for focus-out-event will probably not be handled. 希望这会带来额外的好处,如果您的应用程序确实死机,则可能不会处理焦点事件的信号。 I'm not sure how GTK does UI threading though, but I think this should be true.
我不确定GTK如何进行UI线程化,但是我认为这应该是正确的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.