1 ## Description: enable overlay scrollbars
2 ## Origin/Author: Andrea Cimitan <andrea.cimitan@canonical.com>
3 === modified file 'gtk/gtkmain.c'
4 Index: gtk+2.0-2.24.6/gtk/gtkmain.c
5 ===================================================================
6 --- gtk+2.0-2.24.6.orig/gtk/gtkmain.c 2011-09-28 13:23:08.000000000 +0200
7 +++ gtk+2.0-2.24.6/gtk/gtkmain.c 2011-09-29 09:15:01.000000000 +0200
12 +static gboolean use_overlay_scrollbar = FALSE;
13 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
16 +ubuntu_gtk_get_use_overlay_scrollbar (void)
18 + return use_overlay_scrollbar;
22 +ubuntu_gtk_set_use_overlay_scrollbar (gboolean use)
24 + use_overlay_scrollbar = use;
29 +_ubuntu_gtk_overlay_scrollbar_new (GtkOrientation orientation, GtkAdjustment* adjustment)
31 + g_return_if_fail (os_scrollbar_new);
32 + return os_scrollbar_new (orientation, adjustment);
36 + * _overlay_scrollbar_init:
38 + * Initialize local use of the overlay-scrollbar module.
40 + * If the module is installed, this code checks both a whitelist
41 + * and a blacklist to decide whether to activate the remplacement
44 + * It is possible to force the feature to be disabled by setting
45 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
49 +_overlay_scrollbar_init (void)
51 + GModule *module = NULL;
52 + gpointer symbol = NULL;
54 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
56 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
57 + and disable the feature in this case */
58 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
61 + /* default extension library to use for this release */
62 + gchar *path = "/usr/lib/liboverlay-scrollbar-0.2.so.0";
64 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
68 + /* check the blacklist, in all cases */
69 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
71 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
72 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
76 + /* all controls are positive: the feature can be activated now */
77 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
79 + os_scrollbar_new = symbol;
80 + use_overlay_scrollbar = TRUE;
85 do_post_parse_initialization (int *argc,
89 _gtk_accel_map_init ();
91 + _overlay_scrollbar_init ();
93 /* Set the 'initialized' flag.
95 Index: gtk+2.0-2.24.6/gtk/gtkscrolledwindow.c
96 ===================================================================
97 --- gtk+2.0-2.24.6.orig/gtk/gtkscrolledwindow.c 2011-09-28 13:23:01.000000000 +0200
98 +++ gtk+2.0-2.24.6/gtk/gtkscrolledwindow.c 2011-09-28 16:24:47.000000000 +0200
100 * under A) at least correspond to the space taken up by its scrollbars.
103 +gboolean ubuntu_gtk_get_use_overlay_scrollbar(void);
105 #define DEFAULT_SCROLLBAR_SPACING 3
108 @@ -1030,7 +1032,7 @@
110 gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
112 - if (!scrollbars_within_bevel)
113 + if (!scrollbars_within_bevel && ubuntu_gtk_get_use_overlay_scrollbar() == FALSE)
115 gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
117 @@ -1490,7 +1492,7 @@
119 if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
121 - if (!scrollbars_within_bevel)
122 + if (!scrollbars_within_bevel && ubuntu_gtk_get_use_overlay_scrollbar() == FALSE)
124 child_allocation.x -= widget->style->xthickness;
125 child_allocation.width += 2 * widget->style->xthickness;
126 @@ -1542,7 +1544,7 @@
128 if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
130 - if (!scrollbars_within_bevel)
131 + if (!scrollbars_within_bevel && ubuntu_gtk_get_use_overlay_scrollbar() == FALSE)
133 child_allocation.y -= widget->style->ythickness;
134 child_allocation.height += 2 * widget->style->ythickness;
135 @@ -1780,6 +1782,9 @@
137 class = GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_window);
139 + if (ubuntu_gtk_get_use_overlay_scrollbar())
142 if (class->scrollbar_spacing >= 0)
143 return class->scrollbar_spacing;
145 Index: gtk+2.0-2.24.6/gtk/gtkhscrollbar.c
146 ===================================================================
147 --- gtk+2.0-2.24.6.orig/gtk/gtkhscrollbar.c 2011-09-28 13:23:01.000000000 +0200
148 +++ gtk+2.0-2.24.6/gtk/gtkhscrollbar.c 2011-09-29 09:15:28.000000000 +0200
151 G_DEFINE_TYPE (GtkHScrollbar, gtk_hscrollbar, GTK_TYPE_SCROLLBAR)
153 +GtkWidget* _ubuntu_gtk_overlay_scrollbar_new (GtkOrientation, GtkAdjustment*);
154 +gboolean ubuntu_gtk_get_use_overlay_scrollbar(void);
157 gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
160 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
163 + if (ubuntu_gtk_get_use_overlay_scrollbar())
164 + return _ubuntu_gtk_overlay_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
166 return g_object_new (GTK_TYPE_HSCROLLBAR,
167 "adjustment", adjustment,
169 Index: gtk+2.0-2.24.6/gtk/gtkvscrollbar.c
170 ===================================================================
171 --- gtk+2.0-2.24.6.orig/gtk/gtkvscrollbar.c 2011-09-28 13:23:01.000000000 +0200
172 +++ gtk+2.0-2.24.6/gtk/gtkvscrollbar.c 2011-09-29 09:15:45.000000000 +0200
175 #include "gtkalias.h"
177 +GtkWidget* _ubuntu_gtk_overlay_scrollbar_new (GtkOrientation, GtkAdjustment*);
178 +gboolean ubuntu_gtk_get_use_overlay_scrollbar (void);
181 * SECTION:gtkvscrollbar
182 * @Short_description: A vertical scrollbar
184 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
187 + if (ubuntu_gtk_get_use_overlay_scrollbar())
188 + return _ubuntu_gtk_overlay_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
190 return g_object_new (GTK_TYPE_VSCROLLBAR,
191 "adjustment", adjustment,