1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ |
2 | /* vim:set et sts=4: */ |
3 | /* ibus - The Input Bus |
4 | * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com> |
5 | * Copyright (C) 2008-2013 Red Hat, Inc. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
20 | * USA |
21 | */ |
22 | |
23 | #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION) |
24 | #error "Only <ibus.h> can be included directly" |
25 | #endif |
26 | |
27 | #ifndef __IBUS_FACTORY_H_ |
28 | #define __IBUS_FACTORY_H_ |
29 | |
30 | /** |
31 | * SECTION: ibusfactory |
32 | * @short_description: Factory for creating engine instances. |
33 | * @title: IBusFactory |
34 | * @stability: Stable |
35 | * |
36 | * An IBusFactory is an #IBusService that creates input method engine (IME) instance. |
37 | * It provides CreateEngine remote method, which creates an IME instance by name, |
38 | * and returns the D-Bus object path to IBus daemon. |
39 | * |
40 | * see_also: #IBusEngine |
41 | * |
42 | */ |
43 | |
44 | #include "ibusservice.h" |
45 | #include "ibusserializable.h" |
46 | #include "ibusengine.h" |
47 | |
48 | G_BEGIN_DECLS |
49 | |
50 | /* |
51 | * Type macros. |
52 | */ |
53 | |
54 | /* define GOBJECT macros */ |
55 | /** |
56 | * IBUS_TYPE_FACTORY: |
57 | * |
58 | * Return GType of IBus factory. |
59 | */ |
60 | #define IBUS_TYPE_FACTORY \ |
61 | (ibus_factory_get_type ()) |
62 | |
63 | /** |
64 | * IBUS_FACTORY: |
65 | * @obj: An object which is subject to casting. |
66 | * |
67 | * Casts an IBUS_FACTORY or derived pointer into a (IBusFactory*) pointer. |
68 | * Depending on the current debugging level, this function may invoke |
69 | * certain runtime checks to identify invalid casts. |
70 | */ |
71 | #define IBUS_FACTORY(obj) \ |
72 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_FACTORY, IBusFactory)) |
73 | |
74 | /** |
75 | * IBUS_FACTORY_CLASS: |
76 | * @klass: A class to be casted. |
77 | * |
78 | * Casts a derived IBusFactoryClass structure into a IBusFactoryClass structure. |
79 | */ |
80 | #define IBUS_FACTORY_CLASS(klass) \ |
81 | (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_FACTORY, IBusFactoryClass)) |
82 | |
83 | /** |
84 | * IBUS_IS_FACTORY: |
85 | * @obj: Instance to check for being a IBUS_FACTORY. |
86 | * |
87 | * Checks whether a valid GTypeInstance pointer is of type IBUS_FACTORY. |
88 | */ |
89 | #define IBUS_IS_FACTORY(obj) \ |
90 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_FACTORY)) |
91 | |
92 | /** |
93 | * IBUS_IS_FACTORY_CLASS: |
94 | * @klass: A class to be checked. |
95 | * |
96 | * Checks whether class "is a" valid IBusFactoryClass structure of type IBUS_FACTORY or derived. |
97 | */ |
98 | #define IBUS_IS_FACTORY_CLASS(klass) \ |
99 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_FACTORY)) |
100 | |
101 | /** |
102 | * IBUS_FACTORY_GET_CLASS: |
103 | * @obj: An object. |
104 | * |
105 | * Get the class of a given object and cast the class to IBusFactoryClass. |
106 | */ |
107 | #define IBUS_FACTORY_GET_CLASS(obj) \ |
108 | (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_FACTORY, IBusFactoryClass)) |
109 | |
110 | typedef struct _IBusFactory IBusFactory; |
111 | typedef struct _IBusFactoryClass IBusFactoryClass; |
112 | typedef struct _IBusFactoryPrivate IBusFactoryPrivate; |
113 | |
114 | /** |
115 | * IBusFactory: |
116 | * |
117 | * An opaque data type representing an IBusFactory. |
118 | */ |
119 | struct _IBusFactory { |
120 | /*< private >*/ |
121 | IBusService parent; |
122 | IBusFactoryPrivate *priv; |
123 | |
124 | /* instance members */ |
125 | }; |
126 | |
127 | struct _IBusFactoryClass { |
128 | /*< private >*/ |
129 | IBusServiceClass parent; |
130 | |
131 | /*< public >*/ |
132 | /* signals */ |
133 | IBusEngine * |
134 | (* create_engine) |
135 | (IBusFactory *factory, |
136 | const gchar *engine_name); |
137 | |
138 | /*< private >*/ |
139 | /* padding */ |
140 | gpointer pdummy[7]; |
141 | }; |
142 | |
143 | /** |
144 | * ibus_factory_info_get_type: |
145 | * |
146 | * Gets GType of IBus factory information. |
147 | * |
148 | * Returns: GType of IBus factory information. |
149 | */ |
150 | GType ibus_factory_get_type (void); |
151 | |
152 | /** |
153 | * ibus_factory_new: |
154 | * @connection: An GDBusConnection. |
155 | * |
156 | * Creates a new #IBusFactory. |
157 | * |
158 | * Returns: A newly allocated #IBusFactory. |
159 | */ |
160 | IBusFactory *ibus_factory_new (GDBusConnection *connection); |
161 | |
162 | /** |
163 | * ibus_factory_add_engine: |
164 | * @factory: An IBusFactory. |
165 | * @engine_name: Name of an engine. |
166 | * @engine_type: GType of an engine. |
167 | * |
168 | * Add an engine to the factory. |
169 | */ |
170 | void ibus_factory_add_engine (IBusFactory *factory, |
171 | const gchar *engine_name, |
172 | GType engine_type); |
173 | |
174 | /** |
175 | * ibus_factory_create_engine: |
176 | * @factory: An #IBusFactory. |
177 | * @engine_name: Name of an engine. |
178 | * |
179 | * Creates an #IBusEngine with @engine_name. |
180 | * |
181 | * Returns: (transfer full): #IBusEngine with @engine_name. |
182 | */ |
183 | IBusEngine *ibus_factory_create_engine (IBusFactory *factory, |
184 | const gchar *engine_name); |
185 | |
186 | G_END_DECLS |
187 | #endif |
188 | |
189 | |