[evolution-patches] patches for bug 44592:accessibility initializing codes to loading evolution and gal atk support extension library



Hi, Ettore

  This patch is the ASE initialization part.

Gilbert 
--- /dev/null	2002-08-31 07:31:37.000000000 +0800
+++ a11y/init.c	2003-06-12 20:27:27.000000000 +0800
@@ -0,0 +1,75 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* init.c
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Gilbert Fang <gilbert fang sun com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#include <config.h>
+
+#include <atk/atkregistry.h>
+
+#include <stdio.h>
+
+/* Static functions */
+
+static gboolean initialized = FALSE;
+
+extern void gnome_accessibility_module_init     (void);
+extern void gnome_accessibility_module_shutdown (void);
+
+void
+evolution_a11y_init (void)
+{
+	if (initialized)
+		return;
+
+	/* atk registry stuff here, need implementation*/
+
+	initialized = TRUE;
+
+	fprintf (stderr, "Evolution Accessibility Support Extension Module initialized\n");
+}
+
+void
+gnome_accessibility_module_init (void)
+{
+	evolution_a11y_init();
+}
+
+void
+gnome_accessibility_module_shutdown (void)
+{
+	if (!initialized)
+		return;
+	
+	/* atk un-registry stuff here need implementation*/
+
+	initialized = FALSE;
+	fprintf (stderr, "Evolution Accessibilty Support Extension Module shutdown\n");
+
+}
+
+int
+gtk_module_init (gint *argc, char** argv[])
+{
+  evolution_a11y_init ();
+
+  return 0;
+}
--- /dev/null	2002-08-31 07:31:37.000000000 +0800
+++ a11y/Makefile.am	2003-06-12 21:13:18.000000000 +0800
@@ -0,0 +1,19 @@
+
+INCLUDES =						\
+	-DPREFIX=\"$(prefix)\"				\
+	-DSYSCONFDIR=\"$(sysconfdir)\"			\
+	-DDATADIR=\"$(datadir)\"			\
+	-DLIBDIR=\"$(libdir)\"				\
+	-DG_LOG_DOMAIN=\"evolution-a11y\"		\
+	-I$(top_srcdir) 				\
+	-DG_DISABLE_DEPRECATED				\
+	-DLIBGNOME_DISABLE_DEPRECATED			\
+	$(ACCESSIBILITY_CFLAGS)
+
+privlib_LTLIBRARIES = libevolution-a11y.la 
+
+libevolution_a11y_la_SOURCES =				\
+	init.c
+
+libevolution_a11y_la_LIBADD =				\
+	$(ACCESSIBILITY_LIBS)
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.582
diff -u -r1.582 configure.in
--- configure.in	19 May 2003 22:46:57 -0000	1.582
+++ configure.in	12 Jun 2003 08:02:28 -0000
@@ -251,6 +251,22 @@
 
 
 dnl **************************************************
+dnl * Accessibility support
+dnl **************************************************
+AC_ARG_ENABLE(accessibility, [  --enable-accessibility=[no/yes]      Enable support for accessibility.],,enable_accessibility=no)
+if test "x$enable_accessibility" = "xyes"; then
+	AC_DEFINE(ENABLE_ACCESSIBILITY,1,[Enable Accessibility support])
+	msg_accessibility=yes
+	PKG_CHECK_MODULES(ACCESSIBILITY, atk)
+	AC_SUBST(ACCESSIBILITY_CFLAGS)
+	AC_SUBST(ACCESSIBILITY_LIBS)
+else
+	msg_accessibility=no
+fi
+AM_CONDITIONAL(ENABLE_ACCESSIBILITY, test "x$enable_accessibility" = "xyes")
+
+
+dnl **************************************************
 dnl * IPv6 support
 dnl **************************************************
 AC_ARG_ENABLE(ipv6, [  --enable-ipv6=[no/yes]      Enable support for resolving IPv6 addresses.],,enable_ipv6=no)
@@ -1281,6 +1297,7 @@
 
 AC_OUTPUT([ po/Makefile.in
 Makefile
+a11y/Makefile
 addressbook/Makefile
 addressbook/gui/Makefile
 addressbook/gui/component/Makefile
@@ -1404,6 +1421,11 @@
 	Dot Locking:	  $msg_dot
 	File Locking:	  $msg_file
 	Gtk-doc:	  $enable_gtk_doc"
+
+if test "$msg_accessibility" = "yes"; then
+echo "\
+	Accessibility support:     $msg_accessibility"
+fi
 
 if test x$enable_gtk_doc = xyes; then
 echo "
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/Makefile.am,v
retrieving revision 1.80
diff -u -r1.80 Makefile.am
--- Makefile.am	26 Mar 2003 23:02:26 -0000	1.80
+++ Makefile.am	12 Jun 2003 06:55:01 -0000
@@ -22,6 +22,10 @@
 	intltool-extract.in	\
 	$(pkgconfig_DATA:.pc=.pc.in)
 
+if ENABLE_ACCESSIBILITY
+ACCESSIBILITY_SUBDIR = a11y
+endif
+
 SUBDIRS = 			\
         data                    \
         e-util                  \
@@ -43,6 +47,7 @@
 	views			\
 	wombat			\
 	tools			\
+	$(ACCESSIBILITY_SUBDIR)	\
 	help			\
 	po
 
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.123
diff -u -r1.123 main.c
--- shell/main.c	19 May 2003 19:41:05 -0000	1.123
+++ shell/main.c	12 Jun 2003 06:56:33 -0000
@@ -35,6 +35,7 @@
 
 #include <gconf/gconf-client.h>
 
+#include <gmodule.h>
 #include <gtk/gtkalignment.h>
 #include <gtk/gtkframe.h>
 #include <gtk/gtklabel.h>
@@ -91,6 +92,11 @@
 
 extern char *evolution_debug_log;
 
+#ifdef ENABLE_ACCESSIBILITY
+#define GNOME_ACCESSIBILITY_ENV "GNOME_ACCESSIBILITY"
+#define GNOME_ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
+#endif
+
 
 static GtkWidget *
 quit_box_new (void)
@@ -534,6 +540,111 @@
 	g_static_mutex_lock (&segv_mutex);
 }
 
+#ifdef ENABLE_ACCESSIBILITY
+
+static char *
+find_accessibility_module (GnomeProgram *program, const char *libname)
+{
+	char *sub;
+	char *path;
+	char *fname;
+	char *retval;
+
+	fname = g_strconcat (libname, "." G_MODULE_SUFFIX, NULL);
+	sub = g_strconcat ("gtk-2.0/modules", G_DIR_SEPARATOR_S, fname, NULL);
+
+	path = gnome_program_locate_file (
+		program, GNOME_FILE_DOMAIN_LIBDIR, sub, TRUE, NULL);
+
+	g_free (sub);
+
+	if (path)
+		retval = path;
+	else {
+		sub = g_strconcat ("evolution", G_DIR_SEPARATOR_S, BASE_VERSION,
+				   G_DIR_SEPARATOR_S, fname, NULL);
+		path = gnome_program_locate_file (
+		       program, GNOME_FILE_DOMAIN_LIBDIR, sub, TRUE, NULL);
+		g_free (sub);
+
+		if (path)
+			retval = path;
+		else
+			retval = gnome_program_locate_file (
+				 program, GNOME_FILE_DOMAIN_LIBDIR, fname, TRUE, NULL);
+	}
+	g_free (fname);
+
+	return retval;
+}
+
+
+static gboolean
+accessibility_invoke_module (GnomeProgram *program,
+			     const char   *libname,
+			     gboolean      init)
+{
+	GModule    *handle;
+	void      (*invoke_fn) (void);
+	const char *method;
+	gboolean    retval = FALSE;
+	char       *module_name;
+
+	if (init)
+		method = "gnome_accessibility_module_init";
+	else
+		method = "gnome_accessibility_module_shutdown";
+
+	module_name = find_accessibility_module (program, libname);
+
+	if (!module_name) {
+		g_warning ("Accessibility: failed to find module '%s' which "
+			   "is needed to make this application accessible",
+			   libname);
+
+	} else if (!(handle = g_module_open (module_name, G_MODULE_BIND_LAZY))) {
+		g_warning ("Accessibility: failed to load module '%s': '%s'",
+			   libname, g_module_error ());
+
+	} else if (!g_module_symbol (handle, method, (gpointer *)&invoke_fn)) {
+		g_warning ("Accessibility: error library '%s' does not include "
+			   "method '%s' required for accessibility support",
+			   libname, method);
+		g_module_close (handle);
+
+	} else {
+		retval = TRUE;
+		invoke_fn ();
+	}
+
+	g_free (module_name);
+
+	return retval;
+}
+
+static void
+accessibility_init (GnomeProgram *program)
+{
+	gboolean do_init;
+	const char *env_var;
+	
+	do_init = FALSE;
+
+	if ((env_var = g_getenv (GNOME_ACCESSIBILITY_ENV)))
+		do_init = atoi (env_var);
+	else
+		do_init = gconf_client_get_bool (
+			gconf_client_get_default (),
+			GNOME_ACCESSIBILITY_KEY, NULL);
+
+	if (do_init) {
+		accessibility_invoke_module (program, "libgal-a11y-2.0", TRUE);
+		accessibility_invoke_module (program, "libevolution-a11y", TRUE);
+	}
+}
+
+#endif
+
 int
 main (int argc, char **argv)
 {
@@ -573,6 +684,11 @@
 				      GNOME_PARAM_POPT_TABLE, options,
 				      GNOME_PARAM_HUMAN_READABLE_NAME, _("Evolution"),
 				      NULL);
+
+#ifdef ENABLE_ACCESSIBILITY	
+	accessibility_init (program);
+#endif
+
 
 	if (start_online && start_offline) {
 		fprintf (stderr, _("%s: --online and --offline cannot be used together.\n  Use %s --help for more information.\n"),


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