Merge lp:~eeejay/notify-osd/text_iface into lp:notify-osd/trunk
- text_iface
- Merge into main
Proposed by
Eitan Isaacson
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~eeejay/notify-osd/text_iface | ||||
Merge into: | lp:notify-osd/trunk | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~eeejay/notify-osd/text_iface | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Notify OSD Developers | Pending | ||
Review via email: mp+5919@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Eitan Isaacson (eeejay) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bubble-window-accessible.c' | |||
2 | --- src/bubble-window-accessible.c 2009-02-27 20:00:53 +0000 | |||
3 | +++ src/bubble-window-accessible.c 2009-04-27 08:45:53 +0000 | |||
4 | @@ -37,6 +37,7 @@ | |||
5 | 37 | static void bubble_window_real_initialize (AtkObject* obj, | 37 | static void bubble_window_real_initialize (AtkObject* obj, |
6 | 38 | gpointer data); | 38 | gpointer data); |
7 | 39 | static void atk_value_interface_init (AtkValueIface* iface); | 39 | static void atk_value_interface_init (AtkValueIface* iface); |
8 | 40 | static void atk_text_interface_init (AtkTextIface* iface); | ||
9 | 40 | static void bubble_window_get_current_value (AtkValue* obj, | 41 | static void bubble_window_get_current_value (AtkValue* obj, |
10 | 41 | GValue* value); | 42 | GValue* value); |
11 | 42 | static void bubble_window_get_maximum_value (AtkValue* obj, | 43 | static void bubble_window_get_maximum_value (AtkValue* obj, |
12 | @@ -46,6 +47,19 @@ | |||
13 | 46 | static void bubble_value_changed_event (Bubble* bubble, | 47 | static void bubble_value_changed_event (Bubble* bubble, |
14 | 47 | gint value, | 48 | gint value, |
15 | 48 | AtkObject *obj); | 49 | AtkObject *obj); |
16 | 50 | static void bubble_message_body_deleted_event (Bubble* bubble, | ||
17 | 51 | const gchar* text, | ||
18 | 52 | AtkObject* obj); | ||
19 | 53 | static void bubble_message_body_inserted_event (Bubble* bubble, | ||
20 | 54 | const gchar* text, | ||
21 | 55 | AtkObject* obj); | ||
22 | 56 | |||
23 | 57 | static gchar* bubble_window_get_text (AtkText *obj, | ||
24 | 58 | gint start_offset, | ||
25 | 59 | gint end_offset); | ||
26 | 60 | static gint bubble_window_get_character_count (AtkText *obj); | ||
27 | 61 | static gunichar bubble_window_get_character_at_offset (AtkText *obj, | ||
28 | 62 | gint offset); | ||
29 | 49 | 63 | ||
30 | 50 | static void* bubble_window_accessible_parent_class; | 64 | static void* bubble_window_accessible_parent_class; |
31 | 51 | 65 | ||
32 | @@ -76,6 +90,13 @@ | |||
33 | 76 | (GInterfaceFinalizeFunc) NULL, | 90 | (GInterfaceFinalizeFunc) NULL, |
34 | 77 | NULL | 91 | NULL |
35 | 78 | }; | 92 | }; |
36 | 93 | |||
37 | 94 | const GInterfaceInfo atk_text_info = | ||
38 | 95 | { | ||
39 | 96 | (GInterfaceInitFunc) atk_text_interface_init, | ||
40 | 97 | (GInterfaceFinalizeFunc) NULL, | ||
41 | 98 | NULL | ||
42 | 99 | }; | ||
43 | 79 | 100 | ||
44 | 80 | /* | 101 | /* |
45 | 81 | * Figure out the size of the class and instance | 102 | * Figure out the size of the class and instance |
46 | @@ -100,6 +121,8 @@ | |||
47 | 100 | "BubbleWindowAccessible", &tinfo, 0); | 121 | "BubbleWindowAccessible", &tinfo, 0); |
48 | 101 | 122 | ||
49 | 102 | g_type_add_interface_static (type, ATK_TYPE_VALUE, &atk_value_info); | 123 | g_type_add_interface_static (type, ATK_TYPE_VALUE, &atk_value_info); |
50 | 124 | |||
51 | 125 | g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); | ||
52 | 103 | } | 126 | } |
53 | 104 | 127 | ||
54 | 105 | return type; | 128 | return type; |
55 | @@ -116,6 +139,17 @@ | |||
56 | 116 | } | 139 | } |
57 | 117 | 140 | ||
58 | 118 | static void | 141 | static void |
59 | 142 | atk_text_interface_init (AtkTextIface* iface) | ||
60 | 143 | { | ||
61 | 144 | g_return_if_fail (iface != NULL); | ||
62 | 145 | |||
63 | 146 | iface->get_text = bubble_window_get_text; | ||
64 | 147 | iface->get_character_count = bubble_window_get_character_count; | ||
65 | 148 | iface->get_character_at_offset = bubble_window_get_character_at_offset; | ||
66 | 149 | |||
67 | 150 | } | ||
68 | 151 | |||
69 | 152 | static void | ||
70 | 119 | bubble_window_accessible_init (BubbleWindowAccessible *object) | 153 | bubble_window_accessible_init (BubbleWindowAccessible *object) |
71 | 120 | { | 154 | { |
72 | 121 | /* TODO: Add initialization code here */ | 155 | /* TODO: Add initialization code here */ |
73 | @@ -160,6 +194,16 @@ | |||
74 | 160 | G_CALLBACK (bubble_value_changed_event), | 194 | G_CALLBACK (bubble_value_changed_event), |
75 | 161 | obj); | 195 | obj); |
76 | 162 | 196 | ||
77 | 197 | g_signal_connect (bubble, | ||
78 | 198 | "message-body-deleted", | ||
79 | 199 | G_CALLBACK (bubble_message_body_deleted_event), | ||
80 | 200 | obj); | ||
81 | 201 | |||
82 | 202 | g_signal_connect (bubble, | ||
83 | 203 | "message-body-inserted", | ||
84 | 204 | G_CALLBACK (bubble_message_body_inserted_event), | ||
85 | 205 | obj); | ||
86 | 206 | |||
87 | 163 | } | 207 | } |
88 | 164 | 208 | ||
89 | 165 | AtkObject* | 209 | AtkObject* |
90 | @@ -286,3 +330,108 @@ | |||
91 | 286 | { | 330 | { |
92 | 287 | g_object_notify (G_OBJECT (obj), "accessible-value"); | 331 | g_object_notify (G_OBJECT (obj), "accessible-value"); |
93 | 288 | } | 332 | } |
94 | 333 | |||
95 | 334 | static void | ||
96 | 335 | bubble_message_body_deleted_event (Bubble* bubble, | ||
97 | 336 | const gchar* text, | ||
98 | 337 | AtkObject* obj) | ||
99 | 338 | { | ||
100 | 339 | /* Not getting very fancy here, delete is always complete */ | ||
101 | 340 | g_signal_emit_by_name ( | ||
102 | 341 | obj, "text_changed::delete", 0, g_utf8_strlen (text, -1)); | ||
103 | 342 | } | ||
104 | 343 | |||
105 | 344 | static void | ||
106 | 345 | bubble_message_body_inserted_event (Bubble* bubble, | ||
107 | 346 | const gchar* text, | ||
108 | 347 | AtkObject* obj) | ||
109 | 348 | { | ||
110 | 349 | const gchar* message_body; | ||
111 | 350 | |||
112 | 351 | message_body = bubble_get_message_body (bubble); | ||
113 | 352 | |||
114 | 353 | g_signal_emit_by_name ( | ||
115 | 354 | obj, "text_changed::insert", | ||
116 | 355 | g_utf8_strlen (message_body, -1) - g_utf8_strlen (text, -1), | ||
117 | 356 | g_utf8_strlen (message_body, -1)); | ||
118 | 357 | } | ||
119 | 358 | |||
120 | 359 | static gchar* | ||
121 | 360 | bubble_window_get_text (AtkText *obj, | ||
122 | 361 | gint start_offset, | ||
123 | 362 | gint end_offset) | ||
124 | 363 | { | ||
125 | 364 | GtkAccessible* accessible; | ||
126 | 365 | Bubble* bubble; | ||
127 | 366 | const gchar* body_text; | ||
128 | 367 | gsize char_length; | ||
129 | 368 | glong body_strlen; | ||
130 | 369 | |||
131 | 370 | g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), g_strdup("")); | ||
132 | 371 | |||
133 | 372 | accessible = GTK_ACCESSIBLE (obj); | ||
134 | 373 | |||
135 | 374 | g_return_val_if_fail (accessible->widget == NULL, g_strdup("")); | ||
136 | 375 | |||
137 | 376 | bubble = g_object_get_data (G_OBJECT(accessible->widget), "bubble"); | ||
138 | 377 | |||
139 | 378 | if (end_offset <= start_offset) | ||
140 | 379 | return g_strdup(""); | ||
141 | 380 | |||
142 | 381 | body_text = bubble_get_message_body (bubble); | ||
143 | 382 | |||
144 | 383 | body_strlen = g_utf8_strlen(body_text, -1); | ||
145 | 384 | |||
146 | 385 | if (start_offset > body_strlen) | ||
147 | 386 | start_offset = body_strlen; | ||
148 | 387 | |||
149 | 388 | if (end_offset > body_strlen || end_offset == -1) | ||
150 | 389 | end_offset = body_strlen; | ||
151 | 390 | |||
152 | 391 | |||
153 | 392 | char_length = g_utf8_offset_to_pointer (body_text, end_offset) - | ||
154 | 393 | g_utf8_offset_to_pointer (body_text, start_offset); | ||
155 | 394 | |||
156 | 395 | return g_strndup (g_utf8_offset_to_pointer(body_text, start_offset), | ||
157 | 396 | char_length); | ||
158 | 397 | } | ||
159 | 398 | |||
160 | 399 | static gint | ||
161 | 400 | bubble_window_get_character_count (AtkText *obj) | ||
162 | 401 | { | ||
163 | 402 | GtkAccessible* accessible; | ||
164 | 403 | Bubble* bubble; | ||
165 | 404 | |||
166 | 405 | g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), 0); | ||
167 | 406 | |||
168 | 407 | accessible = GTK_ACCESSIBLE (obj); | ||
169 | 408 | |||
170 | 409 | if (accessible->widget == NULL) | ||
171 | 410 | return 0; | ||
172 | 411 | |||
173 | 412 | bubble = g_object_get_data (G_OBJECT(accessible->widget), "bubble"); | ||
174 | 413 | |||
175 | 414 | return g_utf8_strlen(bubble_get_message_body (bubble), -1); | ||
176 | 415 | } | ||
177 | 416 | |||
178 | 417 | static gunichar | ||
179 | 418 | bubble_window_get_character_at_offset (AtkText *obj, | ||
180 | 419 | gint offset) | ||
181 | 420 | { | ||
182 | 421 | GtkAccessible* accessible; | ||
183 | 422 | Bubble* bubble; | ||
184 | 423 | const gchar* body_text; | ||
185 | 424 | |||
186 | 425 | g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), 0); | ||
187 | 426 | |||
188 | 427 | accessible = GTK_ACCESSIBLE (obj); | ||
189 | 428 | |||
190 | 429 | if (accessible->widget == NULL) | ||
191 | 430 | return 0; | ||
192 | 431 | |||
193 | 432 | bubble = g_object_get_data (G_OBJECT(accessible->widget), "bubble"); | ||
194 | 433 | |||
195 | 434 | body_text = bubble_get_message_body (bubble); | ||
196 | 435 | |||
197 | 436 | return g_utf8_get_char (g_utf8_offset_to_pointer (body_text, offset)); | ||
198 | 437 | } | ||
199 | 289 | 438 | ||
200 | === modified file 'src/bubble.c' | |||
201 | --- src/bubble.c 2009-04-16 14:13:47 +0000 | |||
202 | +++ src/bubble.c 2009-04-27 08:54:00 +0000 | |||
203 | @@ -94,6 +94,8 @@ | |||
204 | 94 | { | 94 | { |
205 | 95 | TIMED_OUT, | 95 | TIMED_OUT, |
206 | 96 | VALUE_CHANGED, | 96 | VALUE_CHANGED, |
207 | 97 | MESSAGE_BODY_DELETED, | ||
208 | 98 | MESSAGE_BODY_INSERTED, | ||
209 | 97 | LAST_SIGNAL | 99 | LAST_SIGNAL |
210 | 98 | }; | 100 | }; |
211 | 99 | 101 | ||
212 | @@ -1903,6 +1905,30 @@ | |||
213 | 1903 | G_TYPE_NONE, | 1905 | G_TYPE_NONE, |
214 | 1904 | 1, | 1906 | 1, |
215 | 1905 | G_TYPE_INT); | 1907 | G_TYPE_INT); |
216 | 1908 | |||
217 | 1909 | g_bubble_signals[MESSAGE_BODY_DELETED] = g_signal_new ( | ||
218 | 1910 | "message-body-deleted", | ||
219 | 1911 | G_OBJECT_CLASS_TYPE (gobject_class), | ||
220 | 1912 | G_SIGNAL_RUN_LAST, | ||
221 | 1913 | G_STRUCT_OFFSET (BubbleClass, message_body_deleted), | ||
222 | 1914 | NULL, | ||
223 | 1915 | NULL, | ||
224 | 1916 | g_cclosure_marshal_VOID__STRING, | ||
225 | 1917 | G_TYPE_NONE, | ||
226 | 1918 | 1, | ||
227 | 1919 | G_TYPE_STRING); | ||
228 | 1920 | |||
229 | 1921 | g_bubble_signals[MESSAGE_BODY_INSERTED] = g_signal_new ( | ||
230 | 1922 | "message-body-inserted", | ||
231 | 1923 | G_OBJECT_CLASS_TYPE (gobject_class), | ||
232 | 1924 | G_SIGNAL_RUN_LAST, | ||
233 | 1925 | G_STRUCT_OFFSET (BubbleClass, message_body_inserted), | ||
234 | 1926 | NULL, | ||
235 | 1927 | NULL, | ||
236 | 1928 | g_cclosure_marshal_VOID__STRING, | ||
237 | 1929 | G_TYPE_NONE, | ||
238 | 1930 | 1, | ||
239 | 1931 | G_TYPE_STRING); | ||
240 | 1906 | } | 1932 | } |
241 | 1907 | 1933 | ||
242 | 1908 | /*-- public API --------------------------------------------------------------*/ | 1934 | /*-- public API --------------------------------------------------------------*/ |
243 | @@ -2066,6 +2092,10 @@ | |||
244 | 2066 | g_string_free (priv->title, TRUE); | 2092 | g_string_free (priv->title, TRUE); |
245 | 2067 | 2093 | ||
246 | 2068 | priv->title = g_string_new (title); | 2094 | priv->title = g_string_new (title); |
247 | 2095 | |||
248 | 2096 | g_object_notify ( | ||
249 | 2097 | G_OBJECT (gtk_widget_get_accessible (GET_PRIVATE(self)->widget)), | ||
250 | 2098 | "accessible-name"); | ||
251 | 2069 | } | 2099 | } |
252 | 2070 | 2100 | ||
253 | 2071 | const gchar* | 2101 | const gchar* |
254 | @@ -2089,13 +2119,20 @@ | |||
255 | 2089 | 2119 | ||
256 | 2090 | priv = GET_PRIVATE (self); | 2120 | priv = GET_PRIVATE (self); |
257 | 2091 | 2121 | ||
259 | 2092 | if (priv->message_body->len != 0) | 2122 | if (priv->message_body->len != 0) { |
260 | 2123 | g_signal_emit (self, g_bubble_signals[MESSAGE_BODY_DELETED], | ||
261 | 2124 | 0, priv->message_body->str); | ||
262 | 2093 | g_string_free (priv->message_body, TRUE); | 2125 | g_string_free (priv->message_body, TRUE); |
264 | 2094 | 2126 | } | |
265 | 2095 | /* filter out any HTML/markup if possible */ | 2127 | /* filter out any HTML/markup if possible */ |
266 | 2096 | text = filter_text (body); | 2128 | text = filter_text (body); |
267 | 2097 | 2129 | ||
268 | 2098 | priv->message_body = g_string_new (text); | 2130 | priv->message_body = g_string_new (text); |
269 | 2131 | |||
270 | 2132 | g_signal_emit (self, g_bubble_signals[MESSAGE_BODY_INSERTED], 0, text); | ||
271 | 2133 | g_object_notify (G_OBJECT (gtk_widget_get_accessible (priv->widget)), | ||
272 | 2134 | "accessible-description"); | ||
273 | 2135 | |||
274 | 2099 | g_free (text); | 2136 | g_free (text); |
275 | 2100 | } | 2137 | } |
276 | 2101 | 2138 | ||
277 | @@ -3387,6 +3424,12 @@ | |||
278 | 3387 | /* append text to current message-body */ | 3424 | /* append text to current message-body */ |
279 | 3388 | g_string_append (GET_PRIVATE (self)->message_body, text); | 3425 | g_string_append (GET_PRIVATE (self)->message_body, text); |
280 | 3389 | 3426 | ||
281 | 3427 | g_signal_emit (self, g_bubble_signals[MESSAGE_BODY_INSERTED], 0, text); | ||
282 | 3428 | |||
283 | 3429 | g_object_notify ( | ||
284 | 3430 | G_OBJECT (gtk_widget_get_accessible (GET_PRIVATE(self)->widget)), | ||
285 | 3431 | "accessible-description"); | ||
286 | 3432 | |||
287 | 3390 | g_free ((gpointer) text); | 3433 | g_free ((gpointer) text); |
288 | 3391 | } | 3434 | } |
289 | 3392 | 3435 | ||
290 | 3393 | 3436 | ||
291 | === modified file 'src/bubble.h' | |||
292 | --- src/bubble.h 2009-04-09 10:44:07 +0000 | |||
293 | +++ src/bubble.h 2009-04-23 15:22:58 +0000 | |||
294 | @@ -76,6 +76,8 @@ | |||
295 | 76 | /*< signals >*/ | 76 | /*< signals >*/ |
296 | 77 | void (*timed_out) (Bubble* bubble); | 77 | void (*timed_out) (Bubble* bubble); |
297 | 78 | void (*value_changed) (Bubble* bubble); | 78 | void (*value_changed) (Bubble* bubble); |
298 | 79 | void (*message_body_deleted) (Bubble* bubble); | ||
299 | 80 | void (*message_body_inserted) (Bubble* bubble); | ||
300 | 79 | }; | 81 | }; |
301 | 80 | 82 | ||
302 | 81 | GType bubble_get_type (void); | 83 | GType bubble_get_type (void); |
This branch adds a text interface and relevant AT-SPI events for dynamic bubble messages and titles.