开发者

system modal dialog in GTK

开发者 https://www.devze.com 2023-01-14 11:56 出处:网络
I am 开发者_如何学编程trying to create GtkDialog with system wide Modal property i.e. when the dialog is opened no other window should get focus. There is an option for making it modal using GtkDialog

I am 开发者_如何学编程trying to create GtkDialog with system wide Modal property i.e. when the dialog is opened no other window should get focus. There is an option for making it modal using GtkDialogFlag but that is not system wide modal.


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.

Something like gksu does:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消