updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / gtk3-ubuntu / 100_overlay_scrollbar_loading.patch
blob1f46fa6acac0f37a1654408eb6273115b8cc2850
1 === modified file 'gtk/gtkhscrollbar.c'
2 Index: gtk+3.0-3.1.16/gtk/gtkhscrollbar.c
3 ===================================================================
4 --- gtk+3.0-3.1.16.orig/gtk/gtkhscrollbar.c 2011-09-05 08:52:01.439554654 +0200
5 +++ gtk+3.0-3.1.16/gtk/gtkhscrollbar.c 2011-09-05 08:52:44.339554938 +0200
6 @@ -33,6 +33,8 @@
7 #include "gtkorientable.h"
8 #include "gtkintl.h"
10 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
11 +static gboolean use_overlay_scrollbar = FALSE;
13 /**
14 * SECTION:gtkhscrollbar
15 @@ -82,7 +84,67 @@
16 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
17 NULL);
19 + if (use_overlay_scrollbar)
20 + return os_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
22 return g_object_new (GTK_TYPE_HSCROLLBAR,
23 "adjustment", adjustment,
24 NULL);
27 +/*
28 + * ubuntu_gtk_hscrollbar_init:
29 + *
30 + * Initialize local use of the overlay-scrollbar module.
31 + *
32 + * If the module is installed, this code checks both a whitelist
33 + * and a blacklist to decide whether to activate the remplacement
34 + * scrollbars.
35 + *
36 + * It is possible to force the feature to be disabled by setting
37 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
38 + * empty value.
39 + */
40 +void
41 +ubuntu_gtk_hscrollbar_init (void)
43 + static gboolean init_once = FALSE;
45 + if (init_once == FALSE)
46 + {
47 + GModule *module = NULL;
48 + gpointer symbol = NULL;
50 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
52 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
53 + and disable the feature in this case */
54 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
55 + goto skip_loading;
57 + /* default extension library to use for this release */
58 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
60 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
61 + if (module == NULL)
62 + goto skip_loading;
64 + /* check the blacklist, in all cases */
65 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
66 + {
67 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
68 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
69 + goto skip_loading;
70 + }
72 + /* all controls are positive: the feature can be activated now */
73 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
74 + {
75 + os_scrollbar_new = symbol;
76 + use_overlay_scrollbar = TRUE;
77 + }
79 +skip_loading:
80 + init_once = TRUE;
81 + }
83 Index: gtk+3.0-3.1.16/gtk/gtkhscrollbar.h
84 ===================================================================
85 --- gtk+3.0-3.1.16.orig/gtk/gtkhscrollbar.h 2011-09-05 08:52:01.459554651 +0200
86 +++ gtk+3.0-3.1.16/gtk/gtkhscrollbar.h 2011-09-05 08:52:44.339554938 +0200
87 @@ -63,6 +63,7 @@
89 GType gtk_hscrollbar_get_type (void) G_GNUC_CONST;
90 GtkWidget* gtk_hscrollbar_new (GtkAdjustment *adjustment);
91 +void ubuntu_gtk_hscrollbar_init (void);
94 G_END_DECLS
95 Index: gtk+3.0-3.1.16/gtk/gtkmain.c
96 ===================================================================
97 --- gtk+3.0-3.1.16.orig/gtk/gtkmain.c 2011-09-05 08:52:19.209554770 +0200
98 +++ gtk+3.0-3.1.16/gtk/gtkmain.c 2011-09-05 08:52:44.349554937 +0200
99 @@ -857,6 +857,11 @@
101 _gtk_accel_map_init ();
103 + ubuntu_gtk_scrolled_window_init ();
104 + ubuntu_gtk_scrollbar_init ();
105 + ubuntu_gtk_hscrollbar_init ();
106 + ubuntu_gtk_vscrollbar_init ();
108 /* Set the 'initialized' flag.
110 gtk_initialized = TRUE;
111 Index: gtk+3.0-3.1.16/gtk/gtkscrollbar.c
112 ===================================================================
113 --- gtk+3.0-3.1.16.orig/gtk/gtkscrollbar.c 2011-09-05 08:52:01.499554651 +0200
114 +++ gtk+3.0-3.1.16/gtk/gtkscrollbar.c 2011-09-05 08:52:44.349554937 +0200
115 @@ -58,6 +58,9 @@
117 static void gtk_scrollbar_style_updated (GtkWidget *widget);
119 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
120 +static gboolean use_overlay_scrollbar = FALSE;
122 G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE)
124 static void
125 @@ -166,8 +169,68 @@
126 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
127 NULL);
129 + if (use_overlay_scrollbar)
130 + return os_scrollbar_new (orientation, adjustment);
132 return g_object_new (GTK_TYPE_SCROLLBAR,
133 "orientation", orientation,
134 "adjustment", adjustment,
135 NULL);
139 + * ubuntu_gtk_scrollbar_init:
141 + * Initialize local use of the overlay-scrollbar module.
142 + *
143 + * If the module is installed, this code checks both a whitelist
144 + * and a blacklist to decide whether to activate the remplacement
145 + * scrollbars.
147 + * It is possible to force the feature to be disabled by setting
148 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
149 + * empty value.
150 + */
151 +void
152 +ubuntu_gtk_scrollbar_init (void)
154 + static gboolean init_once = FALSE;
156 + if (init_once == FALSE)
158 + GModule *module = NULL;
159 + gpointer symbol = NULL;
161 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
163 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
164 + and disable the feature in this case */
165 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
166 + goto skip_loading;
168 + /* default extension library to use for this release */
169 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
171 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
172 + if (module == NULL)
173 + goto skip_loading;
175 + /* check the blacklist, in all cases */
176 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
178 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
179 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
180 + goto skip_loading;
183 + /* all controls are positive: the feature can be activated now */
184 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
186 + os_scrollbar_new = symbol;
187 + use_overlay_scrollbar = TRUE;
190 +skip_loading:
191 + init_once = TRUE;
194 Index: gtk+3.0-3.1.16/gtk/gtkscrollbar.h
195 ===================================================================
196 --- gtk+3.0-3.1.16.orig/gtk/gtkscrollbar.h 2011-09-05 08:52:01.539554654 +0200
197 +++ gtk+3.0-3.1.16/gtk/gtkscrollbar.h 2011-09-05 08:52:44.349554937 +0200
198 @@ -68,6 +68,7 @@
199 GType gtk_scrollbar_get_type (void) G_GNUC_CONST;
200 GtkWidget * gtk_scrollbar_new (GtkOrientation orientation,
201 GtkAdjustment *adjustment);
202 +void ubuntu_gtk_scrollbar_init (void);
204 G_END_DECLS
206 Index: gtk+3.0-3.1.16/gtk/gtkscrolledwindow.c
207 ===================================================================
208 --- gtk+3.0-3.1.16.orig/gtk/gtkscrolledwindow.c 2011-09-05 08:52:01.429554652 +0200
209 +++ gtk+3.0-3.1.16/gtk/gtkscrolledwindow.c 2011-09-05 08:52:44.349554937 +0200
210 @@ -220,6 +220,8 @@
212 static guint signals[LAST_SIGNAL] = {0};
214 +static gboolean use_overlay_scrollbar = FALSE;
216 G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
219 @@ -1212,7 +1214,7 @@
221 gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
223 - if (!scrollbars_within_bevel)
224 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
226 GtkStateFlags state;
227 GtkBorder padding, border;
228 @@ -1768,7 +1770,7 @@
230 if (priv->shadow_type != GTK_SHADOW_NONE)
232 - if (!scrollbars_within_bevel)
233 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
235 child_allocation.x -= padding.left + border.left;
236 child_allocation.width += padding.left + padding.right + border.left + border.right;
237 @@ -1816,7 +1818,7 @@
239 if (priv->shadow_type != GTK_SHADOW_NONE)
241 - if (!scrollbars_within_bevel)
242 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
244 child_allocation.y -= padding.top + border.top;
245 child_allocation.height += padding.top + padding.bottom + border.top + border.bottom;
246 @@ -2057,6 +2059,58 @@
250 + * ubuntu_gtk_scrolled_window_init:
252 + * Initialize local use of the overlay-scrollbar module.
253 + *
254 + * If the module is installed, this code checks both a whitelist
255 + * and a blacklist to decide whether to activate the remplacement
256 + * scrollbars.
258 + * It is possible to force the feature to be disabled by setting
259 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
260 + * empty value.
261 + */
262 +void
263 +ubuntu_gtk_scrolled_window_init (void)
265 + static gboolean init_once = FALSE;
267 + if (init_once == FALSE)
269 + GModule *module = NULL;
270 + gpointer symbol = NULL;
272 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
274 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
275 + and disable the feature in this case */
276 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
277 + goto skip_loading;
279 + /* default extension library to use for this release */
280 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
282 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
283 + if (module == NULL)
284 + goto skip_loading;
286 + /* check the blacklist, in all cases */
287 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
289 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
290 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
291 + goto skip_loading;
294 + use_overlay_scrollbar = TRUE;
296 +skip_loading:
297 + init_once = TRUE;
302 * _gtk_scrolled_window_get_spacing:
303 * @scrolled_window: a scrolled window
305 @@ -2072,6 +2126,9 @@
307 g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0);
309 + if (use_overlay_scrollbar)
310 + return 0;
312 class = GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_window);
314 if (class->scrollbar_spacing >= 0)
315 Index: gtk+3.0-3.1.16/gtk/gtkscrolledwindow.h
316 ===================================================================
317 --- gtk+3.0-3.1.16.orig/gtk/gtkscrolledwindow.h 2011-09-05 08:52:01.519554653 +0200
318 +++ gtk+3.0-3.1.16/gtk/gtkscrolledwindow.h 2011-09-05 08:52:44.349554937 +0200
319 @@ -119,6 +119,7 @@
320 gint height);
322 gint _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window);
323 +void ubuntu_gtk_scrolled_window_init (void);
326 G_END_DECLS
327 Index: gtk+3.0-3.1.16/gtk/gtkvscrollbar.c
328 ===================================================================
329 --- gtk+3.0-3.1.16.orig/gtk/gtkvscrollbar.c 2011-09-05 08:52:01.469554652 +0200
330 +++ gtk+3.0-3.1.16/gtk/gtkvscrollbar.c 2011-09-05 08:52:44.349554937 +0200
331 @@ -33,6 +33,8 @@
332 #include "gtkvscrollbar.h"
333 #include "gtkintl.h"
335 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
336 +static gboolean use_overlay_scrollbar = FALSE;
339 * SECTION:gtkvscrollbar
340 @@ -81,7 +83,67 @@
341 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
342 NULL);
344 + if (use_overlay_scrollbar)
345 + return os_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
347 return g_object_new (GTK_TYPE_VSCROLLBAR,
348 "adjustment", adjustment,
349 NULL);
353 + * ubuntu_gtk_vscrollbar_init:
355 + * Initialize local use of the overlay-scrollbar module.
356 + *
357 + * If the module is installed, this code checks both a whitelist
358 + * and a blacklist to decide whether to activate the remplacement
359 + * scrollbars.
361 + * It is possible to force the feature to be disabled by setting
362 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
363 + * empty value.
364 + */
365 +void
366 +ubuntu_gtk_vscrollbar_init (void)
368 + static gboolean init_once = FALSE;
370 + if (init_once == FALSE)
372 + GModule *module = NULL;
373 + gpointer symbol = NULL;
375 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
377 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
378 + and disable the feature in this case */
379 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
380 + goto skip_loading;
382 + /* default extension library to use for this release */
383 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
385 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
386 + if (module == NULL)
387 + goto skip_loading;
389 + /* check the blacklist, in all cases */
390 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
392 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
393 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
394 + goto skip_loading;
397 + /* all controls are positive: the feature can be activated now */
398 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
400 + os_scrollbar_new = symbol;
401 + use_overlay_scrollbar = TRUE;
404 +skip_loading:
405 + init_once = TRUE;
408 Index: gtk+3.0-3.1.16/gtk/gtkvscrollbar.h
409 ===================================================================
410 --- gtk+3.0-3.1.16.orig/gtk/gtkvscrollbar.h 2011-09-05 08:52:01.479554654 +0200
411 +++ gtk+3.0-3.1.16/gtk/gtkvscrollbar.h 2011-09-05 08:52:44.349554937 +0200
412 @@ -69,6 +69,7 @@
414 GType gtk_vscrollbar_get_type (void) G_GNUC_CONST;
415 GtkWidget* gtk_vscrollbar_new (GtkAdjustment *adjustment);
416 +void ubuntu_gtk_vscrollbar_init (void);
419 G_END_DECLS