Merge lp:~apinheiro/unity/a11y-replace-gconf into lp:unity

Proposed by Alejandro Piñeiro
Status: Merged
Approved by: Alex Launi
Approved revision: no longer in the source branch.
Merged at revision: 1285
Proposed branch: lp:~apinheiro/unity/a11y-replace-gconf
Merge into: lp:unity
Diff against target: 134 lines (+27/-32)
2 files modified
plugins/unityshell/src/unitya11y.cpp (+13/-16)
services/panel-a11y.c (+14/-16)
To merge this branch: bzr merge lp:~apinheiro/unity/a11y-replace-gconf
Reviewer Review Type Date Requested Status
Alex Launi (community) Approve
Neil J. Patel Pending
Review via email: mp+67869@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unitya11y.cpp'
2--- plugins/unityshell/src/unitya11y.cpp 2011-05-30 04:13:42 +0000
3+++ plugins/unityshell/src/unitya11y.cpp 2011-07-13 17:41:35 +0000
4@@ -20,7 +20,6 @@
5 #include <gio/gio.h>
6 #include <gmodule.h>
7 #include <stdio.h>
8-#include <gconf/gconf-client.h>
9
10 #include "unitya11y.h"
11 #include "unitya11ytests.h"
12@@ -52,7 +51,8 @@
13 static gboolean a11y_initialized = FALSE;
14
15 #define INIT_METHOD "gnome_accessibility_module_init"
16-#define A11Y_GCONF_KEY "/desktop/gnome/interface/accessibility"
17+#define DESKTOP_SCHEMA "org.gnome.desktop.interface"
18+#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility"
19 #define AT_SPI_SCHEMA "org.a11y.atspi"
20 #define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location"
21
22@@ -70,6 +70,8 @@
23 g_type_class_unref (g_type_class_ref (UNITY_TYPE_UTIL_ACCESSIBLE));
24 }
25
26+/* This method is required because g_setting_new abort if the schema
27+ is not present. */
28 static gboolean
29 has_gsettings_schema (const gchar *schema)
30 {
31@@ -77,8 +79,6 @@
32 gboolean found = FALSE;
33 int i = 0;
34
35- /* we need to check if AT_SPI_SCHEMA is present as g_setting_new
36- could abort if the schema is not here*/
37 list_schemas = g_settings_list_schemas ();
38 for (i = 0; list_schemas [i]; i++)
39 {
40@@ -95,19 +95,16 @@
41 static gboolean
42 should_enable_a11y (void)
43 {
44- GConfClient *client = NULL;
45+ GSettings *desktop_settings = NULL;
46 gboolean value = FALSE;
47- GError *error = NULL;
48-
49- client = gconf_client_get_default ();
50- value = gconf_client_get_bool (client, A11Y_GCONF_KEY, &error);
51- if (error != NULL)
52- {
53- g_warning ("Error getting gconf variable %s, a11y disabled by default",
54- A11Y_GCONF_KEY);
55- g_error_free (error);
56- }
57- g_object_unref (client);
58+
59+ if (!has_gsettings_schema (DESKTOP_SCHEMA))
60+ return FALSE;
61+
62+ desktop_settings = g_settings_new (DESKTOP_SCHEMA);
63+ value = g_settings_get_boolean (desktop_settings, ACCESSIBILITY_ENABLED_KEY);
64+
65+ g_object_unref (desktop_settings);
66
67 return value;
68 }
69
70=== modified file 'services/panel-a11y.c'
71--- services/panel-a11y.c 2011-06-28 10:48:51 +0000
72+++ services/panel-a11y.c 2011-07-13 17:41:35 +0000
73@@ -16,7 +16,6 @@
74 * Authored by: Rodrigo Moya <rodrigo.moya@canonical.com>
75 */
76
77-#include <gconf/gconf-client.h>
78 #include <gio/gio.h>
79
80 #include "panel-a11y.h"
81@@ -25,10 +24,14 @@
82 static gboolean a11y_initialized = FALSE;
83
84 #define INIT_METHOD "gnome_accessibility_module_init"
85-#define A11Y_GCONF_KEY "/desktop/gnome/interface/accessibility"
86+#define DESKTOP_SCHEMA "org.gnome.desktop.interface"
87+#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility"
88 #define AT_SPI_SCHEMA "org.a11y.atspi"
89 #define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location"
90
91+
92+/* This method is required because g_setting_new abort if the schema
93+ is not present. */
94 static gboolean
95 has_gsettings_schema (const gchar *schema)
96 {
97@@ -36,8 +39,6 @@
98 gboolean found = FALSE;
99 int i = 0;
100
101- /* we need to check if AT_SPI_SCHEMA is present as g_settings_new
102- could abort if the schema is not here*/
103 list_schemas = g_settings_list_schemas ();
104 for (i = 0; list_schemas [i]; i++)
105 {
106@@ -54,19 +55,16 @@
107 static gboolean
108 should_enable_a11y (void)
109 {
110- GConfClient *client = NULL;
111+ GSettings *desktop_settings = NULL;
112 gboolean value = FALSE;
113- GError *error = NULL;
114-
115- client = gconf_client_get_default ();
116- value = gconf_client_get_bool (client, A11Y_GCONF_KEY, &error);
117- if (error != NULL)
118- {
119- g_warning ("Error getting gconf variable %s, a11y disabled by default",
120- A11Y_GCONF_KEY);
121- g_error_free (error);
122- }
123- g_object_unref (client);
124+
125+ if (!has_gsettings_schema (DESKTOP_SCHEMA))
126+ return FALSE;
127+
128+ desktop_settings = g_settings_new (DESKTOP_SCHEMA);
129+ value = g_settings_get_boolean (desktop_settings, ACCESSIBILITY_ENABLED_KEY);
130+
131+ g_object_unref (desktop_settings);
132
133 return value;
134 }