[gnome-todo] notification-widget: cancel timer when mouse enters



commit c796ede3bc1a5cca72f9ee98a07d674b05193167
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jul 10 22:46:55 2015 -0300

    notification-widget: cancel timer when mouse enters
    
    If the user is about to undo the deletion and notification
    fades away, the user gets frustrated. Frustration is bad.
    
    Avoid frustration by not disposing the notification on
    mouse enter, and restart counter when mouse leaves the
    notification.

 src/notification/gtd-notification-widget.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/notification/gtd-notification-widget.c b/src/notification/gtd-notification-widget.c
index dbdcb14..d75032f 100644
--- a/src/notification/gtd-notification-widget.c
+++ b/src/notification/gtd-notification-widget.c
@@ -69,6 +69,26 @@ gtd_notification_widget_clear_bindings (GtdNotificationWidget *widget)
   g_clear_pointer (&priv->secondary_label_binding, g_binding_unbind);
 }
 
+static void
+gtd_notification_widget__enter_notify_cb (GtdNotificationWidget *widget)
+{
+  GtdNotificationWidgetPrivate *priv = widget->priv;
+
+  /* Stop the timer when mouse enters */
+  if (priv->current_notification)
+    gtd_notification_stop (priv->current_notification);
+}
+
+static void
+gtd_notification_widget__leave_notify_cb (GtdNotificationWidget *widget)
+{
+  GtdNotificationWidgetPrivate *priv = widget->priv;
+
+  /* Restart the timer when mouse leaves */
+  if (priv->current_notification)
+    gtd_notification_start (priv->current_notification);
+}
+
 /*
  * This method is called after a notification is dismissed
  * or any action is taken, and it verifies if it should
@@ -193,6 +213,8 @@ gtd_notification_widget_class_init (GtdNotificationWidgetClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtdNotificationWidget, text_label);
 
   gtk_widget_class_bind_template_callback (widget_class, gtd_notification_widget__close_button_clicked_cb);
+  gtk_widget_class_bind_template_callback (widget_class, gtd_notification_widget__enter_notify_cb);
+  gtk_widget_class_bind_template_callback (widget_class, gtd_notification_widget__leave_notify_cb);
   gtk_widget_class_bind_template_callback (widget_class, 
gtd_notification_widget__secondary_button_clicked_cb);
 }
 


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