[libgd/wip/ernestask/gtk4: 7/10] notification: remove visibility_notify_event override



commit cd5719a79c43ee0e9a3a046f9dc14c08d3be30ea
Author: Ernestas Kulik <ernestask gnome org>
Date:   Sun Mar 11 10:10:04 2018 +0200

    notification: remove visibility_notify_event override
    
    The event no longer exists, so the bulk of the handler is moved to the
    show/hide overrides.

 libgd/gd-notification.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/libgd/gd-notification.c b/libgd/gd-notification.c
index 55c2c62..37f6ca2 100644
--- a/libgd/gd-notification.c
+++ b/libgd/gd-notification.c
@@ -57,7 +57,6 @@ struct _GdNotificationPrivate {
   GdkWindow *bin_window;
 
   int animate_y; /* from 0 to allocation.height */
-  gboolean waiting_for_viewable;
   gboolean revealed;
   gboolean dismissed;
   gboolean sent_dismissed;
@@ -287,6 +286,30 @@ start_animation (GdNotification *notification)
 }
 
 static void
+unqueue_autohide (GdNotification *notification)
+{
+  GdNotificationPrivate *priv = notification->priv;
+
+  if (priv->timeout_source_id)
+    {
+      g_source_remove (priv->timeout_source_id);
+      priv->timeout_source_id = 0;
+    }
+}
+
+static void
+queue_autohide (GdNotification *notification)
+{
+  GdNotificationPrivate *priv = notification->priv;
+
+  if (priv->timeout_source_id == 0 &&
+      priv->timeout != -1)
+    priv->timeout_source_id =
+      g_timeout_add (priv->timeout * 1000, gd_notification_timeout_cb, notification);
+}
+
+
+static void
 gd_notification_show (GtkWidget *widget)
 {
   GdNotification *notification = GD_NOTIFICATION (widget);
@@ -294,7 +317,9 @@ gd_notification_show (GtkWidget *widget)
 
   GTK_WIDGET_CLASS (gd_notification_parent_class)->show (widget);
   priv->revealed = TRUE;
-  priv->waiting_for_viewable = TRUE;
+
+  start_animation (notification);
+  queue_autohide (notification);
 }
 
 static void
@@ -303,9 +328,12 @@ gd_notification_hide (GtkWidget *widget)
   GdNotification *notification = GD_NOTIFICATION (widget);
   GdNotificationPrivate *priv = notification->priv;
 
+  unqueue_autohide (notification);
+
   GTK_WIDGET_CLASS (gd_notification_parent_class)->hide (widget);
   priv->revealed = FALSE;
-  priv->waiting_for_viewable = FALSE;
+
+  start_animation (notification);
 }
 
 static void


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