updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / gtk2-overlay-scrollbar / 100_overlay_scrollbar_loading.patch
blob1cc4957d311b4fb0bb5cd943099258c3b434f7eb
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
8 @@ -752,6 +752,9 @@
10 _gtk_accel_map_init ();
11 _gtk_rc_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
22 @@ -144,6 +144,8 @@
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)
30 static void
31 @@ -1030,7 +1032,7 @@
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);
40 @@ -1490,7 +1492,7 @@
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;
49 @@ -1542,7 +1544,7 @@
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:
63 + *
64 + * Initialize local use of the overlay-scrollbar module.
65 + *
66 + * If the module is installed, this code checks both a whitelist
67 + * and a blacklist to decide whether to activate the replacement
68 + * scrollbars.
69 + *
70 + * It is possible to force the feature to be disabled by setting
71 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
72 + * empty value.
73 + */
74 +void
75 +ubuntu_gtk_scrolled_window_init (void)
77 + static gboolean init_once = FALSE;
79 + if (init_once == FALSE)
80 + {
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'))
89 + goto skip_loading;
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);
95 + if (module == NULL)
96 + goto skip_loading;
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)
103 + goto skip_loading;
106 + use_overlay_scrollbar = TRUE;
108 +skip_loading:
109 + init_once = 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)
122 + return 0;
124 if (class->scrollbar_spacing >= 0)
125 return class->scrollbar_spacing;
126 else
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
131 @@ -127,6 +127,7 @@
132 void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
133 GtkWidget *child);
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
143 @@ -32,6 +32,9 @@
144 #include "gtkintl.h"
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)
152 static void
153 @@ -61,10 +64,70 @@
154 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
155 NULL);
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,
162 NULL);
166 + * ubuntu_gtk_hscrollbar_init:
168 + * Initialize local use of the overlay-scrollbar module.
169 + *
170 + * If the module is installed, this code checks both a whitelist
171 + * and a blacklist to decide whether to activate the remplacement
172 + * scrollbars.
174 + * It is possible to force the feature to be disabled by setting
175 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
176 + * empty value.
177 + */
178 +void
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'))
193 + goto skip_loading;
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)
200 + goto skip_loading;
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)
207 + goto skip_loading;
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;
217 +skip_loading:
218 + init_once = 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
228 @@ -62,7 +62,7 @@
230 GType gtk_hscrollbar_get_type (void) G_GNUC_CONST;
231 GtkWidget* gtk_hscrollbar_new (GtkAdjustment *adjustment);
233 +void ubuntu_gtk_hscrollbar_init (void);
235 G_END_DECLS
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
241 @@ -32,6 +32,9 @@
242 #include "gtkintl.h"
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
251 @@ -75,10 +78,70 @@
252 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
253 NULL);
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,
260 NULL);
264 + * ubuntu_gtk_vscrollbar_init:
266 + * Initialize local use of the overlay-scrollbar module.
267 + *
268 + * If the module is installed, this code checks both a whitelist
269 + * and a blacklist to decide whether to activate the remplacement
270 + * scrollbars.
272 + * It is possible to force the feature to be disabled by setting
273 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
274 + * empty value.
275 + */
276 +void
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'))
291 + goto skip_loading;
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)
298 + goto skip_loading;
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)
305 + goto skip_loading;
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;
315 +skip_loading:
316 + init_once = 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
326 @@ -68,7 +68,7 @@
328 GType gtk_vscrollbar_get_type (void) G_GNUC_CONST;
329 GtkWidget* gtk_vscrollbar_new (GtkAdjustment *adjustment);
331 +void ubuntu_gtk_vscrollbar_init (void);
333 G_END_DECLS