forked from sarim/goibus
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfactory.go
More file actions
42 lines (34 loc) · 1.23 KB
/
factory.go
File metadata and controls
42 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package goibus
import (
"github.com/godbus/dbus/v5"
)
type Factory struct {
conn *dbus.Conn
EngineCreator func(conn *dbus.Conn, engineName string) dbus.ObjectPath
}
func NewFactory(conn *dbus.Conn, EngineCreator func(conn *dbus.Conn, engineName string) dbus.ObjectPath) *Factory {
f := &Factory{conn, EngineCreator}
conn.Export(f, "/org/freedesktop/IBus/Factory", IBUS_IFACE_ENGINE_FACTORY)
return f
}
// # Return a array. [name, default_language, icon_path, authors, credits]
// @method(out_signature="as")
// def GetInfo(self): pass
// # Factory should allocate all resources in this method
// @method()
// def Initialize(self): pass
// # Factory should free all allocated resources in this method
// @method()
// def Uninitialize(self): pass
// # Create an input context and return the id of the context.
// # If failed, it will return "" or None.
// @method(in_signature="s", out_signature="o")
func (factory *Factory) CreateEngine(engineName string) (dbus.ObjectPath, *dbus.Error) {
return factory.EngineCreator(factory.conn, engineName), nil
}
// # Destroy the engine
// @method()
func (factory *Factory) Destroy() *dbus.Error {
factory.conn.Export(nil, "/org/freedesktop/IBus/Factory", IBUS_IFACE_ENGINE_FACTORY)
return nil
}