Merge lp:~cimi/overlay-scrollbar/support-different-placement into lp:overlay-scrollbar
- support-different-placement
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ted Gould | ||||
Approved revision: | 271 | ||||
Merged at revision: | 272 | ||||
Proposed branch: | lp:~cimi/overlay-scrollbar/support-different-placement | ||||
Merge into: | lp:overlay-scrollbar | ||||
Diff against target: |
621 lines (+281/-72) 4 files modified
configure.ac (+2/-2) os/os-scrollbar.c (+278/-65) os/os-utils.c (+0/-5) tests/test-os.c (+1/-0) |
||||
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/support-different-placement | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+66183@code.launchpad.net |
Commit message
Description of the change
Support different scrollbar layout, didn't test the qdata yet
To post a comment you must log in.
- 269. By Andrea Cimitan
-
This should fix multimonitor support
- 270. By Andrea Cimitan
-
Merged trunk
- 271. By Andrea Cimitan
-
Initialize side
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2011-06-17 02:48:41 +0000 |
3 | +++ configure.ac 2011-06-29 10:01:21 +0000 |
4 | @@ -71,9 +71,9 @@ |
5 | |
6 | AC_ARG_WITH([gtk], |
7 | [AS_HELP_STRING([--with-gtk], |
8 | - [Which version of gtk to use @<:@default=2@:>@])], |
9 | + [Which version of gtk to use @<:@default=3@:>@])], |
10 | [], |
11 | - [with_gtk=2]) |
12 | + [with_gtk=3]) |
13 | AS_IF([test "x$with_gtk" = x3], |
14 | [PKG_CHECK_MODULES(DEPS, glib-2.0 >= $glib_req gtk+-3.0 >= $gtk3_req cairo >= $cairo_req) |
15 | AC_SUBST(DEPS_CFLAGS) |
16 | |
17 | === modified file 'os/os-scrollbar.c' |
18 | --- os/os-scrollbar.c 2011-06-28 23:04:55 +0000 |
19 | +++ os/os-scrollbar.c 2011-06-29 10:01:21 +0000 |
20 | @@ -35,9 +35,6 @@ |
21 | /* Size of the pager in pixels. */ |
22 | #define PAGER_SIZE 3 |
23 | |
24 | -/* Thumb allocation shift in pixels. */ |
25 | -#define THUMB_ALLOCATION_SHIFT -3 |
26 | - |
27 | /* Size of the proximity effect in pixels. */ |
28 | #define PROXIMITY_SIZE 30 |
29 | |
30 | @@ -61,6 +58,15 @@ |
31 | OS_SIDE_RIGHT |
32 | } OsSide; |
33 | |
34 | +typedef enum |
35 | +{ |
36 | + OS_STRUT_SIDE_NONE = 0, |
37 | + OS_STRUT_SIDE_TOP = 1, |
38 | + OS_STRUT_SIDE_BOTTOM = 2, |
39 | + OS_STRUT_SIDE_LEFT = 4, |
40 | + OS_STRUT_SIDE_RIGHT = 8 |
41 | +} OsStrutSide; |
42 | + |
43 | struct _OsScrollbarPrivate |
44 | { |
45 | GdkRectangle trough; |
46 | @@ -73,6 +79,7 @@ |
47 | GtkOrientation orientation; |
48 | GtkWindowGroup *window_group; |
49 | OsPager *pager; |
50 | + OsSide side; |
51 | gboolean button_press_event; |
52 | gboolean enter_notify_event; |
53 | gboolean motion_notify_event; |
54 | @@ -102,6 +109,7 @@ |
55 | static Atom unity_net_workarea_region_atom = None; |
56 | static GList *os_root_list = NULL; |
57 | static cairo_region_t *os_workarea = NULL; |
58 | +static GQuark os_quark_placement = 0; |
59 | |
60 | static void swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment); |
61 | static void swap_thumb (OsScrollbar *scrollbar, GtkWidget *thumb); |
62 | @@ -409,14 +417,16 @@ |
63 | GdkScreen *screen; |
64 | OsScrollbarPrivate *priv; |
65 | cairo_rectangle_int_t rect; |
66 | - gint screen_width, n_monitor; |
67 | + gint screen_x, screen_width, n_monitor, monitor_x; |
68 | |
69 | priv = scrollbar->priv; |
70 | |
71 | /* the x - 1 coordinate shift is done |
72 | * to calculate monitor boundaries. */ |
73 | + monitor_x = priv->side == OS_SIDE_LEFT ? x : x - 1; |
74 | + |
75 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); |
76 | - n_monitor = gdk_screen_get_monitor_at_point (screen, x - 1, y); |
77 | + n_monitor = gdk_screen_get_monitor_at_point (screen, monitor_x, y); |
78 | #ifdef USE_GTK3 |
79 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); |
80 | #else |
81 | @@ -428,42 +438,108 @@ |
82 | rect.height = gdk_rect.height; |
83 | #endif |
84 | |
85 | - if (cairo_region_is_empty (os_workarea)) |
86 | - screen_width = rect.x + rect.width; |
87 | - else |
88 | + screen_x = rect.x; |
89 | + screen_width = rect.x + rect.width; |
90 | + |
91 | + if (!cairo_region_is_empty (os_workarea)) |
92 | { |
93 | cairo_region_t *monitor_workarea; |
94 | + cairo_region_t *struts_region; |
95 | cairo_rectangle_int_t tmp_rect; |
96 | gint i, x, width; |
97 | |
98 | x = rect.x; |
99 | - width = rect.width; |
100 | + width = rect.x + rect.width; |
101 | |
102 | + /* full monitor region */ |
103 | monitor_workarea = cairo_region_create_rectangle (&rect); |
104 | + struts_region = cairo_region_copy (monitor_workarea); |
105 | |
106 | + /* workarea region for current monitor */ |
107 | cairo_region_intersect (monitor_workarea, os_workarea); |
108 | |
109 | - for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++) |
110 | + /* struts region for current monitor */ |
111 | + cairo_region_subtract (struts_region, monitor_workarea); |
112 | + |
113 | + for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) |
114 | { |
115 | - cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect); |
116 | - |
117 | - if (tmp_rect.x > x) |
118 | - x = tmp_rect.x; |
119 | - if (tmp_rect.x + tmp_rect.width < width) |
120 | - width = tmp_rect.x + tmp_rect.width; |
121 | + OsStrutSide strut_side; |
122 | + gint count; |
123 | + |
124 | + cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
125 | + |
126 | + strut_side = OS_STRUT_SIDE_NONE; |
127 | + count = 0; |
128 | + |
129 | + /* determine which side the strut is on */ |
130 | + if (tmp_rect.y == rect.y) |
131 | + { |
132 | + strut_side |= OS_STRUT_SIDE_TOP; |
133 | + count++; |
134 | + } |
135 | + |
136 | + if (tmp_rect.x == rect.x) |
137 | + { |
138 | + strut_side |= OS_STRUT_SIDE_LEFT; |
139 | + count++; |
140 | + } |
141 | + |
142 | + if (tmp_rect.x + tmp_rect.width == rect.x + rect.width) |
143 | + { |
144 | + strut_side |= OS_STRUT_SIDE_RIGHT; |
145 | + count++; |
146 | + } |
147 | + |
148 | + if (tmp_rect.y + tmp_rect.height == rect.y + rect.height) |
149 | + { |
150 | + strut_side |= OS_STRUT_SIDE_BOTTOM; |
151 | + count++; |
152 | + } |
153 | + |
154 | + /* handle multiple sides */ |
155 | + if (count >= 2) |
156 | + { |
157 | + if (tmp_rect.width > tmp_rect.height) |
158 | + strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT); |
159 | + else if (tmp_rect.width < tmp_rect.height) |
160 | + strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM); |
161 | + } |
162 | + |
163 | + /* get the monitor boundaries using the strut */ |
164 | + if (strut_side & OS_STRUT_SIDE_LEFT) |
165 | + { |
166 | + if (tmp_rect.x + tmp_rect.width > x) |
167 | + x = tmp_rect.x + tmp_rect.width; |
168 | + } |
169 | + |
170 | + if (strut_side & OS_STRUT_SIDE_RIGHT) |
171 | + { |
172 | + if (tmp_rect.x < width) |
173 | + width = tmp_rect.x; |
174 | + } |
175 | } |
176 | |
177 | - screen_width = x + width; |
178 | + screen_x = x; |
179 | + screen_width = width; |
180 | |
181 | cairo_region_destroy (monitor_workarea); |
182 | - } |
183 | - |
184 | - if (priv->orientation == GTK_ORIENTATION_VERTICAL && |
185 | - (n_monitor != gdk_screen_get_monitor_at_point (screen, x - 1 + priv->slider.width, y) || |
186 | - x - 1 + priv->slider.width >= screen_width)) |
187 | - { |
188 | - priv->internal = TRUE; |
189 | - return MAX (x - priv->slider.width, screen_width - priv->slider.width); |
190 | + cairo_region_destroy (struts_region); |
191 | + } |
192 | + |
193 | + if (priv->side == OS_SIDE_RIGHT && |
194 | + (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x + priv->thumb_all.width, y) || |
195 | + monitor_x + priv->thumb_all.width >= screen_width)) |
196 | + { |
197 | + priv->internal = TRUE; |
198 | + return MAX (x - priv->thumb_all.width, screen_width - priv->thumb_all.width); |
199 | + } |
200 | + |
201 | + if (priv->side == OS_SIDE_LEFT && |
202 | + (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x - priv->thumb_all.width, y) || |
203 | + monitor_x - priv->thumb_all.width <= screen_x)) |
204 | + { |
205 | + priv->internal = TRUE; |
206 | + return MAX (x, screen_x); |
207 | } |
208 | |
209 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
210 | @@ -484,14 +560,16 @@ |
211 | GdkScreen *screen; |
212 | OsScrollbarPrivate *priv; |
213 | cairo_rectangle_int_t rect; |
214 | - gint screen_height, n_monitor; |
215 | + gint screen_y, screen_height, n_monitor, monitor_y; |
216 | |
217 | priv = scrollbar->priv; |
218 | |
219 | /* the y - 1 coordinate shift is done |
220 | * to calculate monitor boundaries. */ |
221 | + monitor_y = priv->side == OS_SIDE_TOP ? y : y - 1; |
222 | + |
223 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); |
224 | - n_monitor = gdk_screen_get_monitor_at_point (screen, x, y - 1); |
225 | + n_monitor = gdk_screen_get_monitor_at_point (screen, x, monitor_y); |
226 | #ifdef USE_GTK3 |
227 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); |
228 | #else |
229 | @@ -503,42 +581,108 @@ |
230 | rect.height = gdk_rect.height; |
231 | #endif |
232 | |
233 | - if (cairo_region_is_empty (os_workarea)) |
234 | - screen_height = rect.y + rect.height; |
235 | - else |
236 | + screen_y = rect.y; |
237 | + screen_height = rect.y + rect.height; |
238 | + |
239 | + if (!cairo_region_is_empty (os_workarea)) |
240 | { |
241 | cairo_region_t *monitor_workarea; |
242 | + cairo_region_t *struts_region; |
243 | cairo_rectangle_int_t tmp_rect; |
244 | gint i, y, height; |
245 | |
246 | y = rect.y; |
247 | - height = rect.height; |
248 | + height = rect.y + rect.height; |
249 | |
250 | + /* full monitor region */ |
251 | monitor_workarea = cairo_region_create_rectangle (&rect); |
252 | + struts_region = cairo_region_copy (monitor_workarea); |
253 | |
254 | + /* workarea region for current monitor */ |
255 | cairo_region_intersect (monitor_workarea, os_workarea); |
256 | |
257 | - for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++) |
258 | + /* struts region for current monitor */ |
259 | + cairo_region_subtract (struts_region, monitor_workarea); |
260 | + |
261 | + for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) |
262 | { |
263 | - cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect); |
264 | - |
265 | - if (tmp_rect.y > y) |
266 | - y = tmp_rect.y; |
267 | - if (tmp_rect.y + tmp_rect.height < height) |
268 | - height = tmp_rect.y + tmp_rect.height; |
269 | + OsStrutSide strut_side; |
270 | + gint count; |
271 | + |
272 | + cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
273 | + |
274 | + strut_side = OS_STRUT_SIDE_NONE; |
275 | + count = 0; |
276 | + |
277 | + /* determine which side the strut is on */ |
278 | + if (tmp_rect.y == rect.y) |
279 | + { |
280 | + strut_side |= OS_STRUT_SIDE_TOP; |
281 | + count++; |
282 | + } |
283 | + |
284 | + if (tmp_rect.x == rect.x) |
285 | + { |
286 | + strut_side |= OS_STRUT_SIDE_LEFT; |
287 | + count++; |
288 | + } |
289 | + |
290 | + if (tmp_rect.x + tmp_rect.width == rect.x + rect.width) |
291 | + { |
292 | + strut_side |= OS_STRUT_SIDE_RIGHT; |
293 | + count++; |
294 | + } |
295 | + |
296 | + if (tmp_rect.y + tmp_rect.height == rect.y + rect.height) |
297 | + { |
298 | + strut_side |= OS_STRUT_SIDE_BOTTOM; |
299 | + count++; |
300 | + } |
301 | + |
302 | + /* handle multiple sides */ |
303 | + if (count >= 2) |
304 | + { |
305 | + if (tmp_rect.width > tmp_rect.height) |
306 | + strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT); |
307 | + else if (tmp_rect.width < tmp_rect.height) |
308 | + strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM); |
309 | + } |
310 | + |
311 | + /* get the monitor boundaries using the strut */ |
312 | + if (strut_side & OS_STRUT_SIDE_TOP) |
313 | + { |
314 | + if (tmp_rect.y + tmp_rect.height > y) |
315 | + y = tmp_rect.y + tmp_rect.height; |
316 | + } |
317 | + |
318 | + if (strut_side & OS_STRUT_SIDE_BOTTOM) |
319 | + { |
320 | + if (tmp_rect.y < height) |
321 | + height = tmp_rect.y; |
322 | + } |
323 | } |
324 | |
325 | - screen_height = y + height; |
326 | + screen_y = y; |
327 | + screen_height = height; |
328 | |
329 | cairo_region_destroy (monitor_workarea); |
330 | - } |
331 | - |
332 | - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && |
333 | - (n_monitor != gdk_screen_get_monitor_at_point (screen, x, y - 1 + priv->slider.height) || |
334 | - y - 1 + priv->slider.height >= screen_height)) |
335 | - { |
336 | - priv->internal = TRUE; |
337 | - return MAX (y - priv->slider.height, screen_height - priv->slider.height); |
338 | + cairo_region_destroy (struts_region); |
339 | + } |
340 | + |
341 | + if (priv->side == OS_SIDE_BOTTOM && |
342 | + (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y + priv->thumb_all.height) || |
343 | + monitor_y + priv->thumb_all.height >= screen_height)) |
344 | + { |
345 | + priv->internal = TRUE; |
346 | + return MAX (y - priv->thumb_all.height, screen_height - priv->thumb_all.height); |
347 | + } |
348 | + |
349 | + if (priv->side == OS_SIDE_TOP && |
350 | + (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y - priv->thumb_all.height) || |
351 | + monitor_y - priv->thumb_all.height <= screen_y)) |
352 | + { |
353 | + priv->internal = TRUE; |
354 | + return MAX (y, screen_y); |
355 | } |
356 | |
357 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) |
358 | @@ -1580,14 +1724,13 @@ |
359 | static gboolean |
360 | check_proximity (OsScrollbar *scrollbar, |
361 | gint x, |
362 | - gint y, |
363 | - OsSide side) |
364 | + gint y) |
365 | { |
366 | OsScrollbarPrivate *priv; |
367 | |
368 | priv = scrollbar->priv; |
369 | |
370 | - switch (side) |
371 | + switch (priv->side) |
372 | { |
373 | case OS_SIDE_RIGHT: |
374 | return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE && |
375 | @@ -1602,9 +1745,16 @@ |
376 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); |
377 | break; |
378 | case OS_SIDE_LEFT: |
379 | + return (x <= priv->pager_all.x + priv->pager_all.width + PROXIMITY_SIZE && |
380 | + x >= priv->pager_all.x) && |
381 | + (y >= priv->pager_all.y + priv->overlay.y && |
382 | + y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height); |
383 | + break; |
384 | case OS_SIDE_TOP: |
385 | - /* FIXME not implemented yet. |
386 | - * Add support for different scrollbar positions here. */ |
387 | + return (y <= priv->pager_all.y + priv->pager_all.height + PROXIMITY_SIZE && |
388 | + y >= priv->pager_all.y) && |
389 | + (x >= priv->pager_all.x + priv->overlay.x && |
390 | + x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); |
391 | break; |
392 | default: |
393 | break; |
394 | @@ -1655,7 +1805,7 @@ |
395 | /* proximity area */ |
396 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
397 | { |
398 | - if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) |
399 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
400 | { |
401 | priv->can_hide = FALSE; |
402 | |
403 | @@ -1685,7 +1835,7 @@ |
404 | } |
405 | else |
406 | { |
407 | - if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) |
408 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
409 | { |
410 | priv->can_hide = FALSE; |
411 | |
412 | @@ -1776,7 +1926,7 @@ |
413 | /* proximity area */ |
414 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
415 | { |
416 | - if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) |
417 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
418 | { |
419 | priv->can_hide = FALSE; |
420 | |
421 | @@ -1820,7 +1970,7 @@ |
422 | } |
423 | else |
424 | { |
425 | - if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) |
426 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
427 | { |
428 | priv->can_hide = FALSE; |
429 | |
430 | @@ -1903,7 +2053,7 @@ |
431 | /* proximity area */ |
432 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
433 | { |
434 | - if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_RIGHT)) |
435 | + if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) |
436 | { |
437 | priv->can_hide = FALSE; |
438 | |
439 | @@ -1933,7 +2083,7 @@ |
440 | } |
441 | else |
442 | { |
443 | - if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_BOTTOM)) |
444 | + if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) |
445 | { |
446 | priv->can_hide = FALSE; |
447 | |
448 | @@ -2021,7 +2171,7 @@ |
449 | /* proximity area */ |
450 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
451 | { |
452 | - if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_RIGHT)) |
453 | + if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) |
454 | { |
455 | priv->can_hide = FALSE; |
456 | |
457 | @@ -2065,7 +2215,7 @@ |
458 | } |
459 | else |
460 | { |
461 | - if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_BOTTOM)) |
462 | + if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) |
463 | { |
464 | priv->can_hide = FALSE; |
465 | |
466 | @@ -2183,6 +2333,9 @@ |
467 | gdk_window_set_events (root, gdk_window_get_events (root) | |
468 | GDK_PROPERTY_CHANGE_MASK); |
469 | gdk_window_add_filter (root, root_filter_func, NULL); |
470 | + |
471 | + /* initialize the quark */ |
472 | + os_quark_placement = g_quark_from_string ("os_quark_placement"); |
473 | } |
474 | else |
475 | { |
476 | @@ -2204,6 +2357,7 @@ |
477 | priv->lock_position = FALSE; |
478 | priv->proximity = FALSE; |
479 | priv->toplevel_button_press = FALSE; |
480 | + priv->side = OS_SIDE_RIGHT; |
481 | priv->source_deactivate_pager_id = 0; |
482 | priv->source_hide_thumb_id = 0; |
483 | priv->source_unlock_thumb_id = 0; |
484 | @@ -2453,6 +2607,50 @@ |
485 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget); |
486 | } |
487 | |
488 | +/* retrieve the side of the scrollbar */ |
489 | +static void |
490 | +retrieve_side (OsScrollbar *scrollbar) |
491 | +{ |
492 | + GtkCornerType corner; |
493 | + OsScrollbarPrivate *priv; |
494 | + |
495 | + priv = scrollbar->priv; |
496 | + |
497 | + corner = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (scrollbar), os_quark_placement)); |
498 | + |
499 | + if (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar)))) |
500 | + corner = gtk_scrolled_window_get_placement (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar)))); |
501 | + |
502 | + /* GtkCornerType to OsSide */ |
503 | + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) |
504 | + { |
505 | + if (corner == GTK_CORNER_TOP_LEFT || |
506 | + corner == GTK_CORNER_TOP_RIGHT) |
507 | + priv->side = OS_SIDE_BOTTOM; |
508 | + else |
509 | + priv->side = OS_SIDE_TOP; |
510 | + } |
511 | + else |
512 | + { |
513 | + if (gtk_widget_get_direction (GTK_WIDGET (scrollbar)) == GTK_TEXT_DIR_LTR) |
514 | + { |
515 | + if (corner == GTK_CORNER_TOP_LEFT || |
516 | + corner == GTK_CORNER_BOTTOM_LEFT) |
517 | + priv->side = OS_SIDE_RIGHT; |
518 | + else |
519 | + priv->side = OS_SIDE_LEFT; |
520 | + } |
521 | + else |
522 | + { |
523 | + if (corner == GTK_CORNER_TOP_RIGHT || |
524 | + corner == GTK_CORNER_BOTTOM_RIGHT) |
525 | + priv->side = OS_SIDE_RIGHT; |
526 | + else |
527 | + priv->side = OS_SIDE_LEFT; |
528 | + } |
529 | + } |
530 | +} |
531 | + |
532 | static void |
533 | os_scrollbar_size_allocate (GtkWidget *widget, |
534 | GdkRectangle *allocation) |
535 | @@ -2463,6 +2661,9 @@ |
536 | scrollbar = OS_SCROLLBAR (widget); |
537 | priv = scrollbar->priv; |
538 | |
539 | + /* get the side, then move thumb and pager accordingly. */ |
540 | + retrieve_side (scrollbar); |
541 | + |
542 | priv->trough.x = allocation->x; |
543 | priv->trough.y = allocation->y; |
544 | priv->trough.width = allocation->width; |
545 | @@ -2480,12 +2681,18 @@ |
546 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); |
547 | } |
548 | |
549 | - priv->pager_all.x = allocation->x - PAGER_SIZE; |
550 | + if (priv->side == OS_SIDE_RIGHT) |
551 | + priv->pager_all.x = allocation->x - PAGER_SIZE; |
552 | + |
553 | priv->pager_all.width = PAGER_SIZE; |
554 | |
555 | - priv->thumb_all.x = allocation->x + THUMB_ALLOCATION_SHIFT; |
556 | priv->thumb_all.width = THUMB_WIDTH; |
557 | |
558 | + if (priv->side == OS_SIDE_RIGHT) |
559 | + priv->thumb_all.x = allocation->x - priv->pager_all.width; |
560 | + else |
561 | + priv->thumb_all.x = allocation->x + priv->pager_all.width - priv->thumb_all.width; |
562 | + |
563 | allocation->width = 0; |
564 | } |
565 | else |
566 | @@ -2497,11 +2704,17 @@ |
567 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); |
568 | } |
569 | |
570 | - priv->pager_all.y = allocation->y - PAGER_SIZE; |
571 | + if (priv->side == OS_SIDE_BOTTOM) |
572 | + priv->pager_all.y = allocation->y - PAGER_SIZE; |
573 | + |
574 | priv->pager_all.height = PAGER_SIZE; |
575 | |
576 | - priv->thumb_all.y = allocation->y + THUMB_ALLOCATION_SHIFT; |
577 | - priv->thumb_all.height = THUMB_HEIGHT; |
578 | + priv->thumb_all.height = THUMB_WIDTH; |
579 | + |
580 | + if (priv->side == OS_SIDE_BOTTOM) |
581 | + priv->thumb_all.y = allocation->y - priv->pager_all.height; |
582 | + else |
583 | + priv->thumb_all.y = allocation->y + priv->pager_all.height - priv->thumb_all.height; |
584 | |
585 | allocation->height = 0; |
586 | } |
587 | |
588 | === modified file 'os/os-utils.c' |
589 | --- os/os-utils.c 2011-06-09 12:45:39 +0000 |
590 | +++ os/os-utils.c 2011-06-29 10:01:21 +0000 |
591 | @@ -41,7 +41,6 @@ |
592 | "firefox-bin", |
593 | "gnucash", |
594 | "gvim", |
595 | - "meld", |
596 | "pgadmin3", |
597 | "soffice", |
598 | "synaptic", |
599 | @@ -65,10 +64,6 @@ |
600 | } |
601 | g_module_close (module); |
602 | |
603 | - /* Black list RTL languages, not supported yet */ |
604 | - if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) |
605 | - return TRUE; |
606 | - |
607 | for (i = 0; i < nr_programs; i++) |
608 | if (g_strcmp0 (blacklist[i], program) == 0) |
609 | return TRUE; |
610 | |
611 | === modified file 'tests/test-os.c' |
612 | --- tests/test-os.c 2011-03-02 15:29:56 +0000 |
613 | +++ tests/test-os.c 2011-06-29 10:01:21 +0000 |
614 | @@ -270,6 +270,7 @@ |
615 | text_view0 = gtk_text_view_new (); |
616 | gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window_text0), text_view0); |
617 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
618 | + gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_CORNER_BOTTOM_RIGHT); |
619 | |
620 | /* text_buffer0 */ |
621 | text_buffer0 = gtk_text_view_get_buffer(GTK_TEXT_VIEW (text_view0)); |
Need to initialize side.