[libgd] main-icon-box-child: Show a spinner to reflect GdMainBoxItem::pulse



commit 6085c29403e01b6142e5f721a6a998ff4ef428e9
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 12 10:42:33 2018 +0100

    main-icon-box-child: Show a spinner to reflect GdMainBoxItem::pulse
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793295

 libgd/gd-main-icon-box-child.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/libgd/gd-main-icon-box-child.c b/libgd/gd-main-icon-box-child.c
index be766e0..3e24694 100644
--- a/libgd/gd-main-icon-box-child.c
+++ b/libgd/gd-main-icon-box-child.c
@@ -108,6 +108,18 @@ gd_main_icon_box_child_update_layout (GdMainIconBoxChild *self)
   gtk_widget_set_hexpand (icon, TRUE);
   gtk_container_add (GTK_CONTAINER (overlay), icon);
 
+  if (gd_main_box_item_get_pulse (priv->item))
+    {
+      GtkWidget *spinner;
+
+      spinner = gtk_spinner_new ();
+      gtk_widget_set_halign (spinner, GTK_ALIGN_CENTER);
+      gtk_widget_set_size_request (spinner, 32, 32);
+      gtk_widget_set_valign (spinner, GTK_ALIGN_CENTER);
+      gtk_spinner_start (GTK_SPINNER (spinner));
+      gtk_overlay_add_overlay (GTK_OVERLAY (overlay), spinner);
+    }
+
   priv->check_button = gtk_check_button_new ();
   gtk_widget_set_can_focus (priv->check_button, FALSE);
   gtk_widget_set_halign (priv->check_button, GTK_ALIGN_END);
@@ -166,6 +178,12 @@ gd_main_icon_box_child_update_layout (GdMainIconBoxChild *self)
   gtk_widget_show_all (grid);
 }
 
+static void
+gd_main_icon_box_child_notify_pulse (GdMainIconBoxChild *self)
+{
+  gd_main_icon_box_child_update_layout (self);
+}
+
 static GdMainBoxItem *
 gd_main_icon_box_child_get_item (GdMainBoxChild *child)
 {
@@ -230,9 +248,21 @@ gd_main_icon_box_child_set_item (GdMainIconBoxChild *self, GdMainBoxItem *item)
 
   priv = gd_main_icon_box_child_get_instance_private (self);
 
+  if (priv->item != NULL)
+    g_signal_handlers_disconnect_by_func (priv->item, gd_main_icon_box_child_notify_pulse, self);
+
   if (!g_set_object (&priv->item, item))
     return;
 
+  if (priv->item != NULL)
+    {
+      g_signal_connect_object (priv->item,
+                               "notify::pulse",
+                               G_CALLBACK (gd_main_icon_box_child_notify_pulse),
+                               self,
+                               G_CONNECT_SWAPPED);
+    }
+
   g_object_notify (G_OBJECT (self), "item");
   gtk_widget_queue_draw (GTK_WIDGET (self));
 }


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