summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Isaacson <eitan@monotonous.org>2011-06-08 12:53:10 -0700
committerEitan Isaacson <eitan@monotonous.org>2011-06-08 12:56:28 -0700
commit80ff27e165389fe490305d05e2e01708d113ddc2 (patch)
treec1e6decde9db174d3bc107217951e1f68749f904
parent031c5c6b2701504fcf9e0c6f056b7cc8e67e7964 (diff)
downloadcaribou-80ff27e165389fe490305d05e2e01708d113ddc2.tar.gz
Use generic keyboard service name.
- Have it replaceable by a service that is activated later. - Have Antler quit if the generic name is acquired by a new service. - Keep non-replaceable implementation specific name on bus. https://bugzilla.gnome.org/show_bug.cgi?id=651702
-rw-r--r--caribou/antler/main.py5
-rw-r--r--caribou/daemon/main.py6
-rw-r--r--data/org.gnome.Caribou.Antler.service.in2
-rw-r--r--libcaribou/keyboard-service.vala29
4 files changed, 30 insertions, 12 deletions
diff --git a/caribou/antler/main.py b/caribou/antler/main.py
index ce0eca3..d5d9a1b 100644
--- a/caribou/antler/main.py
+++ b/caribou/antler/main.py
@@ -2,6 +2,7 @@ from gi.repository import Caribou
from window import AntlerWindowEntry
from keyboard_view import AntlerKeyboardView
import gobject
+import sys
class AntlerKeyboardService(Caribou.KeyboardService):
def __init__(self):
@@ -25,6 +26,10 @@ class AntlerKeyboardService(Caribou.KeyboardService):
def do_set_entry_location (self, x, y, w, h):
self.window.set_entry_location(x, y, w, h)
+ def do_name_lost (self, name):
+ sys.stderr.write("Another service acquired %s, quitting..\n")
+ sys.exit(0)
+
if __name__ == "__main__":
antler_keyboard_service = AntlerKeyboardService()
antler_keyboard_service.run()
diff --git a/caribou/daemon/main.py b/caribou/daemon/main.py
index 4f3def9..63eb444 100644
--- a/caribou/daemon/main.py
+++ b/caribou/daemon/main.py
@@ -9,13 +9,13 @@ from caribou import APP_NAME
debug = False
class CaribouDaemon:
- def __init__(self, keyboard_name="Antler"):
+ def __init__(self):
if not self._get_a11y_enabled():
self._show_no_a11y_dialogs()
bus = dbus.SessionBus()
try:
- dbus_obj = bus.get_object("org.gnome.Caribou.%s" % keyboard_name,
- "/org/gnome/Caribou/%s" % keyboard_name)
+ dbus_obj = bus.get_object("org.gnome.Caribou.Keyboard",
+ "/org/gnome/Caribou/Keyboard")
except dbus.DBusException, e:
self._show_error_dialog(e.message)
self.keyboard_proxy = dbus.Interface(dbus_obj, "org.gnome.Caribou.Keyboard")
diff --git a/data/org.gnome.Caribou.Antler.service.in b/data/org.gnome.Caribou.Antler.service.in
index fd85a4e..1b1db34 100644
--- a/data/org.gnome.Caribou.Antler.service.in
+++ b/data/org.gnome.Caribou.Antler.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
-Name=org.gnome.Caribou.Antler
+Name=org.gnome.Caribou.Keyboard
Exec=@libexecdir@/antler-keyboard
diff --git a/libcaribou/keyboard-service.vala b/libcaribou/keyboard-service.vala
index ee0035f..0a8c7c9 100644
--- a/libcaribou/keyboard-service.vala
+++ b/libcaribou/keyboard-service.vala
@@ -1,30 +1,43 @@
namespace Caribou {
[DBus(name = "org.gnome.Caribou.Keyboard")]
public abstract class KeyboardService : Object {
- public string name { get; private set; default = "CaribouKeyboard"; }
-
public abstract void set_cursor_location(int x, int y, int w, int h);
public abstract void set_entry_location(int x, int y, int w, int h);
public abstract void show();
public abstract void hide();
protected void register_keyboard (string name) {
- this.name = name;
string dbus_name = @"org.gnome.Caribou.$name";
Bus.own_name (BusType.SESSION, dbus_name, BusNameOwnerFlags.NONE,
- on_bus_aquired, on_name_aquired, on_name_lost);
+ on_bus_acquired, on_impl_name_acquired, on_impl_name_lost);
+ }
+
+ private void on_bus_acquired (DBusConnection conn) {
}
- private void on_name_aquired (DBusConnection conn, string name) {
+ private void on_impl_name_lost (DBusConnection conn, string name) {
+ stderr.printf ("Could not acquire %s\n", name);
}
private void on_name_lost (DBusConnection conn, string name) {
- stderr.printf ("Could not aquire %s\n", name);
+ stderr.printf ("Could not acquire %s\n", name);
+ name_lost (name);
+ }
+
+ protected virtual void name_lost (string name) {
+ stderr.printf ("default\n");
+ }
+
+ private void on_impl_name_acquired (DBusConnection conn, string name) {
+ Bus.own_name (
+ BusType.SESSION, "org.gnome.Caribou.Keyboard",
+ BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE,
+ on_bus_acquired, on_generic_name_acquired, on_name_lost);
}
- private void on_bus_aquired (DBusConnection conn) {
+ private void on_generic_name_acquired (DBusConnection conn, string name) {
try {
- string path = @"/org/gnome/Caribou/$name";
+ string path = @"/org/gnome/Caribou/Keyboard";
conn.register_object (path, this);
} catch (IOError e) {
stderr.printf ("Could not register service: %s\n", e.message);