[caribou: 19/23] Implement g_module_unload to clean up after disabling keyboard



commit 931d840edff1d6cd051838d0f8c01b2e71d1eb1c
Author: Nohemi Fernandez <nf68 cornell edu>
Date:   Mon Aug 8 20:22:43 2011 -0500

    Implement g_module_unload to clean up after disabling keyboard

 modules/gtk3/caribou-gtk-module.vala |    8 ++++++++
 modules/gtk3/caribou-module.c        |    7 +++++++
 modules/gtk3/vapi-fixes.vapi         |    5 +++++
 3 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index add5a79..4c92348 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -125,5 +125,13 @@ namespace Caribou {
 #endif
         }
 
+        public void unload () {
+            Gdk.window_remove_filter(null, event_filter);
+            windows = new GLib.HashTable<Gtk.Window, bool> (null, null);
+            cursor_rect.x = cursor_rect.y = cursor_rect.width = cursor_rect.height = 0;
+            keyboard = null;
+            display = null;
+        }
+
     }
 }
diff --git a/modules/gtk3/caribou-module.c b/modules/gtk3/caribou-module.c
index ad45752..90f0534 100644
--- a/modules/gtk3/caribou-module.c
+++ b/modules/gtk3/caribou-module.c
@@ -5,9 +5,12 @@
 
 #define CARIBOU_LOCALDIR ""
 
+G_MODULE_EXPORT CaribouGtkModule * gtk_module;
+
 G_MODULE_EXPORT CaribouGtkModule *
 gtk_module_init (gint *argc, gchar ***argv[]) {
     CaribouGtkModule *context = caribou_gtk_module_new ();
+    gtk_module = context;
         return context;
 }
 
@@ -17,3 +20,7 @@ g_module_check_init (GModule *module)
     return gtk_check_version (GTK_MAJOR_VERSION, 0, 0);
 }
 
+G_MODULE_EXPORT void
+g_module_unload(GModule *module) {
+    caribou_gtk_module_unload (gtk_module);
+}
diff --git a/modules/gtk3/vapi-fixes.vapi b/modules/gtk3/vapi-fixes.vapi
index 42e7feb..deec3f6 100644
--- a/modules/gtk3/vapi-fixes.vapi
+++ b/modules/gtk3/vapi-fixes.vapi
@@ -8,6 +8,11 @@ namespace Gdk {
     public void window_add_filter (Gdk.Window? window,
 								   Gdk.FilterFunc function);
 
+	// Gdk.Window.remove_filter() doesn't let you pass null for window
+     [CCode (cname = "gdk_window_remove_filter")]
+    public void window_remove_filter (Gdk.Window? window,
+                                                                   Gdk.FilterFunc function);
+
 	// Official binding is missing the "out"
     [CCode (cname = "gdk_window_get_user_data")]
     public void window_get_user_data (Gdk.Window window,



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