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
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-08-04 20:48:42 +0000
+++ src/CMakeLists.txt 2015-09-09 21:31:57 +0000
@@ -1,7 +1,7 @@
1find_package (PkgConfig)1find_package (PkgConfig)
22
3# Add all your dependencies to the list below3# Add all your dependencies to the list below
4pkg_check_modules (DEPS REQUIRED gthread-2.0 gtk+-3.0 wingpanel-2.0)4pkg_check_modules (DEPS REQUIRED gthread-2.0 gtk+-3.0 wingpanel-2.0 granite)
55
6add_definitions (${DEPS_CFLAGS})6add_definitions (${DEPS_CFLAGS})
7link_directories (${DEPS_LIBRARY_DIRS})7link_directories (${DEPS_LIBRARY_DIRS})
@@ -13,11 +13,15 @@
13include (ValaPrecompile)13include (ValaPrecompile)
14# Add all your vala files and requires packages to the List below to include them in the build14# Add all your vala files and requires packages to the List below to include them in the build
15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
16 GreeterWidget.vala
16 Indicator.vala17 Indicator.vala
18 SessionSettings.vala
19 SessionWidget.vala
17 ${CMAKE_CURRENT_BINARY_DIR}/config.vala20 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
18PACKAGES21PACKAGES
19 wingpanel-2.022 wingpanel-2.0
20 posix23 posix
24 granite
21OPTIONS25OPTIONS
22 --thread26 --thread
23)27)
2428
=== added file 'src/GreeterWidget.vala'
--- src/GreeterWidget.vala 1970-01-01 00:00:00 +0000
+++ src/GreeterWidget.vala 2015-09-09 21:31:57 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20public class A11Y.GreeterWidget : Gtk.Grid {
21 KeyFile settings;
22 Gtk.Window keyboard_window;
23 int keyboard_pid;
24
25 public GreeterWidget () {
26 settings = new KeyFile ();
27
28 /*
29 * we could load /etc/lightdm/pantheon-greeter.conf but all keys are commented there.
30 * setting defaults instead to prevent needless warnings
31 */
32 settings.set_boolean ("greeter", "high-contrast", false);
33 settings.set_boolean ("greeter", "onscreen-keyboard", false);
34 /*
35 * try {
36 * settings.load_from_file ("/etc/lightdm/pantheon-greeter.conf",
37 * KeyFileFlags.KEEP_COMMENTS);
38 * } catch (Error e) {
39 * warning (e.message);
40 * }
41 */
42 int position = 0;
43 var onscreen_keyboard = new Wingpanel.Widgets.Switch (_("Onscreen Keyboard"), false);
44 onscreen_keyboard.switched.connect (() => {
45 toggle_keyboard (onscreen_keyboard.get_active ());
46 });
47 attach (onscreen_keyboard, 0, position++, 1, 1);
48 try {
49 onscreen_keyboard.set_active (settings.get_boolean ("greeter", "onscreen-keyboard"));
50 } catch (Error e) {
51 warning (e.message);
52 }
53
54 var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
55 high_contrast.switched.connect (() => {
56 Gtk.Settings.get_default ().gtk_theme_name = high_contrast.get_active () ? "HighContrastInverse" : "elementary";
57 settings.set_boolean ("greeter", "high-contrast", high_contrast.get_active ());
58 });
59 attach (high_contrast, 0, position++, 1, 1);
60 try {
61 high_contrast.set_active (settings.get_boolean ("greeter", "high-contrast"));
62 } catch (Error e) {
63 warning (e.message);
64 }
65 }
66
67 ~GreeterWidget () {
68 if (keyboard_pid != 0) {
69 Posix.kill (keyboard_pid, Posix.SIGKILL);
70 int status;
71 Posix.waitpid (keyboard_pid, out status, 0);
72 keyboard_pid = 0;
73 }
74 }
75
76 private void toggle_keyboard (bool active) {
77 if (keyboard_window != null) {
78 keyboard_window.visible = active;
79 settings.set_boolean ("greeter", "onscreen-keyboard", active);
80
81 return;
82 }
83
84 int id = 0;
85 int onboard_stdout_fd;
86
87 try {
88 string[] argv;
89 Shell.parse_argv ("onboard --xid", out argv);
90 Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out keyboard_pid, null, out onboard_stdout_fd, null);
91
92 var f = FileStream.fdopen (onboard_stdout_fd, "r");
93 var stdout_text = new char[1024];
94 f.gets (stdout_text);
95 id = int.parse ((string)stdout_text);
96 } catch (Error e) {
97 warning (e.message);
98 }
99
100 var keyboard_socket = new Gtk.Socket ();
101 keyboard_window = new Gtk.Window ();
102 keyboard_window.accept_focus = false;
103 keyboard_window.focus_on_map = false;
104 keyboard_window.add (keyboard_socket);
105 keyboard_socket.add_id (id);
106
107 var screen = Gdk.Screen.get_default ();
108 var monitor = screen.get_primary_monitor ();
109 Gdk.Rectangle geom;
110 screen.get_monitor_geometry (monitor, out geom);
111 keyboard_window.move (geom.x, geom.y + geom.height - 200);
112 keyboard_window.resize (geom.width, 200);
113 keyboard_window.set_keep_above (true);
114
115 keyboard_window.show_all ();
116 settings.set_boolean ("greeter", "onscreen-keyboard", true);
117 }
118}
0119
=== modified file 'src/Indicator.vala'
--- src/Indicator.vala 2015-08-04 20:33:38 +0000
+++ src/Indicator.vala 2015-09-09 21:31:57 +0000
@@ -21,41 +21,13 @@
21 Wingpanel.Widgets.OverlayIcon panel_icon;21 Wingpanel.Widgets.OverlayIcon panel_icon;
22 Gtk.Grid main_grid;22 Gtk.Grid main_grid;
2323
24 KeyFile settings;24 public Wingpanel.IndicatorManager.ServerType server_type { get; construct set; }
25 Gtk.Window keyboard_window;
26 int keyboard_pid;
2725
28 public Indicator () {26 public Indicator (Wingpanel.IndicatorManager.ServerType indicator_server_type) {
29 Object (code_name: "a11y",27 Object (code_name: "a11y",
30 display_name: _("Accessibility"),28 display_name: _("Accessibility"),
31 description: _("Accessibility indicator"));29 description: _("Accessibility indicator"),
3230 server_type: indicator_server_type);
33 this.visible = true;
34 settings = new KeyFile ();
35
36 /*
37 * we could load /etc/lightdm/pantheon-greeter.conf but all keys are commented there.
38 * setting defaults instead to prevent needless warnings
39 */
40 settings.set_boolean ("greeter", "high-contrast", false);
41 settings.set_boolean ("greeter", "onscreen-keyboard", false);
42 /*
43 * try {
44 * settings.load_from_file ("/etc/lightdm/pantheon-greeter.conf",
45 * KeyFileFlags.KEEP_COMMENTS);
46 * } catch (Error e) {
47 * warning (e.message);
48 * }
49 */
50 }
51
52 ~Indicator () {
53 if (keyboard_pid != 0) {
54 Posix.kill (keyboard_pid, Posix.SIGKILL);
55 int status;
56 Posix.waitpid (keyboard_pid, out status, 0);
57 keyboard_pid = 0;
58 }
59 }31 }
6032
61 public override Gtk.Widget get_display_widget () {33 public override Gtk.Widget get_display_widget () {
@@ -68,79 +40,22 @@
6840
69 public override Gtk.Widget? get_widget () {41 public override Gtk.Widget? get_widget () {
70 if (main_grid == null) {42 if (main_grid == null) {
71 int position = 0;43 if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) {
72 main_grid = new Gtk.Grid ();44 this.visible = true;
7345 main_grid = new GreeterWidget ();
74 var onscreen_keyboard = new Wingpanel.Widgets.Switch (_("Onscreen Keyboard"), false);46 } else {
75 onscreen_keyboard.switched.connect (() => {47 var visible_settings = new A11ySettings ();
76 toggle_keyboard (onscreen_keyboard.get_active ());48 this.visible = visible_settings.always_show_universal_access_status;
77 });49 visible_settings.notify.connect (() => {
78 main_grid.attach (onscreen_keyboard, 0, position++, 1, 1);50 this.visible = visible_settings.always_show_universal_access_status;
79 try {51 });
80 onscreen_keyboard.set_active (settings.get_boolean ("greeter", "onscreen-keyboard"));52 main_grid = new SessionWidget ();
81 } catch (Error e) {
82 warning (e.message);
83 }
84
85 var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
86 high_contrast.switched.connect (() => {
87 Gtk.Settings.get_default ().gtk_theme_name = high_contrast.get_active () ? "HighContrastInverse" : "elementary";
88 settings.set_boolean ("greeter", "high-contrast", high_contrast.get_active ());
89 });
90 main_grid.attach (high_contrast, 0, position++, 1, 1);
91 try {
92 high_contrast.set_active (settings.get_boolean ("greeter", "high-contrast"));
93 } catch (Error e) {
94 warning (e.message);
95 }53 }
96 }54 }
9755
98 return main_grid;56 return main_grid;
99 }57 }
10058
101 private void toggle_keyboard (bool active) {
102 if (keyboard_window != null) {
103 keyboard_window.visible = active;
104 settings.set_boolean ("greeter", "onscreen-keyboard", active);
105
106 return;
107 }
108
109 int id = 0;
110 int onboard_stdout_fd;
111
112 try {
113 string[] argv;
114 Shell.parse_argv ("onboard --xid", out argv);
115 Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out keyboard_pid, null, out onboard_stdout_fd, null);
116
117 var f = FileStream.fdopen (onboard_stdout_fd, "r");
118 var stdout_text = new char[1024];
119 f.gets (stdout_text);
120 id = int.parse ((string)stdout_text);
121 } catch (Error e) {
122 warning (e.message);
123 }
124
125 var keyboard_socket = new Gtk.Socket ();
126 keyboard_window = new Gtk.Window ();
127 keyboard_window.accept_focus = false;
128 keyboard_window.focus_on_map = false;
129 keyboard_window.add (keyboard_socket);
130 keyboard_socket.add_id (id);
131
132 var screen = Gdk.Screen.get_default ();
133 var monitor = screen.get_primary_monitor ();
134 Gdk.Rectangle geom;
135 screen.get_monitor_geometry (monitor, out geom);
136 keyboard_window.move (geom.x, geom.y + geom.height - 200);
137 keyboard_window.resize (geom.width, 200);
138 keyboard_window.set_keep_above (true);
139
140 keyboard_window.show_all ();
141 settings.set_boolean ("greeter", "onscreen-keyboard", true);
142 }
143
144 public override void opened () {59 public override void opened () {
145 }60 }
14661
@@ -150,11 +65,5 @@
15065
151public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {66public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {
152 debug ("Activating Accessibility Indicator");67 debug ("Activating Accessibility Indicator");
15368 return new A11Y.Indicator (server_type);
154 /* Only show a11y in greeter */
155 if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) {
156 return new A11Y.Indicator ();
157 }
158
159 return null;
160}69}
161\ No newline at end of file70\ No newline at end of file
16271
=== added file 'src/SessionSettings.vala'
--- src/SessionSettings.vala 1970-01-01 00:00:00 +0000
+++ src/SessionSettings.vala 2015-09-09 21:31:57 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright (c) 2015 Pantheon Developers (https://launchpad.net/switchboardswitchboard-plug-a11y)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.Actualy, if you have windows just use
18 *
19 * Authored by: Felipe Escoto <felescoto95@hotmail.com>
20 */
21
22public class A11Y.DesktopInterface : Granite.Services.Settings {
23 private const string HIGH_CONTRAST_THEME = "HighContrast";
24
25 public string gtk_theme { get; set; }
26 public string icon_theme { get; set; }
27
28 private WmSettings wm_settings;
29
30 public DesktopInterface () {
31 base ("org.gnome.desktop.interface");
32 wm_settings = new WmSettings ();
33 }
34
35 public bool get_high_contrast () {
36 if (gtk_theme == HIGH_CONTRAST_THEME) {
37 return true;
38 } else {
39 return false;
40 }
41 }
42
43 public void set_high_contrast (bool state) {
44 if (state) {
45 gtk_theme = HIGH_CONTRAST_THEME;
46 icon_theme = HIGH_CONTRAST_THEME;
47 } else {
48 schema.reset ("gtk-theme");
49 schema.reset ("icon-theme");
50 wm_settings.schema.reset ("theme");
51 }
52 }
53}
54
55public class A11Y.A11ySettings : Granite.Services.Settings {
56 public bool always_show_universal_access_status { get; set; }
57
58 public A11ySettings () {
59 base ("org.gnome.desktop.a11y");
60 }
61}
62
63public class A11Y.WmSettings : Granite.Services.Settings {
64 public string? theme { get; set; }
65 public WmSettings () {
66 base ("org.gnome.desktop.wm.preferences");
67 }
68}
0\ No newline at end of file69\ No newline at end of file
170
=== added file 'src/SessionWidget.vala'
--- src/SessionWidget.vala 1970-01-01 00:00:00 +0000
+++ src/SessionWidget.vala 2015-09-09 21:31:57 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20public class A11Y.SessionWidget : Gtk.Grid {
21
22 public SessionWidget () {
23 var desktop_interface = new DesktopInterface ();
24
25 var high_contrast = new Wingpanel.Widgets.Switch (_("HighContrast"), false);
26 high_contrast.switched.connect (() => {
27 desktop_interface.set_high_contrast (high_contrast.get_active ());
28 });
29 attach (high_contrast, 0, 0, 1, 1);
30 high_contrast.set_active (desktop_interface.get_high_contrast ());
31 desktop_interface.notify["gtk-theme"].connect (() => {
32 high_contrast.set_active (desktop_interface.get_high_contrast ());
33 });
34 }
35
36}

Subscribers

People subscribed via source and target branches

to all changes: