gnome-session r4842 - in branches/dbus_based: . gnome-session



Author: mccann
Date: Fri Jul 25 02:30:57 2008
New Revision: 4842
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4842&view=rev

Log:
2008-07-24  William Jon McCann  <jmccann redhat com>

	* gnome-session/gsm-inhibitor-store.c (gsm_inhibitor_store_remove),
	(_remove_all), (gsm_inhibitor_store_clear):
	Make sure to always emit the removed signal.



Modified:
   branches/dbus_based/ChangeLog
   branches/dbus_based/gnome-session/gsm-inhibitor-store.c

Modified: branches/dbus_based/gnome-session/gsm-inhibitor-store.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-inhibitor-store.c	(original)
+++ branches/dbus_based/gnome-session/gsm-inhibitor-store.c	Fri Jul 25 02:30:57 2008
@@ -74,34 +74,30 @@
         return g_hash_table_size (store->priv->inhibitors);
 }
 
-void
-gsm_inhibitor_store_clear (GsmInhibitorStore    *store)
-{
-        g_return_if_fail (store != NULL);
-        g_debug ("GsmInhibitorStore: Clearing inhibitor store");
-        g_hash_table_remove_all (store->priv->inhibitors);
-}
-
-static gboolean
-remove_inhibitor (guint               *cookie,
-                  GsmInhibitor        *inhibitor,
-                  GsmInhibitor        *inhibitor_to_remove)
-{
-        if (inhibitor == inhibitor_to_remove) {
-                return TRUE;
-        }
-        return FALSE;
-}
-
 gboolean
 gsm_inhibitor_store_remove (GsmInhibitorStore    *store,
                             GsmInhibitor         *inhibitor)
 {
+        GsmInhibitor *found;
+        gboolean      removed;
+        guint         cookie;
+
         g_return_val_if_fail (store != NULL, FALSE);
 
-        gsm_inhibitor_store_foreach_remove (store,
-                                            (GsmInhibitorStoreFunc)remove_inhibitor,
-                                            inhibitor);
+        cookie = gsm_inhibitor_get_cookie (inhibitor);
+
+        found = g_hash_table_lookup (store->priv->inhibitors,
+                                     GUINT_TO_POINTER (cookie));
+        if (found == NULL) {
+                return FALSE;
+        }
+
+        g_signal_emit (store, signals [INHIBITOR_REMOVED], 0, cookie);
+
+        removed = g_hash_table_remove (store->priv->inhibitors,
+                                       GUINT_TO_POINTER (cookie));
+        g_assert (removed);
+
         return FALSE;
 }
 
@@ -192,6 +188,26 @@
         return ret;
 }
 
+static gboolean
+_remove_all (guint        *cookie,
+             GsmInhibitor *inhibitor,
+             gpointer      data)
+{
+        return TRUE;
+}
+
+void
+gsm_inhibitor_store_clear (GsmInhibitorStore    *store)
+{
+        g_return_if_fail (store != NULL);
+
+        g_debug ("GsmInhibitorStore: Clearing inhibitor store");
+
+        gsm_inhibitor_store_foreach_remove (store,
+                                            _remove_all,
+                                            NULL);
+}
+
 gboolean
 gsm_inhibitor_store_add (GsmInhibitorStore *store,
                          GsmInhibitor      *inhibitor)



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