217.2.1
by Raphael Isemann
codestyle and license fixes |
1 |
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
|
2 |
/***
|
|
3 |
BEGIN LICENSE
|
|
4 |
||
5 |
Copyright (C) 2011-2013 elementary Developers
|
|
6 |
||
7 |
This program is free software: you can redistribute it and/or modify it
|
|
8 |
under the terms of the GNU Lesser General Public License version 3, as published
|
|
9 |
by the Free Software Foundation.
|
|
10 |
||
11 |
This program is distributed in the hope that it will be useful, but
|
|
12 |
WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
13 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
14 |
PURPOSE. See the GNU General Public License for more details.
|
|
15 |
||
16 |
You should have received a copy of the GNU General Public License along
|
|
17 |
with this program. If not, see <http://www.gnu.org/licenses/>
|
|
18 |
||
19 |
END LICENSE
|
|
20 |
***/
|
|
21 |
||
20
by Tom Beckmann
Forgot another file... |
22 |
/*big parts stolen from unity-greeter ;) */
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
23 |
|
24 |
public class IndicatorMenuItem : Gtk.MenuItem { |
|
25 |
||
20
by Tom Beckmann
Forgot another file... |
26 |
public unowned Indicator.ObjectEntry entry; |
27 |
private Gtk.Box hbox; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
28 |
|
29 |
public IndicatorMenuItem (Indicator.ObjectEntry _entry) { |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
30 |
entry = _entry; |
31 |
hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
|
32 |
add (this.hbox); |
|
33 |
hbox.show (); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
34 |
|
20
by Tom Beckmann
Forgot another file... |
35 |
if (entry.image != null) { |
70
by tombeckmann at online
A major rewrite and restructure of the code |
36 |
var img = entry.image; |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
37 |
|
29
by Tom Beckmann
Fixed bug #1002607 |
38 |
img.show.connect (visibility_changed_cb); |
39 |
img.hide.connect (visibility_changed_cb); |
|
40 |
hbox.pack_start (img, false, false, 0); |
|
41 |
img.show (); |
|
20
by Tom Beckmann
Forgot another file... |
42 |
}
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
43 |
|
20
by Tom Beckmann
Forgot another file... |
44 |
if (entry.accessible_desc != null) |
45 |
get_accessible ().set_name (entry.accessible_desc); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
46 |
|
20
by Tom Beckmann
Forgot another file... |
47 |
if (entry.menu != null) |
48 |
submenu = entry.menu; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
49 |
|
20
by Tom Beckmann
Forgot another file... |
50 |
if (has_visible_child ()) |
51 |
show (); |
|
52 |
}
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
53 |
|
20
by Tom Beckmann
Forgot another file... |
54 |
public bool has_visible_child () { |
55 |
return (entry.image != null && entry.image.get_visible ()) || |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
56 |
(entry.label != null && entry.label.get_visible ()); |
57 |
}
|
|
58 |
||
59 |
public void visibility_changed_cb (Gtk.Widget widget) { |
|
60 |
visible = has_visible_child (); |
|
61 |
}
|
|
20
by Tom Beckmann
Forgot another file... |
62 |
}
|
63 |
||
64 |
public class Indicators : GtkClutter.Actor { |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
65 |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
66 |
int keyboard_pid; |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
67 |
|
230
by Raphael Isemann
Fixed a few focus issues and applyingn the corrent name to manual login now |
68 |
Gtk.MenuItem power; |
69 |
Gtk.MenuItem poweroff; |
|
70 |
||
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
71 |
int margin_to_right = 5; |
72 |
||
224
by Raphael Isemann
First version of the new UI |
73 |
Gtk.MenuItem keyboard_menuitem; |
74 |
Gtk.Label keyboard_label; |
|
75 |
||
20
by Tom Beckmann
Forgot another file... |
76 |
public Gtk.MenuBar bar; |
77 |
private List<Indicator.Object> indicator_objects; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
78 |
|
20
by Tom Beckmann
Forgot another file... |
79 |
public async void start () { |
80 |
string[] disabled = {"org.gnome.settings-daemon.plugins.background", |
|
81 |
"org.gnome.settings-daemon.plugins.clipboard", |
|
82 |
"org.gnome.settings-daemon.plugins.font", |
|
83 |
"org.gnome.settings-daemon.plugins.gconf", |
|
84 |
"org.gnome.settings-daemon.plugins.gsdwacom", |
|
85 |
"org.gnome.settings-daemon.plugins.housekeeping", |
|
86 |
"org.gnome.settings-daemon.plugins.keybindings", |
|
87 |
"org.gnome.settings-daemon.plugins.keyboard", |
|
88 |
"org.gnome.settings-daemon.plugins.media-keys", |
|
89 |
"org.gnome.settings-daemon.plugins.mouse", |
|
90 |
"org.gnome.settings-daemon.plugins.print-notifications", |
|
91 |
"org.gnome.settings-daemon.plugins.smartcard", |
|
92 |
"org.gnome.settings-daemon.plugins.sound", |
|
93 |
"org.gnome.settings-daemon.plugins.wacom", |
|
94 |
"org.gnome.settings-daemon.plugins.xsettings"}; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
95 |
|
20
by Tom Beckmann
Forgot another file... |
96 |
string[] enabled = {"org.gnome.settings-daemon.plugins.a11y-keyboard", |
97 |
"org.gnome.settings-daemon.plugins.a11y-settings", |
|
98 |
"org.gnome.settings-daemon.plugins.color", |
|
99 |
"org.gnome.settings-daemon.plugins.cursor", |
|
100 |
"org.gnome.settings-daemon.plugins.power", |
|
101 |
"org.gnome.settings-daemon.plugins.xrandr"}; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
102 |
|
103 |
foreach (var schema in disabled) { |
|
20
by Tom Beckmann
Forgot another file... |
104 |
toggle_schema (schema, false); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
105 |
}
|
106 |
||
107 |
foreach (var schema in enabled) { |
|
20
by Tom Beckmann
Forgot another file... |
108 |
toggle_schema (schema, true); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
109 |
}
|
110 |
||
20
by Tom Beckmann
Forgot another file... |
111 |
GLib.Bus.own_name (GLib.BusType.SESSION, "org.gnome.ScreenSaver", |
112 |
GLib.BusNameOwnerFlags.NONE); |
|
113 |
yield run (); |
|
114 |
}
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
115 |
|
116 |
~Indicators () { |
|
122.1.7
by Daniel Fore
tom is dumb for using tabs |
117 |
if (keyboard_pid != 0) { |
118 |
Posix.kill (keyboard_pid, Posix.SIGKILL); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
119 |
|
122.1.7
by Daniel Fore
tom is dumb for using tabs |
120 |
int status; |
121 |
Posix.waitpid (keyboard_pid, out status, 0); |
|
122 |
keyboard_pid = 0; |
|
123 |
}
|
|
124 |
}
|
|
125 |
||
126 |
private async void run () { |
|
127 |
try { |
|
128 |
var proxy = new GLib.DBusProxy.for_bus_sync (GLib.BusType.SESSION, |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
129 |
GLib.DBusProxyFlags.NONE, null, |
20
by Tom Beckmann
Forgot another file... |
130 |
"org.gnome.SettingsDaemon", |
131 |
"/org/gnome/SettingsDaemon", |
|
132 |
"org.gnome.SettingsDaemon", |
|
133 |
null); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
134 |
|
20
by Tom Beckmann
Forgot another file... |
135 |
yield proxy.call ("Awake", null, GLib.DBusCallFlags.NONE, -1, null); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
136 |
} catch (Error e) { |
137 |
warning ("Could not start gnome-settings-daemon: %s", e.message); |
|
138 |
}
|
|
20
by Tom Beckmann
Forgot another file... |
139 |
}
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
140 |
|
20
by Tom Beckmann
Forgot another file... |
141 |
private void toggle_schema (string name, bool active) { |
142 |
var schema = SettingsSchemaSource.get_default ().lookup (name, false); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
143 |
|
20
by Tom Beckmann
Forgot another file... |
144 |
if (schema != null) |
145 |
new Settings (name).set_boolean ("active", active); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
146 |
}
|
147 |
||
148 |
private void greeter_set_env (string key, string val) { |
|
149 |
GLib.Environment.set_variable (key, val, true); |
|
150 |
try { |
|
151 |
var proxy = new GLib.DBusProxy.for_bus_sync (GLib.BusType.SESSION, |
|
20
by Tom Beckmann
Forgot another file... |
152 |
GLib.DBusProxyFlags.NONE, null, |
153 |
"org.freedesktop.DBus", |
|
154 |
"/org/freedesktop/DBus", |
|
155 |
"org.freedesktop.DBus", |
|
156 |
null); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
157 |
|
158 |
var builder = new GLib.VariantBuilder (GLib.VariantType.ARRAY); |
|
159 |
builder.add ("{ss}", key, val); |
|
160 |
proxy.call ("UpdateActivationEnvironment", new Variant ("(a{ss})", builder), DBusCallFlags.NONE, -1, null); |
|
161 |
} catch (Error e) { |
|
162 |
warning ("Could not get set environment for indicators: %s", e.message); |
|
163 |
}
|
|
20
by Tom Beckmann
Forgot another file... |
164 |
}
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
165 |
|
166 |
Settings settings; |
|
167 |
||
168 |
public Indicators (LoginBox loginbox, Settings _settings) { |
|
169 |
settings = _settings; |
|
170 |
bar = new Gtk.MenuBar (); |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
171 |
(get_widget () as Gtk.Container).add (bar); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
172 |
|
20
by Tom Beckmann
Forgot another file... |
173 |
bar.pack_direction = Gtk.PackDirection.RTL; |
122.1.1
by Daniel Fore
make panel height 26px |
174 |
height = 26; |
232
by Raphael Isemann
UI fixes |
175 |
bar.show_all (); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
176 |
|
20
by Tom Beckmann
Forgot another file... |
177 |
var transp = new Gtk.CssProvider (); |
178 |
try { |
|
179 |
transp.load_from_data ("*{background-color:@transparent;-GtkWidget-window-dragging:false;}", -1); |
|
180 |
} catch (Error e) { warning (e.message); } |
|
181 |
bar.get_style_context ().add_provider (transp, 20000); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
182 |
|
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
183 |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
184 |
this.get_widget ().draw.connect ((ctx) => { |
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
185 |
ctx.rectangle (0, 0, bar.get_allocated_width (), bar.get_allocated_height ()); |
20
by Tom Beckmann
Forgot another file... |
186 |
ctx.set_operator (Cairo.Operator.SOURCE); |
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
187 |
ctx.set_source_rgba (0, 0, 0, 0); |
20
by Tom Beckmann
Forgot another file... |
188 |
ctx.fill (); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
189 |
|
20
by Tom Beckmann
Forgot another file... |
190 |
return false; |
191 |
});
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
192 |
|
20
by Tom Beckmann
Forgot another file... |
193 |
greeter_set_env ("INDICATOR_GREETER_MODE", "1"); |
194 |
greeter_set_env ("GIO_USE_VFS", "local"); |
|
195 |
greeter_set_env ("GVFS_DISABLE_FUSE", "1"); |
|
196 |
greeter_set_env ("RUNNING_UNDER_GDM", "1"); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
197 |
|
20
by Tom Beckmann
Forgot another file... |
198 |
var INDICATORDIR = "/usr/lib/indicators3/7"; |
70
by tombeckmann at online
A major rewrite and restructure of the code |
199 |
string[] filenames = {Path.build_filename (INDICATORDIR, "libpower.so"), |
20
by Tom Beckmann
Forgot another file... |
200 |
Path.build_filename (INDICATORDIR, "libsoundmenu.so")}; |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
201 |
|
20
by Tom Beckmann
Forgot another file... |
202 |
foreach (var filename in filenames) { |
203 |
var io = new Indicator.Object.from_file (filename); |
|
204 |
if (io == null) |
|
205 |
continue; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
206 |
|
20
by Tom Beckmann
Forgot another file... |
207 |
indicator_objects.append (io); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
208 |
io.entry_added.connect ((object, entry) => { |
20
by Tom Beckmann
Forgot another file... |
209 |
bar.append (new IndicatorMenuItem (entry)); |
210 |
});
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
211 |
|
225
by Raphael Isemann
push for testing |
212 |
io.entry_removed.connect ((object, entry) => { |
213 |
for (var i = 1; i < bar.get_children ().length (); i++) { |
|
214 |
if (bar.get_children ().nth_data (i) is IndicatorMenuItem) |
|
215 |
if (entry == (bar.get_children ().nth_data (i) as IndicatorMenuItem).entry) |
|
216 |
bar.remove (bar.get_children ().nth_data (i)); |
|
217 |
}
|
|
218 |
});
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
219 |
|
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
220 |
foreach (var entry in io.get_entries ()) { |
221 |
var widget = new IndicatorMenuItem (entry); |
|
222 |
bar.append (widget); |
|
223 |
widget.margin_right = margin_to_right; |
|
224 |
}
|
|
225
by Raphael Isemann
push for testing |
225 |
|
20
by Tom Beckmann
Forgot another file... |
226 |
}
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
227 |
|
20
by Tom Beckmann
Forgot another file... |
228 |
start (); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
229 |
|
224
by Raphael Isemann
First version of the new UI |
230 |
//keyboard layout menu
|
231 |
keyboard_menuitem = new Gtk.MenuItem (); |
|
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
232 |
keyboard_menuitem.margin_right = margin_to_right; |
224
by Raphael Isemann
First version of the new UI |
233 |
|
234 |
var keyboard_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 3); |
|
235 |
keyboard_menuitem.add (keyboard_hbox); |
|
236 |
keyboard_hbox.add ( new Gtk.Image.from_icon_name ("keyboard", Gtk.IconSize.LARGE_TOOLBAR)); |
|
237 |
keyboard_label = new Gtk.Label (""); |
|
238 |
keyboard_label.set_use_markup (true); |
|
239 |
keyboard_label.width_chars = 2; |
|
240 |
keyboard_hbox.add (keyboard_label); |
|
241 |
||
242 |
bar.append (keyboard_menuitem); |
|
243 |
keyboard_menuitem.show_all (); |
|
244 |
||
245 |
||
230
by Raphael Isemann
Fixed a few focus issues and applyingn the corrent name to manual login now |
246 |
power = new Gtk.MenuItem (); |
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
247 |
power.margin_right = margin_to_right; |
70
by tombeckmann at online
A major rewrite and restructure of the code |
248 |
try { |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
249 |
power.add (new Gtk.Image.from_pixbuf (Gtk.IconTheme.get_default ().lookup_by_gicon ( |
250 |
new GLib.ThemedIcon.with_default_fallbacks ("system-shutdown-symbolic"), 16, 0).load_symbolic ({1,1,1,1}))); |
|
251 |
} catch (Error e) { |
|
252 |
warning (e.message); |
|
253 |
}
|
|
254 |
||
70
by tombeckmann at online
A major rewrite and restructure of the code |
255 |
power.submenu = new Gtk.Menu (); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
256 |
|
230
by Raphael Isemann
Fixed a few focus issues and applyingn the corrent name to manual login now |
257 |
poweroff = new Gtk.MenuItem.with_label (_("Shutdown")); |
70
by tombeckmann at online
A major rewrite and restructure of the code |
258 |
var suspend = new Gtk.MenuItem.with_label (_("Suspend")); |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
259 |
var restart = new Gtk.MenuItem.with_label (_("Restart")); |
260 |
var hibernate = new Gtk.MenuItem.with_label (_("Hibernate")); |
|
261 |
||
70
by tombeckmann at online
A major rewrite and restructure of the code |
262 |
if (LightDM.get_can_hibernate ()) |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
263 |
power.submenu.append (hibernate); |
264 |
||
265 |
if (LightDM.get_can_suspend ()) |
|
266 |
power.submenu.append (suspend); |
|
267 |
||
268 |
if (LightDM.get_can_restart ()) |
|
269 |
power.submenu.append (restart); |
|
270 |
||
271 |
if (LightDM.get_can_shutdown ()) |
|
272 |
power.submenu.append (poweroff); |
|
273 |
||
70
by tombeckmann at online
A major rewrite and restructure of the code |
274 |
poweroff.activate.connect (() => {try { LightDM.shutdown (); } catch (Error e) { warning (e.message); }}); |
275 |
suspend.activate.connect (() => {try { LightDM.suspend (); } catch (Error e) { warning (e.message); }}); |
|
276 |
restart.activate.connect (() => {try { LightDM.restart (); } catch (Error e) { warning (e.message); }}); |
|
277 |
hibernate.activate.connect (() => {try { LightDM.hibernate (); } catch (Error e) { warning (e.message); }}); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
278 |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
279 |
bar.insert (power, 0); |
280 |
power.show_all (); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
281 |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
282 |
var accessibility = new Gtk.MenuItem (); |
229
by Raphael Isemann
Changing the whole UI. You shall contact designers before implementing their old designs. |
283 |
accessibility.margin_right = margin_to_right; |
70
by tombeckmann at online
A major rewrite and restructure of the code |
284 |
try { |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
285 |
accessibility.add (new Gtk.Image.from_pixbuf (Gtk.IconTheme.get_default ().lookup_by_gicon ( |
286 |
new GLib.ThemedIcon.with_default_fallbacks ("preferences-desktop-accessibility-symbolic"), |
|
287 |
16, 0).load_symbolic ({1,1,1,1}))); |
|
288 |
} catch (Error e) { |
|
289 |
warning (e.message); |
|
290 |
}
|
|
291 |
||
292 |
accessibility.submenu = new Gtk.Menu (); |
|
293 |
||
294 |
var keyboard = new Gtk.CheckMenuItem.with_label (_("Onscreen Keyboard")); |
|
295 |
keyboard.active = settings.get_boolean ("onscreen-keyboard"); |
|
189.2.1
by Raphael Isemann
Onboard now appears correctly |
296 |
keyboard.toggled.connect ((e) => { |
297 |
toggle_keyboard (e.active); |
|
298 |
});
|
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
299 |
accessibility.submenu.append (keyboard); |
300 |
||
301 |
var high_contrast = new Gtk.CheckMenuItem.with_label (_("HighContrast")); |
|
302 |
high_contrast.toggled.connect (() => { |
|
303 |
Gtk.Settings.get_default ().gtk_theme_name = high_contrast.active ? "HighContrastInverse" : "elementary"; |
|
224
by Raphael Isemann
First version of the new UI |
304 |
loginbox.high_contrast = high_contrast.active; |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
305 |
|
306 |
settings.set_boolean ("high-contrast", high_contrast.active); |
|
307 |
||
308 |
loginbox.get_widget ().queue_draw (); |
|
309 |
});
|
|
310 |
||
311 |
high_contrast.active = settings.get_boolean ("high-contrast"); |
|
312 |
accessibility.submenu.append (high_contrast); |
|
313 |
||
314 |
bar.append (accessibility); |
|
315 |
||
316 |
accessibility.show_all (); |
|
70
by tombeckmann at online
A major rewrite and restructure of the code |
317 |
}
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
318 |
|
230
by Raphael Isemann
Fixed a few focus issues and applyingn the corrent name to manual login now |
319 |
|
224
by Raphael Isemann
First version of the new UI |
320 |
public void user_changed_cb (PantheonUser user) { |
321 |
||
322 |
var layouts = new List <LightDM.Layout> (); |
|
323 |
if (!user.is_guest () && !user.is_manual ()) |
|
324 |
foreach (var name in user.get_lightdm_user ().get_layouts ()) |
|
325 |
{
|
|
326 |
var layout = PantheonGreeter.get_layout_by_name (name); |
|
327 |
if (layout != null) |
|
328 |
layouts.append (layout); |
|
329 |
}
|
|
330 |
set_layouts (layouts); |
|
331 |
}
|
|
332 |
||
333 |
public void set_layouts (List <LightDM.Layout> layouts) |
|
334 |
{
|
|
231
by Raphael Isemann
Display all available layouts for manual users |
335 |
if (layouts.length () == 0) { |
336 |
LightDM.get_layouts ().foreach ((entry) => { |
|
337 |
layouts.append (entry); |
|
338 |
});
|
|
339 |
}
|
|
224
by Raphael Isemann
First version of the new UI |
340 |
|
341 |
var default_item = recreate_menu (layouts); |
|
342 |
||
343 |
/* Activate first item */
|
|
344 |
if (default_item != null) |
|
345 |
{
|
|
346 |
if (default_item.active) /* Started active, have to manually trigger callback */ |
|
347 |
layout_toggled_cb (default_item); |
|
348 |
else
|
|
349 |
default_item.active = true; /* will trigger callback to do rest of work */ |
|
350 |
}
|
|
351 |
}
|
|
352 |
||
353 |
/* Returns menuitem for first layout in list */
|
|
354 |
private Gtk.RadioMenuItem recreate_menu (List <LightDM.Layout> layouts_in) |
|
355 |
{
|
|
356 |
var submenu = new Gtk.Menu (); |
|
357 |
keyboard_menuitem.set_submenu (submenu as Gtk.Widget); |
|
358 |
||
359 |
var layouts = layouts_in.copy (); |
|
360 |
layouts.sort (cmp_layout); |
|
361 |
||
362 |
Gtk.RadioMenuItem? default_item = null; |
|
363 |
Gtk.RadioMenuItem? last_item = null; |
|
364 |
foreach (var layout in layouts) |
|
365 |
{
|
|
366 |
var item = new Gtk.RadioMenuItem.with_label (last_item == null ? null : last_item.get_group (), layout.description); |
|
367 |
last_item = item; |
|
368 |
||
369 |
item.show (); |
|
370 |
||
371 |
if (layouts_in.data == layout) |
|
372 |
default_item = item; |
|
373 |
||
374 |
/* LightDM does not change its layout list during its lifetime, so this is safe */
|
|
375 |
item.set_data ("unity-greeter-layout", layout); |
|
376 |
||
377 |
item.toggled.connect (layout_toggled_cb); |
|
378 |
||
379 |
submenu.append (item); |
|
380 |
}
|
|
381 |
||
382 |
return default_item; |
|
383 |
}
|
|
384 |
||
385 |
private static int cmp_layout (LightDM.Layout? a, LightDM.Layout? b) |
|
386 |
{
|
|
387 |
if (a == null && b == null) |
|
388 |
return 0; |
|
389 |
else if (a == null) |
|
390 |
return 1; |
|
391 |
else if (b == null) |
|
392 |
return -1; |
|
393 |
else
|
|
394 |
{
|
|
395 |
/* Use a dumb, ascii comparison for now. If it turns out that some
|
|
396 |
descriptions can be in unicode, we'll have to use libicu's collation
|
|
397 |
algorithms. */
|
|
398 |
return strcmp (a.description, b.description); |
|
399 |
}
|
|
400 |
}
|
|
401 |
||
402 |
private void layout_toggled_cb (Gtk.CheckMenuItem item) { |
|
403 |
if (!item.active) |
|
404 |
return; |
|
405 |
||
406 |
var layout = item.get_data<LightDM.Layout> ("unity-greeter-layout"); |
|
407 |
if (layout == null) |
|
408 |
return; |
|
409 |
||
410 |
var desc = layout.short_description; |
|
411 |
if (desc == null || desc == "") { |
|
412 |
var parts = layout.name.split ("\t", 2); |
|
413 |
if (parts[0] == layout.name) { |
|
414 |
desc = layout.name; |
|
415 |
} else { |
|
416 |
/* Lookup parent layout, get its short_description */
|
|
417 |
var parent_layout = PantheonGreeter.get_layout_by_name (parts[0]); |
|
418 |
if (parent_layout.short_description == null || |
|
419 |
parent_layout.short_description == "") { |
|
420 |
desc = parts[0]; |
|
421 |
} else { |
|
422 |
desc = parent_layout.short_description; |
|
423 |
}
|
|
424 |
}
|
|
425 |
}
|
|
426 |
keyboard_label.label = "<span foreground=\"white\">"+desc+"</span>"; |
|
427 |
||
428 |
LightDM.set_layout (layout); |
|
429 |
}
|
|
430 |
||
70
by tombeckmann at online
A major rewrite and restructure of the code |
431 |
int onboard_stdout_fd; |
432 |
Gtk.Window keyboard_window; |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
433 |
|
189.2.1
by Raphael Isemann
Onboard now appears correctly |
434 |
public void toggle_keyboard (bool active) { |
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
435 |
if (keyboard_window != null) { |
189.2.1
by Raphael Isemann
Onboard now appears correctly |
436 |
keyboard_window.visible = active; |
437 |
settings.set_boolean ("onscreen-keyboard", active); |
|
123.1.3
by David Gomes
Licensed project under GPLv3, added AUTHORS, README, INSTALL and fixed tons of more code. |
438 |
return; |
439 |
}
|
|
440 |
||
441 |
int id = 0; |
|
442 |
||
443 |
try { |
|
444 |
string [] argv; |
|
445 |
Shell.parse_argv ("onboard --xid", out argv); |
|
446 |
Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out keyboard_pid, null, out onboard_stdout_fd, null); |
|
447 |
||
448 |
var f = FileStream.fdopen (onboard_stdout_fd, "r"); |
|
449 |
var stdout_text = new char[1024]; |
|
450 |
f.gets (stdout_text); |
|
451 |
id = int.parse ((string)stdout_text); |
|
452 |
} catch (Error e) { |
|
453 |
warning (e.message); |
|
454 |
}
|
|
455 |
||
456 |
var keyboard_socket = new Gtk.Socket (); |
|
457 |
keyboard_window = new Gtk.Window (); |
|
458 |
keyboard_window.accept_focus = false; |
|
459 |
keyboard_window.focus_on_map = false; |
|
460 |
keyboard_window.add (keyboard_socket); |
|
461 |
keyboard_socket.add_id (id); |
|
462 |
||
463 |
var screen = Gdk.Screen.get_default (); |
|
464 |
var monitor = screen.get_primary_monitor (); |
|
465 |
Gdk.Rectangle geom; |
|
466 |
screen.get_monitor_geometry (monitor, out geom); |
|
467 |
keyboard_window.move (geom.x, geom.y + geom.height - 200); |
|
468 |
keyboard_window.resize (geom.width, 200); |
|
469 |
keyboard_window.set_keep_above (true); |
|
470 |
||
471 |
keyboard_window.show_all (); |
|
472 |
settings.set_boolean ("onscreen-keyboard", true); |
|
20
by Tom Beckmann
Forgot another file... |
473 |
}
|
474 |
}
|