Bug 451161 - Part 1: Allow overriding system accesibility settings without SystemPref module. r=surkov.alexander

This commit is contained in:
Masatoshi Kimura 2011-11-26 20:48:55 +01:00
parent 36621e319f
commit b3caf3014c
2 changed files with 31 additions and 16 deletions

View File

@ -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 <gtk/gtk.h>
#include <atk/atk.h>
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<nsIPrefBranch> sysPrefService =
do_GetService(sSysPrefService, &rv);
if (NS_SUCCEEDED(rv) && sysPrefService) {
sysPrefService->GetBoolPref(sAccessibilityKey, &isGnomeATEnabled);
if (Preferences::GetBool(sUseSystemPrefsKey, false)) {
nsresult rv;
nsCOMPtr<nsIGConfService> 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);
}
}

View File

@ -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<nsIPrefBranch> sysPrefService =
do_GetService(sSysPrefService, &rv);
if (NS_SUCCEEDED(rv) && sysPrefService) {
else if (Preferences::GetBool(sUseSystemPrefsKey, false)) {
nsCOMPtr<nsIGConfService> 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