Merge lp:~cimi/overlay-scrollbar/support-different-placement into lp:overlay-scrollbar

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
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+66183@code.launchpad.net

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

Revision history for this message
Ted Gould (ted) wrote :

Need to initialize side.

review: Needs Fixing
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
=== modified file 'configure.ac'
--- configure.ac 2011-06-17 02:48:41 +0000
+++ configure.ac 2011-06-29 10:01:21 +0000
@@ -71,9 +71,9 @@
7171
72AC_ARG_WITH([gtk],72AC_ARG_WITH([gtk],
73 [AS_HELP_STRING([--with-gtk],73 [AS_HELP_STRING([--with-gtk],
74 [Which version of gtk to use @<:@default=2@:>@])],74 [Which version of gtk to use @<:@default=3@:>@])],
75 [],75 [],
76 [with_gtk=2])76 [with_gtk=3])
77AS_IF([test "x$with_gtk" = x3],77AS_IF([test "x$with_gtk" = x3],
78 [PKG_CHECK_MODULES(DEPS, glib-2.0 >= $glib_req gtk+-3.0 >= $gtk3_req cairo >= $cairo_req)78 [PKG_CHECK_MODULES(DEPS, glib-2.0 >= $glib_req gtk+-3.0 >= $gtk3_req cairo >= $cairo_req)
79 AC_SUBST(DEPS_CFLAGS)79 AC_SUBST(DEPS_CFLAGS)
8080
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-06-28 23:04:55 +0000
+++ os/os-scrollbar.c 2011-06-29 10:01:21 +0000
@@ -35,9 +35,6 @@
35/* Size of the pager in pixels. */35/* Size of the pager in pixels. */
36#define PAGER_SIZE 336#define PAGER_SIZE 3
3737
38/* Thumb allocation shift in pixels. */
39#define THUMB_ALLOCATION_SHIFT -3
40
41/* Size of the proximity effect in pixels. */38/* Size of the proximity effect in pixels. */
42#define PROXIMITY_SIZE 3039#define PROXIMITY_SIZE 30
4340
@@ -61,6 +58,15 @@
61 OS_SIDE_RIGHT58 OS_SIDE_RIGHT
62} OsSide;59} OsSide;
6360
61typedef enum
62{
63 OS_STRUT_SIDE_NONE = 0,
64 OS_STRUT_SIDE_TOP = 1,
65 OS_STRUT_SIDE_BOTTOM = 2,
66 OS_STRUT_SIDE_LEFT = 4,
67 OS_STRUT_SIDE_RIGHT = 8
68} OsStrutSide;
69
64struct _OsScrollbarPrivate70struct _OsScrollbarPrivate
65{71{
66 GdkRectangle trough;72 GdkRectangle trough;
@@ -73,6 +79,7 @@
73 GtkOrientation orientation;79 GtkOrientation orientation;
74 GtkWindowGroup *window_group;80 GtkWindowGroup *window_group;
75 OsPager *pager;81 OsPager *pager;
82 OsSide side;
76 gboolean button_press_event;83 gboolean button_press_event;
77 gboolean enter_notify_event;84 gboolean enter_notify_event;
78 gboolean motion_notify_event;85 gboolean motion_notify_event;
@@ -102,6 +109,7 @@
102static Atom unity_net_workarea_region_atom = None;109static Atom unity_net_workarea_region_atom = None;
103static GList *os_root_list = NULL;110static GList *os_root_list = NULL;
104static cairo_region_t *os_workarea = NULL;111static cairo_region_t *os_workarea = NULL;
112static GQuark os_quark_placement = 0;
105113
106static void swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment);114static void swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment);
107static void swap_thumb (OsScrollbar *scrollbar, GtkWidget *thumb);115static void swap_thumb (OsScrollbar *scrollbar, GtkWidget *thumb);
@@ -409,14 +417,16 @@
409 GdkScreen *screen;417 GdkScreen *screen;
410 OsScrollbarPrivate *priv;418 OsScrollbarPrivate *priv;
411 cairo_rectangle_int_t rect;419 cairo_rectangle_int_t rect;
412 gint screen_width, n_monitor;420 gint screen_x, screen_width, n_monitor, monitor_x;
413421
414 priv = scrollbar->priv;422 priv = scrollbar->priv;
415423
416 /* the x - 1 coordinate shift is done 424 /* the x - 1 coordinate shift is done
417 * to calculate monitor boundaries. */425 * to calculate monitor boundaries. */
426 monitor_x = priv->side == OS_SIDE_LEFT ? x : x - 1;
427
418 screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); 428 screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar));
419 n_monitor = gdk_screen_get_monitor_at_point (screen, x - 1, y);429 n_monitor = gdk_screen_get_monitor_at_point (screen, monitor_x, y);
420#ifdef USE_GTK3430#ifdef USE_GTK3
421 gdk_screen_get_monitor_geometry (screen, n_monitor, &rect);431 gdk_screen_get_monitor_geometry (screen, n_monitor, &rect);
422#else432#else
@@ -428,42 +438,108 @@
428 rect.height = gdk_rect.height;438 rect.height = gdk_rect.height;
429#endif439#endif
430440
431 if (cairo_region_is_empty (os_workarea))441 screen_x = rect.x;
432 screen_width = rect.x + rect.width;442 screen_width = rect.x + rect.width;
433 else443
444 if (!cairo_region_is_empty (os_workarea))
434 {445 {
435 cairo_region_t *monitor_workarea;446 cairo_region_t *monitor_workarea;
447 cairo_region_t *struts_region;
436 cairo_rectangle_int_t tmp_rect;448 cairo_rectangle_int_t tmp_rect;
437 gint i, x, width;449 gint i, x, width;
438450
439 x = rect.x;451 x = rect.x;
440 width = rect.width;452 width = rect.x + rect.width;
441453
454 /* full monitor region */
442 monitor_workarea = cairo_region_create_rectangle (&rect);455 monitor_workarea = cairo_region_create_rectangle (&rect);
456 struts_region = cairo_region_copy (monitor_workarea);
443457
458 /* workarea region for current monitor */
444 cairo_region_intersect (monitor_workarea, os_workarea);459 cairo_region_intersect (monitor_workarea, os_workarea);
445460
446 for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++)461 /* struts region for current monitor */
462 cairo_region_subtract (struts_region, monitor_workarea);
463
464 for (i = 0; i < cairo_region_num_rectangles (struts_region); i++)
447 {465 {
448 cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect);466 OsStrutSide strut_side;
449467 gint count;
450 if (tmp_rect.x > x)468
451 x = tmp_rect.x;469 cairo_region_get_rectangle (struts_region, i, &tmp_rect);
452 if (tmp_rect.x + tmp_rect.width < width)470
453 width = tmp_rect.x + tmp_rect.width;471 strut_side = OS_STRUT_SIDE_NONE;
472 count = 0;
473
474 /* determine which side the strut is on */
475 if (tmp_rect.y == rect.y)
476 {
477 strut_side |= OS_STRUT_SIDE_TOP;
478 count++;
479 }
480
481 if (tmp_rect.x == rect.x)
482 {
483 strut_side |= OS_STRUT_SIDE_LEFT;
484 count++;
485 }
486
487 if (tmp_rect.x + tmp_rect.width == rect.x + rect.width)
488 {
489 strut_side |= OS_STRUT_SIDE_RIGHT;
490 count++;
491 }
492
493 if (tmp_rect.y + tmp_rect.height == rect.y + rect.height)
494 {
495 strut_side |= OS_STRUT_SIDE_BOTTOM;
496 count++;
497 }
498
499 /* handle multiple sides */
500 if (count >= 2)
501 {
502 if (tmp_rect.width > tmp_rect.height)
503 strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT);
504 else if (tmp_rect.width < tmp_rect.height)
505 strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM);
506 }
507
508 /* get the monitor boundaries using the strut */
509 if (strut_side & OS_STRUT_SIDE_LEFT)
510 {
511 if (tmp_rect.x + tmp_rect.width > x)
512 x = tmp_rect.x + tmp_rect.width;
513 }
514
515 if (strut_side & OS_STRUT_SIDE_RIGHT)
516 {
517 if (tmp_rect.x < width)
518 width = tmp_rect.x;
519 }
454 }520 }
455521
456 screen_width = x + width;522 screen_x = x;
523 screen_width = width;
457524
458 cairo_region_destroy (monitor_workarea);525 cairo_region_destroy (monitor_workarea);
459 }526 cairo_region_destroy (struts_region);
460527 }
461 if (priv->orientation == GTK_ORIENTATION_VERTICAL &&528
462 (n_monitor != gdk_screen_get_monitor_at_point (screen, x - 1 + priv->slider.width, y) ||529 if (priv->side == OS_SIDE_RIGHT &&
463 x - 1 + priv->slider.width >= screen_width))530 (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x + priv->thumb_all.width, y) ||
464 {531 monitor_x + priv->thumb_all.width >= screen_width))
465 priv->internal = TRUE;532 {
466 return MAX (x - priv->slider.width, screen_width - priv->slider.width);533 priv->internal = TRUE;
534 return MAX (x - priv->thumb_all.width, screen_width - priv->thumb_all.width);
535 }
536
537 if (priv->side == OS_SIDE_LEFT &&
538 (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x - priv->thumb_all.width, y) ||
539 monitor_x - priv->thumb_all.width <= screen_x))
540 {
541 priv->internal = TRUE;
542 return MAX (x, screen_x);
467 }543 }
468544
469 if (priv->orientation == GTK_ORIENTATION_VERTICAL)545 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
@@ -484,14 +560,16 @@
484 GdkScreen *screen;560 GdkScreen *screen;
485 OsScrollbarPrivate *priv;561 OsScrollbarPrivate *priv;
486 cairo_rectangle_int_t rect;562 cairo_rectangle_int_t rect;
487 gint screen_height, n_monitor;563 gint screen_y, screen_height, n_monitor, monitor_y;
488564
489 priv = scrollbar->priv;565 priv = scrollbar->priv;
490566
491 /* the y - 1 coordinate shift is done 567 /* the y - 1 coordinate shift is done
492 * to calculate monitor boundaries. */568 * to calculate monitor boundaries. */
569 monitor_y = priv->side == OS_SIDE_TOP ? y : y - 1;
570
493 screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); 571 screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar));
494 n_monitor = gdk_screen_get_monitor_at_point (screen, x, y - 1);572 n_monitor = gdk_screen_get_monitor_at_point (screen, x, monitor_y);
495#ifdef USE_GTK3573#ifdef USE_GTK3
496 gdk_screen_get_monitor_geometry (screen, n_monitor, &rect);574 gdk_screen_get_monitor_geometry (screen, n_monitor, &rect);
497#else575#else
@@ -503,42 +581,108 @@
503 rect.height = gdk_rect.height;581 rect.height = gdk_rect.height;
504#endif582#endif
505583
506 if (cairo_region_is_empty (os_workarea)) 584 screen_y = rect.y;
507 screen_height = rect.y + rect.height;585 screen_height = rect.y + rect.height;
508 else586
587 if (!cairo_region_is_empty (os_workarea))
509 {588 {
510 cairo_region_t *monitor_workarea;589 cairo_region_t *monitor_workarea;
590 cairo_region_t *struts_region;
511 cairo_rectangle_int_t tmp_rect;591 cairo_rectangle_int_t tmp_rect;
512 gint i, y, height;592 gint i, y, height;
513593
514 y = rect.y;594 y = rect.y;
515 height = rect.height;595 height = rect.y + rect.height;
516596
597 /* full monitor region */
517 monitor_workarea = cairo_region_create_rectangle (&rect);598 monitor_workarea = cairo_region_create_rectangle (&rect);
599 struts_region = cairo_region_copy (monitor_workarea);
518600
601 /* workarea region for current monitor */
519 cairo_region_intersect (monitor_workarea, os_workarea);602 cairo_region_intersect (monitor_workarea, os_workarea);
520603
521 for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++)604 /* struts region for current monitor */
605 cairo_region_subtract (struts_region, monitor_workarea);
606
607 for (i = 0; i < cairo_region_num_rectangles (struts_region); i++)
522 {608 {
523 cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect);609 OsStrutSide strut_side;
524610 gint count;
525 if (tmp_rect.y > y)611
526 y = tmp_rect.y;612 cairo_region_get_rectangle (struts_region, i, &tmp_rect);
527 if (tmp_rect.y + tmp_rect.height < height)613
528 height = tmp_rect.y + tmp_rect.height;614 strut_side = OS_STRUT_SIDE_NONE;
615 count = 0;
616
617 /* determine which side the strut is on */
618 if (tmp_rect.y == rect.y)
619 {
620 strut_side |= OS_STRUT_SIDE_TOP;
621 count++;
622 }
623
624 if (tmp_rect.x == rect.x)
625 {
626 strut_side |= OS_STRUT_SIDE_LEFT;
627 count++;
628 }
629
630 if (tmp_rect.x + tmp_rect.width == rect.x + rect.width)
631 {
632 strut_side |= OS_STRUT_SIDE_RIGHT;
633 count++;
634 }
635
636 if (tmp_rect.y + tmp_rect.height == rect.y + rect.height)
637 {
638 strut_side |= OS_STRUT_SIDE_BOTTOM;
639 count++;
640 }
641
642 /* handle multiple sides */
643 if (count >= 2)
644 {
645 if (tmp_rect.width > tmp_rect.height)
646 strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT);
647 else if (tmp_rect.width < tmp_rect.height)
648 strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM);
649 }
650
651 /* get the monitor boundaries using the strut */
652 if (strut_side & OS_STRUT_SIDE_TOP)
653 {
654 if (tmp_rect.y + tmp_rect.height > y)
655 y = tmp_rect.y + tmp_rect.height;
656 }
657
658 if (strut_side & OS_STRUT_SIDE_BOTTOM)
659 {
660 if (tmp_rect.y < height)
661 height = tmp_rect.y;
662 }
529 }663 }
530664
531 screen_height = y + height;665 screen_y = y;
666 screen_height = height;
532667
533 cairo_region_destroy (monitor_workarea);668 cairo_region_destroy (monitor_workarea);
534 }669 cairo_region_destroy (struts_region);
535670 }
536 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&671
537 (n_monitor != gdk_screen_get_monitor_at_point (screen, x, y - 1 + priv->slider.height) ||672 if (priv->side == OS_SIDE_BOTTOM &&
538 y - 1 + priv->slider.height >= screen_height))673 (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y + priv->thumb_all.height) ||
539 {674 monitor_y + priv->thumb_all.height >= screen_height))
540 priv->internal = TRUE;675 {
541 return MAX (y - priv->slider.height, screen_height - priv->slider.height);676 priv->internal = TRUE;
677 return MAX (y - priv->thumb_all.height, screen_height - priv->thumb_all.height);
678 }
679
680 if (priv->side == OS_SIDE_TOP &&
681 (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y - priv->thumb_all.height) ||
682 monitor_y - priv->thumb_all.height <= screen_y))
683 {
684 priv->internal = TRUE;
685 return MAX (y, screen_y);
542 }686 }
543687
544 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)688 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -1580,14 +1724,13 @@
1580static gboolean1724static gboolean
1581check_proximity (OsScrollbar *scrollbar,1725check_proximity (OsScrollbar *scrollbar,
1582 gint x,1726 gint x,
1583 gint y,1727 gint y)
1584 OsSide side)
1585{1728{
1586 OsScrollbarPrivate *priv;1729 OsScrollbarPrivate *priv;
15871730
1588 priv = scrollbar->priv;1731 priv = scrollbar->priv;
1589 1732
1590 switch (side)1733 switch (priv->side)
1591 {1734 {
1592 case OS_SIDE_RIGHT:1735 case OS_SIDE_RIGHT:
1593 return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE &&1736 return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE &&
@@ -1602,9 +1745,16 @@
1602 x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width);1745 x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width);
1603 break;1746 break;
1604 case OS_SIDE_LEFT:1747 case OS_SIDE_LEFT:
1748 return (x <= priv->pager_all.x + priv->pager_all.width + PROXIMITY_SIZE &&
1749 x >= priv->pager_all.x) &&
1750 (y >= priv->pager_all.y + priv->overlay.y &&
1751 y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height);
1752 break;
1605 case OS_SIDE_TOP:1753 case OS_SIDE_TOP:
1606 /* FIXME not implemented yet.1754 return (y <= priv->pager_all.y + priv->pager_all.height + PROXIMITY_SIZE &&
1607 * Add support for different scrollbar positions here. */1755 y >= priv->pager_all.y) &&
1756 (x >= priv->pager_all.x + priv->overlay.x &&
1757 x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width);
1608 break;1758 break;
1609 default:1759 default:
1610 break;1760 break;
@@ -1655,7 +1805,7 @@
1655 /* proximity area */1805 /* proximity area */
1656 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1806 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1657 {1807 {
1658 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT))1808 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))
1659 {1809 {
1660 priv->can_hide = FALSE;1810 priv->can_hide = FALSE;
16611811
@@ -1685,7 +1835,7 @@
1685 }1835 }
1686 else1836 else
1687 {1837 {
1688 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM))1838 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))
1689 {1839 {
1690 priv->can_hide = FALSE;1840 priv->can_hide = FALSE;
16911841
@@ -1776,7 +1926,7 @@
1776 /* proximity area */1926 /* proximity area */
1777 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1927 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1778 {1928 {
1779 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT))1929 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))
1780 {1930 {
1781 priv->can_hide = FALSE;1931 priv->can_hide = FALSE;
17821932
@@ -1820,7 +1970,7 @@
1820 }1970 }
1821 else1971 else
1822 {1972 {
1823 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM))1973 if (check_proximity (scrollbar, xiev->event_x, xiev->event_y))
1824 {1974 {
1825 priv->can_hide = FALSE;1975 priv->can_hide = FALSE;
18261976
@@ -1903,7 +2053,7 @@
1903 /* proximity area */2053 /* proximity area */
1904 if (priv->orientation == GTK_ORIENTATION_VERTICAL)2054 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1905 {2055 {
1906 if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_RIGHT))2056 if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y))
1907 {2057 {
1908 priv->can_hide = FALSE;2058 priv->can_hide = FALSE;
19092059
@@ -1933,7 +2083,7 @@
1933 }2083 }
1934 else2084 else
1935 {2085 {
1936 if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_BOTTOM))2086 if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y))
1937 {2087 {
1938 priv->can_hide = FALSE;2088 priv->can_hide = FALSE;
19392089
@@ -2021,7 +2171,7 @@
2021 /* proximity area */2171 /* proximity area */
2022 if (priv->orientation == GTK_ORIENTATION_VERTICAL)2172 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
2023 {2173 {
2024 if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_RIGHT))2174 if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y))
2025 {2175 {
2026 priv->can_hide = FALSE;2176 priv->can_hide = FALSE;
20272177
@@ -2065,7 +2215,7 @@
2065 }2215 }
2066 else2216 else
2067 {2217 {
2068 if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_BOTTOM))2218 if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y))
2069 {2219 {
2070 priv->can_hide = FALSE;2220 priv->can_hide = FALSE;
20712221
@@ -2183,6 +2333,9 @@
2183 gdk_window_set_events (root, gdk_window_get_events (root) |2333 gdk_window_set_events (root, gdk_window_get_events (root) |
2184 GDK_PROPERTY_CHANGE_MASK);2334 GDK_PROPERTY_CHANGE_MASK);
2185 gdk_window_add_filter (root, root_filter_func, NULL);2335 gdk_window_add_filter (root, root_filter_func, NULL);
2336
2337 /* initialize the quark */
2338 os_quark_placement = g_quark_from_string ("os_quark_placement");
2186 }2339 }
2187 else2340 else
2188 {2341 {
@@ -2204,6 +2357,7 @@
2204 priv->lock_position = FALSE;2357 priv->lock_position = FALSE;
2205 priv->proximity = FALSE;2358 priv->proximity = FALSE;
2206 priv->toplevel_button_press = FALSE;2359 priv->toplevel_button_press = FALSE;
2360 priv->side = OS_SIDE_RIGHT;
2207 priv->source_deactivate_pager_id = 0;2361 priv->source_deactivate_pager_id = 0;
2208 priv->source_hide_thumb_id = 0;2362 priv->source_hide_thumb_id = 0;
2209 priv->source_unlock_thumb_id = 0;2363 priv->source_unlock_thumb_id = 0;
@@ -2453,6 +2607,50 @@
2453 GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget);2607 GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget);
2454}2608}
24552609
2610/* retrieve the side of the scrollbar */
2611static void
2612retrieve_side (OsScrollbar *scrollbar)
2613{
2614 GtkCornerType corner;
2615 OsScrollbarPrivate *priv;
2616
2617 priv = scrollbar->priv;
2618
2619 corner = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (scrollbar), os_quark_placement));
2620
2621 if (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar))))
2622 corner = gtk_scrolled_window_get_placement (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar))));
2623
2624 /* GtkCornerType to OsSide */
2625 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
2626 {
2627 if (corner == GTK_CORNER_TOP_LEFT ||
2628 corner == GTK_CORNER_TOP_RIGHT)
2629 priv->side = OS_SIDE_BOTTOM;
2630 else
2631 priv->side = OS_SIDE_TOP;
2632 }
2633 else
2634 {
2635 if (gtk_widget_get_direction (GTK_WIDGET (scrollbar)) == GTK_TEXT_DIR_LTR)
2636 {
2637 if (corner == GTK_CORNER_TOP_LEFT ||
2638 corner == GTK_CORNER_BOTTOM_LEFT)
2639 priv->side = OS_SIDE_RIGHT;
2640 else
2641 priv->side = OS_SIDE_LEFT;
2642 }
2643 else
2644 {
2645 if (corner == GTK_CORNER_TOP_RIGHT ||
2646 corner == GTK_CORNER_BOTTOM_RIGHT)
2647 priv->side = OS_SIDE_RIGHT;
2648 else
2649 priv->side = OS_SIDE_LEFT;
2650 }
2651 }
2652}
2653
2456static void2654static void
2457os_scrollbar_size_allocate (GtkWidget *widget,2655os_scrollbar_size_allocate (GtkWidget *widget,
2458 GdkRectangle *allocation)2656 GdkRectangle *allocation)
@@ -2463,6 +2661,9 @@
2463 scrollbar = OS_SCROLLBAR (widget);2661 scrollbar = OS_SCROLLBAR (widget);
2464 priv = scrollbar->priv;2662 priv = scrollbar->priv;
24652663
2664 /* get the side, then move thumb and pager accordingly. */
2665 retrieve_side (scrollbar);
2666
2466 priv->trough.x = allocation->x;2667 priv->trough.x = allocation->x;
2467 priv->trough.y = allocation->y;2668 priv->trough.y = allocation->y;
2468 priv->trough.width = allocation->width;2669 priv->trough.width = allocation->width;
@@ -2480,12 +2681,18 @@
2480 os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height);2681 os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height);
2481 }2682 }
24822683
2483 priv->pager_all.x = allocation->x - PAGER_SIZE;2684 if (priv->side == OS_SIDE_RIGHT)
2685 priv->pager_all.x = allocation->x - PAGER_SIZE;
2686
2484 priv->pager_all.width = PAGER_SIZE;2687 priv->pager_all.width = PAGER_SIZE;
24852688
2486 priv->thumb_all.x = allocation->x + THUMB_ALLOCATION_SHIFT;
2487 priv->thumb_all.width = THUMB_WIDTH;2689 priv->thumb_all.width = THUMB_WIDTH;
24882690
2691 if (priv->side == OS_SIDE_RIGHT)
2692 priv->thumb_all.x = allocation->x - priv->pager_all.width;
2693 else
2694 priv->thumb_all.x = allocation->x + priv->pager_all.width - priv->thumb_all.width;
2695
2489 allocation->width = 0;2696 allocation->width = 0;
2490 }2697 }
2491 else2698 else
@@ -2497,11 +2704,17 @@
2497 os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height);2704 os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height);
2498 }2705 }
24992706
2500 priv->pager_all.y = allocation->y - PAGER_SIZE;2707 if (priv->side == OS_SIDE_BOTTOM)
2708 priv->pager_all.y = allocation->y - PAGER_SIZE;
2709
2501 priv->pager_all.height = PAGER_SIZE;2710 priv->pager_all.height = PAGER_SIZE;
25022711
2503 priv->thumb_all.y = allocation->y + THUMB_ALLOCATION_SHIFT;2712 priv->thumb_all.height = THUMB_WIDTH;
2504 priv->thumb_all.height = THUMB_HEIGHT;2713
2714 if (priv->side == OS_SIDE_BOTTOM)
2715 priv->thumb_all.y = allocation->y - priv->pager_all.height;
2716 else
2717 priv->thumb_all.y = allocation->y + priv->pager_all.height - priv->thumb_all.height;
25052718
2506 allocation->height = 0;2719 allocation->height = 0;
2507 }2720 }
25082721
=== modified file 'os/os-utils.c'
--- os/os-utils.c 2011-06-09 12:45:39 +0000
+++ os/os-utils.c 2011-06-29 10:01:21 +0000
@@ -41,7 +41,6 @@
41 "firefox-bin",41 "firefox-bin",
42 "gnucash",42 "gnucash",
43 "gvim",43 "gvim",
44 "meld",
45 "pgadmin3",44 "pgadmin3",
46 "soffice",45 "soffice",
47 "synaptic",46 "synaptic",
@@ -65,10 +64,6 @@
65 }64 }
66 g_module_close (module);65 g_module_close (module);
6766
68 /* Black list RTL languages, not supported yet */
69 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
70 return TRUE;
71
72 for (i = 0; i < nr_programs; i++)67 for (i = 0; i < nr_programs; i++)
73 if (g_strcmp0 (blacklist[i], program) == 0)68 if (g_strcmp0 (blacklist[i], program) == 0)
74 return TRUE;69 return TRUE;
7570
=== modified file 'tests/test-os.c'
--- tests/test-os.c 2011-03-02 15:29:56 +0000
+++ tests/test-os.c 2011-06-29 10:01:21 +0000
@@ -270,6 +270,7 @@
270 text_view0 = gtk_text_view_new ();270 text_view0 = gtk_text_view_new ();
271 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window_text0), text_view0);271 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window_text0), text_view0);
272 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);272 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
273 gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_CORNER_BOTTOM_RIGHT);
273274
274 /* text_buffer0 */275 /* text_buffer0 */
275 text_buffer0 = gtk_text_view_get_buffer(GTK_TEXT_VIEW (text_view0));276 text_buffer0 = gtk_text_view_get_buffer(GTK_TEXT_VIEW (text_view0));

Subscribers

People subscribed via source and target branches