2 * app_keyboard - zavai keyboard show/hide functions
4 * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 public class Keyboard : Service
33 Object(name: "keyboard");
36 private void on_child_quit(Pid pid, int status)
38 Process.close_pid(pid);
43 protected override void start()
45 string[] args = { zavai.config.homedir + "/keyboard", null };
49 Gdk.Screen.get_default(),
53 SpawnFlags.SEARCH_PATH | SpawnFlags.STDOUT_TO_DEV_NULL | SpawnFlags.STDERR_TO_DEV_NULL,
57 ChildWatch.add(pid, on_child_quit);
60 log.error("Running " + zavai.config.homedir + "/keyboard: " + e.message);
65 protected override void stop()
69 Posix.kill((int)pid, 15);
76 public class KeyboardIcon : Gtk.StatusIcon
78 bool requested = false;
82 activate += on_activate;
83 zavai.ui.power.power.screen_lock_changed += on_screen_lock_changed;
88 private void on_activate()
90 requested = !requested;
93 keyboard.request("keyboardicon");
95 keyboard.release("keyboardicon");
98 protected void on_screen_lock_changed(bool val)
103 protected void update_icon()
105 string name = zavai.config.icondir + "/";
106 if (zavai.ui.power.power.screen_locked)
107 name += "screen_lock.png";
109 name += (requested ? "kbd_on.png" : "kbd_off.png");
110 stderr.printf("load icon from %s\n", name);
116 public class GPSRequestLink : Gtk.ToggleButton
118 public GPSRequestLink()
121 status_icon = new Gtk.StatusIcon();
122 status_icon.set_visible(true);
123 status_icon.activate += on_status_activate;
127 private void on_fix_status_changed(dynamic DBus.Object pos, int fix_status)
129 this.fix_status = fix_status;
133 private void on_toggled(Gtk.Button src)
135 Service s = zavai.registry.gets(service_name);
137 s.request("servicerequestlink");
139 s.release("servicerequestlink");
140 set_label(get_active() ? label_stop : label_start);
144 private void on_status_activate()
146 set_active(!get_active());
156 stderr.printf("INIT KBD\n");
157 keyboard = new Keyboard();
158 zavai.registry.register_service(keyboard);
159 icon = new KeyboardIcon();
160 icon.set_visible(true);