More of keyboard
authorEnrico Zini <enrico@enricozini.org>
Wed, 22 Jul 2009 18:24:19 +0000 (20:24 +0200)
committerEnrico Zini <enrico@enricozini.org>
Wed, 22 Jul 2009 18:24:19 +0000 (20:24 +0200)
icons/kbd_off.png [new file with mode: 0644]
icons/kbd_on.png [new file with mode: 0644]
src/Makefile.am
src/app_keyboard.vala

diff --git a/icons/kbd_off.png b/icons/kbd_off.png
new file mode 100644 (file)
index 0000000..65154f3
Binary files /dev/null and b/icons/kbd_off.png differ
diff --git a/icons/kbd_on.png b/icons/kbd_on.png
new file mode 100644 (file)
index 0000000..6d117b5
Binary files /dev/null and b/icons/kbd_on.png differ
index bd22906f28a697d795dd30116d097e08126dcd83..8e165361ac13f7935df9fef67404cb463c49b3a7 100644 (file)
@@ -1,4 +1,4 @@
-VFLAGS=-g --pkg gee-1.0 --pkg dbus-glib-1 --pkg gtk+-2.0
+VFLAGS=-g --pkg gee-1.0 --pkg dbus-glib-1 --pkg gtk+-2.0 --pkg posix
 
 #zavai: $(SOURCES)
 #      valac -o zavai $(VFLAGS) $^
index a518c221381cb4ddbce44e799c62f542ecc254c9..790ffa1097a682b07e8f184894d9d3dde9f39d1e 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+using GLib;
+
 namespace zavai {
 namespace ui {
 namespace kbd {
 
+public class Keyboard : Service
+{
+       protected Pid pid;
+
+       private void on_child_quit(Pid pid, int status)
+       {
+               Process.close_pid(pid);
+               pid = (Pid)0;
+               stop();
+       }
+
+       protected override void start()
+       {
+               string[] args = { "/usr/bin/matchbox-keyboard", null };
+               int opid;
+               try {
+                       Gdk.spawn_on_screen(
+                               Gdk.Screen.get_default(),
+                               "/",
+                               args,
+                               null,
+                               SpawnFlags.SEARCH_PATH | SpawnFlags.STDOUT_TO_DEV_NULL | SpawnFlags.STDERR_TO_DEV_NULL,
+                               null,
+                               out opid);
+                       pid = (Pid)opid;
+                       ChildWatch.add(pid, on_child_quit);
+                       base.start();
+               } catch (Error e) {
+                       log.error("Running matchbox-keyboard: " + e.message);
+                       pid = (Pid)0;
+               }
+       }
+
+       protected override void stop()
+       {
+               if ((int)pid != 0)
+               {
+                       Posix.kill((int)pid, 15);
+                       pid = (Pid)0;
+               }
+               base.stop();
+       }
+}
+
 /*
 class GPSOn(gtk.ToggleAction):
     states = [_("GPS always on"), _("GPS on when needed")]