[drwright] Add 'Take Break Now' action to the notification



commit 949448c6c50e1ccb6f9a5f5d1434386ad2834689
Author: Christopher Aillon <caillon redhat com>
Date:   Thu Mar 3 13:23:13 2011 -0800

    Add 'Take Break Now' action to the notification
    
    GNOME bug 643535 part 3

 src/drwright.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/drwright.c b/src/drwright.c
index 7a7ebb9..32fca55 100644
--- a/src/drwright.c
+++ b/src/drwright.c
@@ -91,6 +91,24 @@ static GList *  create_secondary_break_windows (void);
 extern gboolean debug;
 
 static void
+notification_action_cb (NotifyNotification *notification,
+                        const char *action,
+                        DrWright *dr)
+{
+	g_assert (action != NULL);
+
+	if (g_strcmp0 (action, "take-break") == 0) {
+		if (dr->enabled) {
+			dr->state = STATE_BREAK_SETUP;
+			maybe_change_state (dr);
+		}
+	}
+	else {
+		g_warning ("Unknown action: %s", action);
+	}
+}
+
+static void
 show_warning_notification (DrWright *dr, gboolean show)
 {
 	NotifyNotification *notification;
@@ -142,6 +160,10 @@ show_warning_notification (DrWright *dr, gboolean show)
 		notification = notify_notification_new (summary, body, "typing-monitor");
 		notify_notification_set_hint (notification, "resident",
 		                              g_variant_new_boolean (TRUE));
+		notify_notification_add_action (notification,
+		                                "take-break", _("Take Break Now"),
+		                                NOTIFY_ACTION_CALLBACK (notification_action_cb),
+		                                dr, NULL);
 		dr->notification = notification;
 	}
 



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