updated on Mon Jan 23 04:00:55 UTC 2012
[aur-mirror.git] / gtk3-overlay-scrollbar / gtk+-3.0-use-overlay-form-module.patch
blob382b2c477ecfc9883fb4bb24b0d681c0cc1564d9
1 Index: gtk+-3.0.9/gtk/gtkhscrollbar.c
2 ===================================================================
3 --- gtk+-3.0.9.orig/gtk/gtkhscrollbar.c 2011-06-06 22:01:31.455723443 +0200
4 +++ gtk+-3.0.9/gtk/gtkhscrollbar.c 2011-06-06 19:54:05.177807603 +0200
5 @@ -31,6 +31,8 @@
6 #include "gtkorientable.h"
7 #include "gtkintl.h"
9 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
10 +static gboolean use_overlay_scrollbar = FALSE;
12 G_DEFINE_TYPE (GtkHScrollbar, gtk_hscrollbar, GTK_TYPE_SCROLLBAR)
14 @@ -61,7 +63,67 @@
15 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
16 NULL);
18 + if (use_overlay_scrollbar)
19 + return os_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
21 return g_object_new (GTK_TYPE_HSCROLLBAR,
22 "adjustment", adjustment,
23 NULL);
26 +/*
27 + * ubuntu_gtk_hscrollbar_init:
28 + *
29 + * Initialize local use of the overlay-scrollbar module.
30 + *
31 + * If the module is installed, this code checks both a whitelist
32 + * and a blacklist to decide whether to activate the remplacement
33 + * scrollbars.
34 + *
35 + * It is possible to force the feature to be disabled by setting
36 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
37 + * empty value.
38 + */
39 +void
40 +ubuntu_gtk_hscrollbar_init (void)
42 + static gboolean init_once = FALSE;
44 + if (init_once == FALSE)
45 + {
46 + GModule *module = NULL;
47 + gpointer symbol = NULL;
49 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
51 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
52 + and disable the feature in this case */
53 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
54 + goto skip_loading;
56 + /* default extension library to use for this release */
57 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
59 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
60 + if (module == NULL)
61 + goto skip_loading;
63 + /* check the blacklist, in all cases */
64 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
65 + {
66 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
67 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
68 + goto skip_loading;
69 + }
71 + /* all controls are positive: the feature can be activated now */
72 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
73 + {
74 + os_scrollbar_new = symbol;
75 + use_overlay_scrollbar = TRUE;
76 + }
78 +skip_loading:
79 + init_once = TRUE;
80 + }
82 Index: gtk+-3.0.9/gtk/gtkhscrollbar.h
83 ===================================================================
84 --- gtk+-3.0.9.orig/gtk/gtkhscrollbar.h 2011-06-06 22:01:31.479723561 +0200
85 +++ gtk+-3.0.9/gtk/gtkhscrollbar.h 2011-06-06 19:54:26.889915270 +0200
86 @@ -62,6 +62,7 @@
88 GType gtk_hscrollbar_get_type (void) G_GNUC_CONST;
89 GtkWidget* gtk_hscrollbar_new (GtkAdjustment *adjustment);
90 +void ubuntu_gtk_hscrollbar_init (void);
93 G_END_DECLS
94 Index: gtk+-3.0.9/gtk/gtkmain.c
95 ===================================================================
96 --- gtk+-3.0.9.orig/gtk/gtkmain.c 2011-06-06 22:01:31.435723345 +0200
97 +++ gtk+-3.0.9/gtk/gtkmain.c 2011-06-06 19:55:18.630171830 +0200
98 @@ -855,6 +855,11 @@
100 _gtk_accel_map_init ();
102 + ubuntu_gtk_scrolled_window_init ();
103 + ubuntu_gtk_scrollbar_init ();
104 + ubuntu_gtk_hscrollbar_init ();
105 + ubuntu_gtk_vscrollbar_init ();
107 /* Set the 'initialized' flag.
109 gtk_initialized = TRUE;
110 Index: gtk+-3.0.9/gtk/gtkscrollbar.c
111 ===================================================================
112 --- gtk+-3.0.9.orig/gtk/gtkscrollbar.c 2011-06-06 22:01:31.579724063 +0200
113 +++ gtk+-3.0.9/gtk/gtkscrollbar.c 2011-06-06 19:57:52.322933951 +0200
114 @@ -58,6 +58,9 @@
116 static void gtk_scrollbar_style_updated (GtkWidget *widget);
118 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
119 +static gboolean use_overlay_scrollbar = FALSE;
121 G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE)
123 static void
124 @@ -164,8 +167,68 @@
125 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
126 NULL);
128 + if (use_overlay_scrollbar)
129 + return os_scrollbar_new (orientation, adjustment);
131 return g_object_new (GTK_TYPE_SCROLLBAR,
132 "orientation", orientation,
133 "adjustment", adjustment,
134 NULL);
138 + * ubuntu_gtk_scrollbar_init:
140 + * Initialize local use of the overlay-scrollbar module.
141 + *
142 + * If the module is installed, this code checks both a whitelist
143 + * and a blacklist to decide whether to activate the remplacement
144 + * scrollbars.
146 + * It is possible to force the feature to be disabled by setting
147 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
148 + * empty value.
149 + */
150 +void
151 +ubuntu_gtk_scrollbar_init (void)
153 + static gboolean init_once = FALSE;
155 + if (init_once == FALSE)
157 + GModule *module = NULL;
158 + gpointer symbol = NULL;
160 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
162 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
163 + and disable the feature in this case */
164 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
165 + goto skip_loading;
167 + /* default extension library to use for this release */
168 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
170 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
171 + if (module == NULL)
172 + goto skip_loading;
174 + /* check the blacklist, in all cases */
175 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
177 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
178 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
179 + goto skip_loading;
182 + /* all controls are positive: the feature can be activated now */
183 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
185 + os_scrollbar_new = symbol;
186 + use_overlay_scrollbar = TRUE;
189 +skip_loading:
190 + init_once = TRUE;
193 Index: gtk+-3.0.9/gtk/gtkscrollbar.h
194 ===================================================================
195 --- gtk+-3.0.9.orig/gtk/gtkscrollbar.h 2011-06-06 22:01:31.619724258 +0200
196 +++ gtk+-3.0.9/gtk/gtkscrollbar.h 2011-06-06 19:58:12.079031917 +0200
197 @@ -68,6 +68,7 @@
198 GType gtk_scrollbar_get_type (void) G_GNUC_CONST;
199 GtkWidget * gtk_scrollbar_new (GtkOrientation orientation,
200 GtkAdjustment *adjustment);
201 +void ubuntu_gtk_scrollbar_init (void);
203 G_END_DECLS
205 Index: gtk+-3.0.9/gtk/gtkscrolledwindow.c
206 ===================================================================
207 --- gtk+-3.0.9.orig/gtk/gtkscrolledwindow.c 2011-06-06 22:01:31.659724455 +0200
208 +++ gtk+-3.0.9/gtk/gtkscrolledwindow.c 2011-06-06 20:02:19.400258318 +0200
209 @@ -220,6 +220,8 @@
211 static guint signals[LAST_SIGNAL] = {0};
213 +static gboolean use_overlay_scrollbar = FALSE;
215 G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
218 @@ -1210,7 +1212,7 @@
220 gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
222 - if (!scrollbars_within_bevel)
223 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
225 GtkStateFlags state;
226 GtkBorder padding, border;
227 @@ -1766,7 +1768,7 @@
229 if (priv->shadow_type != GTK_SHADOW_NONE)
231 - if (!scrollbars_within_bevel)
232 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
234 child_allocation.x -= padding.left + border.left;
235 child_allocation.width += padding.left + padding.right + border.left + border.right;
236 @@ -1814,7 +1816,7 @@
238 if (priv->shadow_type != GTK_SHADOW_NONE)
240 - if (!scrollbars_within_bevel)
241 + if (!scrollbars_within_bevel && !use_overlay_scrollbar)
243 child_allocation.y -= padding.top + border.top;
244 child_allocation.height += padding.top + padding.bottom + border.top + border.bottom;
245 @@ -2055,6 +2057,58 @@
249 + * ubuntu_gtk_scrolled_window_init:
251 + * Initialize local use of the overlay-scrollbar module.
252 + *
253 + * If the module is installed, this code checks both a whitelist
254 + * and a blacklist to decide whether to activate the remplacement
255 + * scrollbars.
257 + * It is possible to force the feature to be disabled by setting
258 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
259 + * empty value.
260 + */
261 +void
262 +ubuntu_gtk_scrolled_window_init (void)
264 + static gboolean init_once = FALSE;
266 + if (init_once == FALSE)
268 + GModule *module = NULL;
269 + gpointer symbol = NULL;
271 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
273 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
274 + and disable the feature in this case */
275 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
276 + goto skip_loading;
278 + /* default extension library to use for this release */
279 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
281 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
282 + if (module == NULL)
283 + goto skip_loading;
285 + /* check the blacklist, in all cases */
286 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
288 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
289 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
290 + goto skip_loading;
293 + use_overlay_scrollbar = TRUE;
295 +skip_loading:
296 + init_once = TRUE;
301 * _gtk_scrolled_window_get_spacing:
302 * @scrolled_window: a scrolled window
304 @@ -2070,6 +2124,9 @@
306 g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0);
308 + if (use_overlay_scrollbar)
309 + return 0;
311 class = GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_window);
313 if (class->scrollbar_spacing >= 0)
314 Index: gtk+-3.0.9/gtk/gtkscrolledwindow.h
315 ===================================================================
316 --- gtk+-3.0.9.orig/gtk/gtkscrolledwindow.h 2011-06-06 22:01:31.679724552 +0200
317 +++ gtk+-3.0.9/gtk/gtkscrolledwindow.h 2011-06-06 20:02:52.764423758 +0200
318 @@ -123,6 +123,7 @@
319 gint height);
321 gint _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window);
322 +void ubuntu_gtk_scrolled_window_init (void);
325 G_END_DECLS
326 Index: gtk+-3.0.9/gtk/gtkvscrollbar.c
327 ===================================================================
328 --- gtk+-3.0.9.orig/gtk/gtkvscrollbar.c 2011-06-06 22:01:31.507723704 +0200
329 +++ gtk+-3.0.9/gtk/gtkvscrollbar.c 2011-06-06 20:05:06.117085008 +0200
330 @@ -31,6 +31,8 @@
331 #include "gtkvscrollbar.h"
332 #include "gtkintl.h"
334 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
335 +static gboolean use_overlay_scrollbar = FALSE;
338 * SECTION:gtkvscrollbar
339 @@ -75,7 +77,67 @@
340 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
341 NULL);
343 + if (use_overlay_scrollbar)
344 + return os_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
346 return g_object_new (GTK_TYPE_VSCROLLBAR,
347 "adjustment", adjustment,
348 NULL);
352 + * ubuntu_gtk_vscrollbar_init:
354 + * Initialize local use of the overlay-scrollbar module.
355 + *
356 + * If the module is installed, this code checks both a whitelist
357 + * and a blacklist to decide whether to activate the remplacement
358 + * scrollbars.
360 + * It is possible to force the feature to be disabled by setting
361 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
362 + * empty value.
363 + */
364 +void
365 +ubuntu_gtk_vscrollbar_init (void)
367 + static gboolean init_once = FALSE;
369 + if (init_once == FALSE)
371 + GModule *module = NULL;
372 + gpointer symbol = NULL;
374 + gchar *flag = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR");
376 + /* check if LIBOVERLAY_SCROLLBAR is set to 0 or an empty value
377 + and disable the feature in this case */
378 + if (flag != NULL && (*flag == '\0' || *flag == '0'))
379 + goto skip_loading;
381 + /* default extension library to use for this release */
382 + gchar *path = "/usr/lib/liboverlay-scrollbar3-0.2.so.0";
384 + module = g_module_open (path, G_MODULE_BIND_LOCAL);
385 + if (module == NULL)
386 + goto skip_loading;
388 + /* check the blacklist, in all cases */
389 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
391 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
392 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
393 + goto skip_loading;
396 + /* all controls are positive: the feature can be activated now */
397 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
399 + os_scrollbar_new = symbol;
400 + use_overlay_scrollbar = TRUE;
403 +skip_loading:
404 + init_once = TRUE;
407 Index: gtk+-3.0.9/gtk/gtkvscrollbar.h
408 ===================================================================
409 --- gtk+-3.0.9.orig/gtk/gtkvscrollbar.h 2011-06-06 22:01:31.543723883 +0200
410 +++ gtk+-3.0.9/gtk/gtkvscrollbar.h 2011-06-06 20:08:59.662243113 +0200
411 @@ -68,6 +68,7 @@
413 GType gtk_vscrollbar_get_type (void) G_GNUC_CONST;
414 GtkWidget* gtk_vscrollbar_new (GtkAdjustment *adjustment);
415 +void ubuntu_gtk_vscrollbar_init (void);
418 G_END_DECLS