[gnome-builder] notifications: fade notification button in/out



commit ed110ea3cf121f2ca91f5826124bce619339ff1c
Author: Christian Hergert <chergert redhat com>
Date:   Tue Apr 30 14:28:06 2019 -0700

    notifications: fade notification button in/out
    
    This is a bit nicer now that we have the search button in the compressed
    form in most cases.

 src/libide/gui/ide-notifications-button.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/gui/ide-notifications-button.c b/src/libide/gui/ide-notifications-button.c
index a9e47e41e..c2b13b30b 100644
--- a/src/libide/gui/ide-notifications-button.c
+++ b/src/libide/gui/ide-notifications-button.c
@@ -110,6 +110,26 @@ ide_notifications_button_bind_model (IdeNotificationsButton *self,
     }
 }
 
+static void
+ide_notifications_button_notify_has_progress_cb (IdeNotificationsButton *self,
+                                                 GParamSpec             *pspec,
+                                                 IdeNotifications       *notifications)
+{
+  g_assert (IDE_IS_NOTIFICATIONS_BUTTON (self));
+  g_assert (IDE_IS_NOTIFICATIONS (notifications));
+
+  if (ide_notifications_get_has_progress (notifications))
+    {
+      if (!gtk_widget_get_visible (GTK_WIDGET (self)))
+        dzl_gtk_widget_show_with_fade (GTK_WIDGET (self));
+    }
+  else
+    {
+      if (gtk_widget_get_visible (GTK_WIDGET (self)))
+        dzl_gtk_widget_hide_with_fade (GTK_WIDGET (self));
+    }
+}
+
 static void
 ide_notifications_button_context_set_cb (GtkWidget  *widget,
                                          IdeContext *context)
@@ -125,10 +145,15 @@ ide_notifications_button_context_set_cb (GtkWidget  *widget,
 
   g_object_bind_property (notifications, "progress", self, "progress",
                           G_BINDING_SYNC_CREATE);
-  g_object_bind_property (notifications, "has-progress", self, "visible",
-                          G_BINDING_SYNC_CREATE);
+  g_signal_connect_object (notifications,
+                           "notify::has-progress",
+                           G_CALLBACK (ide_notifications_button_notify_has_progress_cb),
+                           self,
+                           G_CONNECT_SWAPPED);
   g_object_bind_property (notifications, "progress-is-imprecise", self, "show-progress",
                           G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
+
+  ide_notifications_button_notify_has_progress_cb (self, NULL, notifications);
 }
 
 static void


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