From 6011ffb5e7cde4ab7e1bc4fb044e4ad8628fffbe Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 24 Jun 2013 14:48:00 +0200 Subject: Notify user about question dialogs Set an urgency hint on dialog's parent, or dialog itself, when it has no parent, to get user's attention to the dialog. For example, when there is a changed mail composer window on a different workspace than evolution's main window and user invokes quit by File->Quit in evolution, then the window is waiting for a response on the composer, but there was no hint it's waiting for anything. --- e-util/e-alert-dialog.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c index b4e12ad8c9..156c2729ac 100644 --- a/e-util/e-alert-dialog.c +++ b/e-util/e-alert-dialog.c @@ -322,17 +322,43 @@ e_alert_dialog_new_for_args (GtkWindow *parent, return dialog; } +static gboolean +dialog_focus_in_event_cb (GtkWindow *dialog, + GdkEvent *event, + GtkWindow *parent) +{ + gtk_window_set_urgency_hint (parent, FALSE); + + return FALSE; +} + gint e_alert_run_dialog (GtkWindow *parent, EAlert *alert) { GtkWidget *dialog; gint response; + gulong signal_id = 0; g_return_val_if_fail (E_IS_ALERT (alert), 0); dialog = e_alert_dialog_new (parent, alert); + + if (parent) { + gtk_window_set_urgency_hint (parent, TRUE); + signal_id = g_signal_connect (dialog, "focus-in-event", G_CALLBACK (dialog_focus_in_event_cb), parent); + } else { + gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); + } + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (parent) { + gtk_window_set_urgency_hint (parent, FALSE); + if (signal_id) + g_signal_handler_disconnect (dialog, signal_id); + } + gtk_widget_destroy (dialog); return response; -- cgit v1.2.3