[gtk+] Shut down a11y when an app shuts down



commit 5debed5ae247c1dd440cb71d0a6d328df74b0844
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Sep 14 14:12:36 2012 -0400

    Shut down a11y when an app shuts down
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684076

 gtk/a11y/gail.c      |   18 +++++++++++++++++-
 gtk/a11y/gailutil.c  |   17 +++++++++++++++++
 gtk/a11y/gailutil.h  |    1 +
 gtk/gtkapplication.c |    6 ++++++
 gtk/gtkmain.c        |    5 +++++
 5 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/gtk/a11y/gail.c b/gtk/a11y/gail.c
index ff8450a..82c657e 100644
--- a/gtk/a11y/gail.c
+++ b/gtk/a11y/gail.c
@@ -76,6 +76,7 @@ static GtkWidget* focus_before_menu = NULL;
 static guint focus_notify_handler = 0;    
 static guint focus_tracker_id = 0;
 static GQuark quark_focus_object = 0;
+static int initialized = FALSE;
 
 static AtkObject*
 gail_get_accessible_for_widget (GtkWidget *widget,
@@ -795,9 +796,24 @@ gail_set_focus_object (AtkObject *focus_obj,
 }
 
 void
+_gtk_accessibility_shutdown (void)
+{
+  if (!initialized)
+    return;
+
+  initialized = FALSE;
+
+  g_clear_object (&atk_misc_instance);
+
+#ifdef GDK_WINDOWING_X11
+  atk_bridge_adaptor_cleanup ();
+#endif
+  _gail_util_uninstall ();
+}
+
+void
 _gtk_accessibility_init (void)
 {
-  static int initialized = FALSE;
 
   if (initialized)
     return;
diff --git a/gtk/a11y/gailutil.c b/gtk/a11y/gailutil.c
index 7cc175a..0dce3a8 100644
--- a/gtk/a11y/gailutil.c
+++ b/gtk/a11y/gailutil.c
@@ -206,6 +206,17 @@ do_window_event_initialization (void)
                     (GCallback) window_removed, NULL);
 }
 
+static void
+undo_window_event_initialization (void)
+{
+  AtkObject *root;
+
+  root = atk_get_root ();
+
+  g_signal_handlers_disconnect_by_func (root, (GCallback) window_added, NULL);
+  g_signal_handlers_disconnect_by_func (root, (GCallback) window_removed, NULL);
+}
+
 static AtkKeyEventStruct *
 atk_key_event_from_gdk_event_key (GdkEventKey *key)
 {
@@ -342,6 +353,12 @@ gail_util_get_toolkit_version (void)
 }
 
 void
+_gail_util_uninstall (void)
+{
+  undo_window_event_initialization ();
+}
+
+void
 _gail_util_install (void)
 {
   AtkUtilClass *atk_class = ATK_UTIL_CLASS (g_type_class_ref (ATK_TYPE_UTIL));
diff --git a/gtk/a11y/gailutil.h b/gtk/a11y/gailutil.h
index 9c3977d..f89d1d6 100644
--- a/gtk/a11y/gailutil.h
+++ b/gtk/a11y/gailutil.h
@@ -23,6 +23,7 @@
 G_BEGIN_DECLS
 
 void _gail_util_install (void);
+void _gail_util_uninstall (void);
 
 gboolean  _gail_util_key_snooper (GtkWidget   *the_widget,
                                   GdkEventKey *event);
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index e82cda0..907b3fe 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -47,6 +47,8 @@
 #include <gdk/x11/gdkx.h>
 #endif
 
+extern void _gtk_accessibility_shutdown (void);
+
 /**
  * SECTION:gtkapplication
  * @title: GtkApplication
@@ -425,12 +427,16 @@ gtk_application_shutdown (GApplication *application)
   gtk_application_shutdown_quartz (GTK_APPLICATION (application));
 #endif
 
+  /* Keep this section in sync with gtk_main() */
+
   /* Try storing all clipboard data we have */
   _gtk_clipboard_store_all ();
 
   /* Synchronize the recent manager singleton */
   _gtk_recent_manager_sync ();
 
+  _gtk_accessibility_shutdown ();
+
   G_APPLICATION_CLASS (gtk_application_parent_class)
     ->shutdown (application);
 }
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 56f2226..1fd7f19 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -671,6 +671,7 @@ gettext_initialization (void)
 
 /* XXX: Remove me after getting rid of gail */
 extern void _gtk_accessibility_init (void);
+extern void _gtk_accessibility_shutdown (void);
 
 static void
 do_post_parse_initialization (int    *argc,
@@ -1172,11 +1173,15 @@ gtk_main (void)
 
   if (gtk_main_loop_level == 0)
     {
+      /* Keep this section in sync with gtk_application_shutdown() */
+
       /* Try storing all clipboard data we have */
       _gtk_clipboard_store_all ();
 
       /* Synchronize the recent manager singleton */
       _gtk_recent_manager_sync ();
+
+      _gtk_accessibility_shutdown ();
     }
 }
 



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