[caribou: 12/23] Make "windows" a hash table rather than a list



commit cc324bf941b3856c90c0c42753433ab0ceb4bfa7
Author: Dan Winship <danw gnome org>
Date:   Fri Aug 5 12:18:06 2011 -0400

    Make "windows" a hash table rather than a list
    
    And remove windows from it when they are destroyed

 modules/gtk3/caribou-gtk-module.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index c5e230d..46a76ce 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -10,11 +10,11 @@ namespace Caribou {
     }
 
     class GtkModule {
-        private GLib.List<Gtk.Window> windows;
+        private GLib.HashTable<Gtk.Window, bool> windows;
         private Keyboard keyboard;
 
         public GtkModule () {
-            windows = new GLib.List<Gtk.Window> ();
+            windows = new GLib.HashTable<Gtk.Window, bool> (null, null);
             try {
                 keyboard = Bus.get_proxy_sync (BusType.SESSION,
                                                "org.gnome.Caribou.Keyboard",
@@ -37,9 +37,10 @@ namespace Caribou {
 
             toplevels = Gtk.Window.list_toplevels ();
             foreach (Gtk.Window window in toplevels) {
-                if (windows.find (window) == null) {
+                if (!windows.lookup (window)) {
                     window.notify["has-toplevel-focus"].connect (has_top_level_focus_changed);
-                    windows.append (window);
+                    window.destroy.connect (() => { windows.remove (window); });
+                    windows.insert (window, true);
                 }
             }
         }



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