[gnome-control-center] network: Update forget button sensitivity when rows are destroyed



commit fb9d98bff19f1764453806a1f92c4712d944a1f7
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Sep 30 18:55:03 2013 +0200

    network: Update forget button sensitivity when rows are destroyed
    
    Doesn't make sense to keep it sensitive after the dialog returns OK.
    
    This also avoids using finalized objects if the forget button is
    clicked after some previously checked rows were destroyed because
    their connection got removed elsewhere.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709118

 panels/network/net-device-wifi.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index f8df6fc..3f0d624 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -1430,6 +1430,18 @@ check_toggled (GtkToggleButton *check, GtkWidget *forget)
 }
 
 static void
+update_forget (GtkWidget *forget,
+               gpointer   row)
+{
+        GList *rows;
+
+        rows = g_object_steal_data (G_OBJECT (forget), "rows");
+        rows = g_list_remove (rows, row);
+        g_object_set_data_full (G_OBJECT (forget), "rows", rows, (GDestroyNotify)g_list_free);
+        gtk_widget_set_sensitive (forget, rows != NULL);
+}
+
+static void
 make_row (GtkSizeGroup   *rows,
           GtkSizeGroup   *icons,
           GtkWidget      *forget,
@@ -1509,6 +1521,8 @@ make_row (GtkSizeGroup   *rows,
                 gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
                 gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
                 gtk_box_pack_start (GTK_BOX (row_box), widget, FALSE, FALSE, 0);
+                g_signal_connect_object (row, "destroy",
+                                         G_CALLBACK (update_forget), forget, G_CONNECT_SWAPPED);
         }
         if (check_out)
                 *check_out = widget;


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