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.4/gtk/gtkmain.c
5 ===================================================================
6 --- gtk+2.0-2.24.4.orig/gtk/gtkmain.c 2011-05-17 22:38:32.790683626 +0200
7 +++ gtk+2.0-2.24.4/gtk/gtkmain.c 2011-05-17 22:38:33.078685054 +0200
10 _gtk_accel_map_init ();
12 + ubuntu_gtk_scrolled_window_init ();
13 + ubuntu_gtk_hscrollbar_init ();
14 + ubuntu_gtk_vscrollbar_init ();
16 /* Set the 'initialized' flag.
18 Index: gtk+2.0-2.24.4/gtk/gtkscrolledwindow.c
19 ===================================================================
20 --- gtk+2.0-2.24.4.orig/gtk/gtkscrolledwindow.c 2011-05-17 22:37:27.946362079 +0200
21 +++ gtk+2.0-2.24.4/gtk/gtkscrolledwindow.c 2011-05-17 22:39:03.706836932 +0200
24 static guint signals[LAST_SIGNAL] = {0};
26 +static gboolean use_overlay_scrollbar = FALSE;
28 G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
33 gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
35 - if (!scrollbars_within_bevel)
36 + if (!scrollbars_within_bevel && use_overlay_scrollbar == FALSE)
38 gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
42 if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
44 - if (!scrollbars_within_bevel)
45 + if (!scrollbars_within_bevel && use_overlay_scrollbar == FALSE)
47 child_allocation.x -= widget->style->xthickness;
48 child_allocation.width += 2 * widget->style->xthickness;
51 if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
53 - if (!scrollbars_within_bevel)
54 + if (!scrollbars_within_bevel && use_overlay_scrollbar == FALSE)
56 child_allocation.y -= widget->style->ythickness;
57 child_allocation.height += 2 * widget->style->ythickness;
58 @@ -1763,6 +1765,58 @@
62 + * ubuntu_gtk_scrolled_window_init:
64 + * Initialize local use of the overlay-scrollbar module.
66 + * If the module is installed, this code checks both a whitelist
67 + * and a blacklist to decide whether to activate the replacement
70 + * It is possible to force the feature to be disabled by setting
71 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
75 +ubuntu_gtk_scrolled_window_init (void)
77 + static gboolean init_once = FALSE;
79 + if (init_once == FALSE)
81 + GModule *module = NULL;
82 + gpointer symbol = NULL;
84 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
86 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
87 + and disable the feature in this case */
88 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
91 + /* default extension library to use for this release */
92 + gchar *path = "/usr/lib/liboverlay-scrollbar-0.2.so.0";
94 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
98 + /* check the blacklist, in all cases */
99 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
101 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
102 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
106 + use_overlay_scrollbar = TRUE;
114 * _gtk_scrolled_window_get_spacing:
115 * @scrolled_window: a scrolled window
117 @@ -1780,6 +1834,9 @@
119 class = GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_window);
121 + if (use_overlay_scrollbar)
124 if (class->scrollbar_spacing >= 0)
125 return class->scrollbar_spacing;
127 Index: gtk+2.0-2.24.4/gtk/gtkscrolledwindow.h
128 ===================================================================
129 --- gtk+2.0-2.24.4.orig/gtk/gtkscrolledwindow.h 2011-05-17 22:37:27.886361784 +0200
130 +++ gtk+2.0-2.24.4/gtk/gtkscrolledwindow.h 2011-05-17 22:38:33.082685078 +0200
132 void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
135 +void ubuntu_gtk_scrolled_window_init (void);
136 gint _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window);
139 Index: gtk+2.0-2.24.4/gtk/gtkhscrollbar.c
140 ===================================================================
141 --- gtk+2.0-2.24.4.orig/gtk/gtkhscrollbar.c 2011-05-17 22:37:27.978362244 +0200
142 +++ gtk+2.0-2.24.4/gtk/gtkhscrollbar.c 2011-05-17 22:38:33.082685078 +0200
145 #include "gtkalias.h"
147 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
148 +static gboolean use_overlay_scrollbar = FALSE;
150 G_DEFINE_TYPE (GtkHScrollbar, gtk_hscrollbar, GTK_TYPE_SCROLLBAR)
154 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
157 + if (use_overlay_scrollbar)
158 + return os_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
160 return g_object_new (GTK_TYPE_HSCROLLBAR,
161 "adjustment", adjustment,
166 + * ubuntu_gtk_hscrollbar_init:
168 + * Initialize local use of the overlay-scrollbar module.
170 + * If the module is installed, this code checks both a whitelist
171 + * and a blacklist to decide whether to activate the remplacement
174 + * It is possible to force the feature to be disabled by setting
175 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
179 +ubuntu_gtk_hscrollbar_init (void)
181 + static gboolean init_once = FALSE;
183 + if (init_once == FALSE)
185 + GModule *module = NULL;
186 + gpointer symbol = NULL;
188 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
190 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
191 + and disable the feature in this case */
192 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
195 + /* default extension library to use for this release */
196 + gchar *path = "/usr/lib/liboverlay-scrollbar-0.2.so.0";
198 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
199 + if (module == NULL)
202 + /* check the blacklist, in all cases */
203 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
205 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
206 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
210 + /* all controls are positive: the feature can be activated now */
211 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
213 + os_scrollbar_new = symbol;
214 + use_overlay_scrollbar = TRUE;
222 #define __GTK_HSCROLLBAR_C__
223 #include "gtkaliasdef.c"
224 Index: gtk+2.0-2.24.4/gtk/gtkhscrollbar.h
225 ===================================================================
226 --- gtk+2.0-2.24.4.orig/gtk/gtkhscrollbar.h 2011-05-17 22:37:27.862361665 +0200
227 +++ gtk+2.0-2.24.4/gtk/gtkhscrollbar.h 2011-05-17 22:38:33.082685078 +0200
230 GType gtk_hscrollbar_get_type (void) G_GNUC_CONST;
231 GtkWidget* gtk_hscrollbar_new (GtkAdjustment *adjustment);
233 +void ubuntu_gtk_hscrollbar_init (void);
237 Index: gtk+2.0-2.24.4/gtk/gtkvscrollbar.c
238 ===================================================================
239 --- gtk+2.0-2.24.4.orig/gtk/gtkvscrollbar.c 2011-05-17 22:37:27.906361887 +0200
240 +++ gtk+2.0-2.24.4/gtk/gtkvscrollbar.c 2011-05-17 22:38:33.082685078 +0200
243 #include "gtkalias.h"
245 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
246 +static gboolean use_overlay_scrollbar = FALSE;
249 * SECTION:gtkvscrollbar
250 * @Short_description: A vertical scrollbar
252 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
255 + if (use_overlay_scrollbar)
256 + return os_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
258 return g_object_new (GTK_TYPE_VSCROLLBAR,
259 "adjustment", adjustment,
264 + * ubuntu_gtk_vscrollbar_init:
266 + * Initialize local use of the overlay-scrollbar module.
268 + * If the module is installed, this code checks both a whitelist
269 + * and a blacklist to decide whether to activate the remplacement
272 + * It is possible to force the feature to be disabled by setting
273 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
277 +ubuntu_gtk_vscrollbar_init (void)
279 + static gboolean init_once = FALSE;
281 + if (init_once == FALSE)
283 + GModule *module = NULL;
284 + gpointer symbol = NULL;
286 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
288 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
289 + and disable the feature in this case */
290 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
293 + /* default extension library to use for this release */
294 + gchar *path = "/usr/lib/liboverlay-scrollbar-0.2.so.0";
296 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
297 + if (module == NULL)
300 + /* check the blacklist, in all cases */
301 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
303 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
304 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
308 + /* all controls are positive: the feature can be activated now */
309 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
311 + os_scrollbar_new = symbol;
312 + use_overlay_scrollbar = TRUE;
320 #define __GTK_VSCROLLBAR_C__
321 #include "gtkaliasdef.c"
322 Index: gtk+2.0-2.24.4/gtk/gtkvscrollbar.h
323 ===================================================================
324 --- gtk+2.0-2.24.4.orig/gtk/gtkvscrollbar.h 2011-05-17 22:37:27.958362141 +0200
325 +++ gtk+2.0-2.24.4/gtk/gtkvscrollbar.h 2011-05-17 22:38:33.082685078 +0200
328 GType gtk_vscrollbar_get_type (void) G_GNUC_CONST;
329 GtkWidget* gtk_vscrollbar_new (GtkAdjustment *adjustment);
331 +void ubuntu_gtk_vscrollbar_init (void);