From b3caf3014c63640eb3faa3d9e9eb96759c7c5866 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 26 Nov 2011 20:48:55 +0100 Subject: [PATCH] Bug 451161 - Part 1: Allow overriding system accesibility settings without SystemPref module. r=surkov.alexander --- .../src/atk/nsApplicationAccessibleWrap.cpp | 27 +++++++++++++------ widget/src/gtk2/nsWindow.cpp | 20 ++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/accessible/src/atk/nsApplicationAccessibleWrap.cpp b/accessible/src/atk/nsApplicationAccessibleWrap.cpp index c8ee40cf0e06..d08280d8890c 100644 --- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp +++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp @@ -44,7 +44,8 @@ #include "nsMai.h" #include "prlink.h" #include "prenv.h" -#include "nsIPrefBranch.h" +#include "mozilla/Preferences.h" +#include "nsIGConfService.h" #include "nsIServiceManager.h" #include "nsAutoPtr.h" #include "nsAccessibilityService.h" @@ -53,6 +54,8 @@ #include #include +using namespace mozilla; + typedef GType (* AtkGetTypeType) (void); GType g_atk_hyperlink_impl_type = G_TYPE_INVALID; static bool sATKChecked = false; @@ -61,10 +64,12 @@ static const char sATKLibName[] = "libatk-1.0.so.0"; static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type"; static const char sAccEnv [] = "GNOME_ACCESSIBILITY"; -static const char sSysPrefService [] = - "@mozilla.org/system-preference-service;1"; +static const char sUseSystemPrefsKey[] = + "config.use_system_prefs"; static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility"; +static const char sGconfAccessibilityKey[] = + "/desktop/gnome/interface/accessibility"; /* gail function pointer */ static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener, @@ -625,11 +630,17 @@ nsApplicationAccessibleWrap::Init() isGnomeATEnabled = !!atoi(envValue); } else { //check gconf-2 setting - nsresult rv; - nsCOMPtr sysPrefService = - do_GetService(sSysPrefService, &rv); - if (NS_SUCCEEDED(rv) && sysPrefService) { - sysPrefService->GetBoolPref(sAccessibilityKey, &isGnomeATEnabled); + if (Preferences::GetBool(sUseSystemPrefsKey, false)) { + nsresult rv; + nsCOMPtr gconf = + do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && gconf) { + gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), + &isGnomeATEnabled); + } + } else { + isGnomeATEnabled = + Preferences::GetBool(sAccessibilityKey, false); } } diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index f3d2d4fe1e20..7213896644a4 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -99,7 +99,7 @@ #include "mozilla/Preferences.h" #include "nsIPrefService.h" -#include "nsIPrefBranch.h" +#include "nsIGConfService.h" #include "nsIServiceManager.h" #include "nsIStringBundle.h" #include "nsGfxCIID.h" @@ -119,9 +119,10 @@ using namespace mozilla; static bool sAccessibilityChecked = false; /* static */ bool nsWindow::sAccessibilityEnabled = false; -static const char sSysPrefService [] = "@mozilla.org/system-preference-service;1"; static const char sAccEnv [] = "GNOME_ACCESSIBILITY"; +static const char sUseSystemPrefsKey[] = "config.use_system_prefs"; static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility"; +static const char sGconfAccessibilityKey[] = "/desktop/gnome/interface/accessibility"; #endif /* For SetIcon */ @@ -4293,17 +4294,20 @@ nsWindow::Create(nsIWidget *aParent, LOG(("Accessibility Env %s=%s\n", sAccEnv, envValue)); } //check gconf-2 setting - else { - nsCOMPtr sysPrefService = - do_GetService(sSysPrefService, &rv); - if (NS_SUCCEEDED(rv) && sysPrefService) { + else if (Preferences::GetBool(sUseSystemPrefsKey, false)) { + nsCOMPtr gconf = + do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && gconf) { // do the work to get gconf setting. // will be done soon later. - sysPrefService->GetBoolPref(sAccessibilityKey, - &sAccessibilityEnabled); + gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), + &sAccessibilityEnabled); } + } else { + sAccessibilityEnabled = + Preferences::GetBool(sAccessibilityKey, false); } } #endif