[gnome-power-manager] When libnotify fails, fall back to modal dialogs



commit 726be8aa00eb68e390c510d0e74e0c0f822751dd
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jul 21 16:18:10 2009 +0100

    When libnotify fails, fall back to modal dialogs

 src/gpm-manager.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 1a487cc..8a3f048 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -371,6 +371,7 @@ gpm_manager_notify (GpmManager *manager, NotifyNotification **notification_class
 	gboolean ret;
 	GError *error = NULL;
 	NotifyNotification *notification;
+	GtkWidget *dialog;
 
 	/* close any existing notification of this class */
 	gpm_manager_notify_close (manager, *notification_class);
@@ -391,6 +392,17 @@ gpm_manager_notify (GpmManager *manager, NotifyNotification **notification_class
 	if (!ret) {
 		egg_warning ("failed to show notification: %s", error->message);
 		g_error_free (error);
+
+		/* show modal dialog as libnotify failed */
+		dialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+							     GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+							     "<span size='larger'><b>%s</b></span>", title);
+		gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+
+		/* wait async for close */
+		gtk_widget_show (dialog);
+		g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+
 		g_object_unref (notification);
 		goto out;
 	}



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