Merge lp:~parnold-x/wingpanel-indicator-a11y/session-support into lp:~wingpanel-devs/wingpanel-indicator-a11y/trunk

Proposed by Djax
Status: Merged
Approved by: Felipe Escoto
Approved revision: 3
Merged at revision: 3
Proposed branch: lp:~parnold-x/wingpanel-indicator-a11y/session-support
Merge into: lp:~wingpanel-devs/wingpanel-indicator-a11y/trunk
Diff against target: 420 lines (+242/-107)
5 files modified
src/CMakeLists.txt (+5/-1)
src/GreeterWidget.vala (+118/-0)
src/Indicator.vala (+15/-106)
src/SessionSettings.vala (+68/-0)
src/SessionWidget.vala (+36/-0)
To merge this branch: bzr merge lp:~parnold-x/wingpanel-indicator-a11y/session-support
Reviewer Review Type Date Requested Status
Felipe Escoto Approve
Review via email: mp+270599@code.launchpad.net

Commit message

wingpanel session support

To post a comment you must log in.
3. By Djax

support wingpanel session

Revision history for this message
Felipe Escoto (philip.scott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2015-08-04 20:48:42 +0000
3+++ src/CMakeLists.txt 2015-09-09 21:31:57 +0000
4@@ -1,7 +1,7 @@
5 find_package (PkgConfig)
6
7 # Add all your dependencies to the list below
8-pkg_check_modules (DEPS REQUIRED gthread-2.0 gtk+-3.0 wingpanel-2.0)
9+pkg_check_modules (DEPS REQUIRED gthread-2.0 gtk+-3.0 wingpanel-2.0 granite)
10
11 add_definitions (${DEPS_CFLAGS})
12 link_directories (${DEPS_LIBRARY_DIRS})
13@@ -13,11 +13,15 @@
14 include (ValaPrecompile)
15 # Add all your vala files and requires packages to the List below to include them in the build
16 vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
17+ GreeterWidget.vala
18 Indicator.vala
19+ SessionSettings.vala
20+ SessionWidget.vala
21 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
22 PACKAGES
23 wingpanel-2.0
24 posix
25+ granite
26 OPTIONS
27 --thread
28 )
29
30=== added file 'src/GreeterWidget.vala'
31--- src/GreeterWidget.vala 1970-01-01 00:00:00 +0000
32+++ src/GreeterWidget.vala 2015-09-09 21:31:57 +0000
33@@ -0,0 +1,118 @@
34+/*
35+ * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
36+ *
37+ * This program is free software; you can redistribute it and/or
38+ * modify it under the terms of the GNU General Public
39+ * License as published by the Free Software Foundation; either
40+ * version 2 of the License, or (at your option) any later version.
41+ *
42+ * This program is distributed in the hope that it will be useful,
43+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
44+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45+ * General Public License for more details.
46+ *
47+ * You should have received a copy of the GNU General Public
48+ * License along with this program; if not, write to the
49+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
50+ * Boston, MA 02111-1307, USA.
51+ */
52+
53+public class A11Y.GreeterWidget : Gtk.Grid {
54+ KeyFile settings;
55+ Gtk.Window keyboard_window;
56+ int keyboard_pid;
57+
58+ public GreeterWidget () {
59+ settings = new KeyFile ();
60+
61+ /*
62+ * we could load /etc/lightdm/pantheon-greeter.conf but all keys are commented there.
63+ * setting defaults instead to prevent needless warnings
64+ */
65+ settings.set_boolean ("greeter", "high-contrast", false);
66+ settings.set_boolean ("greeter", "onscreen-keyboard", false);
67+ /*
68+ * try {
69+ * settings.load_from_file ("/etc/lightdm/pantheon-greeter.conf",
70+ * KeyFileFlags.KEEP_COMMENTS);
71+ * } catch (Error e) {
72+ * warning (e.message);
73+ * }
74+ */
75+ int position = 0;
76+ var onscreen_keyboard = new Wingpanel.Widgets.Switch (_("Onscreen Keyboard"), false);
77+ onscreen_keyboard.switched.connect (() => {
78+ toggle_keyboard (onscreen_keyboard.get_active ());
79+ });
80+ attach (onscreen_keyboard, 0, position++, 1, 1);
81+ try {
82+ onscreen_keyboard.set_active (settings.get_boolean ("greeter", "onscreen-keyboard"));
83+ } catch (Error e) {
84+ warning (e.message);
85+ }
86+
87+ var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
88+ high_contrast.switched.connect (() => {
89+ Gtk.Settings.get_default ().gtk_theme_name = high_contrast.get_active () ? "HighContrastInverse" : "elementary";
90+ settings.set_boolean ("greeter", "high-contrast", high_contrast.get_active ());
91+ });
92+ attach (high_contrast, 0, position++, 1, 1);
93+ try {
94+ high_contrast.set_active (settings.get_boolean ("greeter", "high-contrast"));
95+ } catch (Error e) {
96+ warning (e.message);
97+ }
98+ }
99+
100+ ~GreeterWidget () {
101+ if (keyboard_pid != 0) {
102+ Posix.kill (keyboard_pid, Posix.SIGKILL);
103+ int status;
104+ Posix.waitpid (keyboard_pid, out status, 0);
105+ keyboard_pid = 0;
106+ }
107+ }
108+
109+ private void toggle_keyboard (bool active) {
110+ if (keyboard_window != null) {
111+ keyboard_window.visible = active;
112+ settings.set_boolean ("greeter", "onscreen-keyboard", active);
113+
114+ return;
115+ }
116+
117+ int id = 0;
118+ int onboard_stdout_fd;
119+
120+ try {
121+ string[] argv;
122+ Shell.parse_argv ("onboard --xid", out argv);
123+ Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out keyboard_pid, null, out onboard_stdout_fd, null);
124+
125+ var f = FileStream.fdopen (onboard_stdout_fd, "r");
126+ var stdout_text = new char[1024];
127+ f.gets (stdout_text);
128+ id = int.parse ((string)stdout_text);
129+ } catch (Error e) {
130+ warning (e.message);
131+ }
132+
133+ var keyboard_socket = new Gtk.Socket ();
134+ keyboard_window = new Gtk.Window ();
135+ keyboard_window.accept_focus = false;
136+ keyboard_window.focus_on_map = false;
137+ keyboard_window.add (keyboard_socket);
138+ keyboard_socket.add_id (id);
139+
140+ var screen = Gdk.Screen.get_default ();
141+ var monitor = screen.get_primary_monitor ();
142+ Gdk.Rectangle geom;
143+ screen.get_monitor_geometry (monitor, out geom);
144+ keyboard_window.move (geom.x, geom.y + geom.height - 200);
145+ keyboard_window.resize (geom.width, 200);
146+ keyboard_window.set_keep_above (true);
147+
148+ keyboard_window.show_all ();
149+ settings.set_boolean ("greeter", "onscreen-keyboard", true);
150+ }
151+}
152
153=== modified file 'src/Indicator.vala'
154--- src/Indicator.vala 2015-08-04 20:33:38 +0000
155+++ src/Indicator.vala 2015-09-09 21:31:57 +0000
156@@ -21,41 +21,13 @@
157 Wingpanel.Widgets.OverlayIcon panel_icon;
158 Gtk.Grid main_grid;
159
160- KeyFile settings;
161- Gtk.Window keyboard_window;
162- int keyboard_pid;
163+ public Wingpanel.IndicatorManager.ServerType server_type { get; construct set; }
164
165- public Indicator () {
166+ public Indicator (Wingpanel.IndicatorManager.ServerType indicator_server_type) {
167 Object (code_name: "a11y",
168 display_name: _("Accessibility"),
169- description: _("Accessibility indicator"));
170-
171- this.visible = true;
172- settings = new KeyFile ();
173-
174- /*
175- * we could load /etc/lightdm/pantheon-greeter.conf but all keys are commented there.
176- * setting defaults instead to prevent needless warnings
177- */
178- settings.set_boolean ("greeter", "high-contrast", false);
179- settings.set_boolean ("greeter", "onscreen-keyboard", false);
180- /*
181- * try {
182- * settings.load_from_file ("/etc/lightdm/pantheon-greeter.conf",
183- * KeyFileFlags.KEEP_COMMENTS);
184- * } catch (Error e) {
185- * warning (e.message);
186- * }
187- */
188- }
189-
190- ~Indicator () {
191- if (keyboard_pid != 0) {
192- Posix.kill (keyboard_pid, Posix.SIGKILL);
193- int status;
194- Posix.waitpid (keyboard_pid, out status, 0);
195- keyboard_pid = 0;
196- }
197+ description: _("Accessibility indicator"),
198+ server_type: indicator_server_type);
199 }
200
201 public override Gtk.Widget get_display_widget () {
202@@ -68,79 +40,22 @@
203
204 public override Gtk.Widget? get_widget () {
205 if (main_grid == null) {
206- int position = 0;
207- main_grid = new Gtk.Grid ();
208-
209- var onscreen_keyboard = new Wingpanel.Widgets.Switch (_("Onscreen Keyboard"), false);
210- onscreen_keyboard.switched.connect (() => {
211- toggle_keyboard (onscreen_keyboard.get_active ());
212- });
213- main_grid.attach (onscreen_keyboard, 0, position++, 1, 1);
214- try {
215- onscreen_keyboard.set_active (settings.get_boolean ("greeter", "onscreen-keyboard"));
216- } catch (Error e) {
217- warning (e.message);
218- }
219-
220- var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
221- high_contrast.switched.connect (() => {
222- Gtk.Settings.get_default ().gtk_theme_name = high_contrast.get_active () ? "HighContrastInverse" : "elementary";
223- settings.set_boolean ("greeter", "high-contrast", high_contrast.get_active ());
224- });
225- main_grid.attach (high_contrast, 0, position++, 1, 1);
226- try {
227- high_contrast.set_active (settings.get_boolean ("greeter", "high-contrast"));
228- } catch (Error e) {
229- warning (e.message);
230+ if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) {
231+ this.visible = true;
232+ main_grid = new GreeterWidget ();
233+ } else {
234+ var visible_settings = new A11ySettings ();
235+ this.visible = visible_settings.always_show_universal_access_status;
236+ visible_settings.notify.connect (() => {
237+ this.visible = visible_settings.always_show_universal_access_status;
238+ });
239+ main_grid = new SessionWidget ();
240 }
241 }
242
243 return main_grid;
244 }
245
246- private void toggle_keyboard (bool active) {
247- if (keyboard_window != null) {
248- keyboard_window.visible = active;
249- settings.set_boolean ("greeter", "onscreen-keyboard", active);
250-
251- return;
252- }
253-
254- int id = 0;
255- int onboard_stdout_fd;
256-
257- try {
258- string[] argv;
259- Shell.parse_argv ("onboard --xid", out argv);
260- Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out keyboard_pid, null, out onboard_stdout_fd, null);
261-
262- var f = FileStream.fdopen (onboard_stdout_fd, "r");
263- var stdout_text = new char[1024];
264- f.gets (stdout_text);
265- id = int.parse ((string)stdout_text);
266- } catch (Error e) {
267- warning (e.message);
268- }
269-
270- var keyboard_socket = new Gtk.Socket ();
271- keyboard_window = new Gtk.Window ();
272- keyboard_window.accept_focus = false;
273- keyboard_window.focus_on_map = false;
274- keyboard_window.add (keyboard_socket);
275- keyboard_socket.add_id (id);
276-
277- var screen = Gdk.Screen.get_default ();
278- var monitor = screen.get_primary_monitor ();
279- Gdk.Rectangle geom;
280- screen.get_monitor_geometry (monitor, out geom);
281- keyboard_window.move (geom.x, geom.y + geom.height - 200);
282- keyboard_window.resize (geom.width, 200);
283- keyboard_window.set_keep_above (true);
284-
285- keyboard_window.show_all ();
286- settings.set_boolean ("greeter", "onscreen-keyboard", true);
287- }
288-
289 public override void opened () {
290 }
291
292@@ -150,11 +65,5 @@
293
294 public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {
295 debug ("Activating Accessibility Indicator");
296-
297- /* Only show a11y in greeter */
298- if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) {
299- return new A11Y.Indicator ();
300- }
301-
302- return null;
303+ return new A11Y.Indicator (server_type);
304 }
305\ No newline at end of file
306
307=== added file 'src/SessionSettings.vala'
308--- src/SessionSettings.vala 1970-01-01 00:00:00 +0000
309+++ src/SessionSettings.vala 2015-09-09 21:31:57 +0000
310@@ -0,0 +1,68 @@
311+/*
312+ * Copyright (c) 2015 Pantheon Developers (https://launchpad.net/switchboardswitchboard-plug-a11y)
313+ *
314+ * This library is free software; you can redistribute it and/or
315+ * modify it under the terms of the GNU Library General Public
316+ * License as published by the Free Software Foundation; either
317+ * version 3 of the License, or (at your option) any later version.
318+ *
319+ * This library is distributed in the hope that it will be useful,
320+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
321+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
322+ * Library General Public License for more details.
323+ *
324+ * You should have received a copy of the GNU Library General Public
325+ * License along with this library; if not, write to the
326+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
327+ * Boston, MA 02111-1307, USA.Actualy, if you have windows just use
328+ *
329+ * Authored by: Felipe Escoto <felescoto95@hotmail.com>
330+ */
331+
332+public class A11Y.DesktopInterface : Granite.Services.Settings {
333+ private const string HIGH_CONTRAST_THEME = "HighContrast";
334+
335+ public string gtk_theme { get; set; }
336+ public string icon_theme { get; set; }
337+
338+ private WmSettings wm_settings;
339+
340+ public DesktopInterface () {
341+ base ("org.gnome.desktop.interface");
342+ wm_settings = new WmSettings ();
343+ }
344+
345+ public bool get_high_contrast () {
346+ if (gtk_theme == HIGH_CONTRAST_THEME) {
347+ return true;
348+ } else {
349+ return false;
350+ }
351+ }
352+
353+ public void set_high_contrast (bool state) {
354+ if (state) {
355+ gtk_theme = HIGH_CONTRAST_THEME;
356+ icon_theme = HIGH_CONTRAST_THEME;
357+ } else {
358+ schema.reset ("gtk-theme");
359+ schema.reset ("icon-theme");
360+ wm_settings.schema.reset ("theme");
361+ }
362+ }
363+}
364+
365+public class A11Y.A11ySettings : Granite.Services.Settings {
366+ public bool always_show_universal_access_status { get; set; }
367+
368+ public A11ySettings () {
369+ base ("org.gnome.desktop.a11y");
370+ }
371+}
372+
373+public class A11Y.WmSettings : Granite.Services.Settings {
374+ public string? theme { get; set; }
375+ public WmSettings () {
376+ base ("org.gnome.desktop.wm.preferences");
377+ }
378+}
379\ No newline at end of file
380
381=== added file 'src/SessionWidget.vala'
382--- src/SessionWidget.vala 1970-01-01 00:00:00 +0000
383+++ src/SessionWidget.vala 2015-09-09 21:31:57 +0000
384@@ -0,0 +1,36 @@
385+/*
386+ * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
387+ *
388+ * This program is free software; you can redistribute it and/or
389+ * modify it under the terms of the GNU General Public
390+ * License as published by the Free Software Foundation; either
391+ * version 2 of the License, or (at your option) any later version.
392+ *
393+ * This program is distributed in the hope that it will be useful,
394+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
395+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
396+ * General Public License for more details.
397+ *
398+ * You should have received a copy of the GNU General Public
399+ * License along with this program; if not, write to the
400+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
401+ * Boston, MA 02111-1307, USA.
402+ */
403+
404+public class A11Y.SessionWidget : Gtk.Grid {
405+
406+ public SessionWidget () {
407+ var desktop_interface = new DesktopInterface ();
408+
409+ var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
410+ high_contrast.switched.connect (() => {
411+ desktop_interface.set_high_contrast (high_contrast.get_active ());
412+ });
413+ attach (high_contrast, 0, 0, 1, 1);
414+ high_contrast.set_active (desktop_interface.get_high_contrast ());
415+ desktop_interface.notify["gtk-theme"].connect (() => {
416+ high_contrast.set_active (desktop_interface.get_high_contrast ());
417+ });
418+ }
419+
420+}

Subscribers

People subscribed via source and target branches

to all changes: