updated on Sun Jan 15 04:04:02 UTC 2012
[aur-mirror.git] / gtk2-ubuntu / 100_overlay_scrollbar_loading.patch
blobdb0b20593159dcacbd3826a18b06dbae9c8beb12
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
8 @@ -709,6 +709,78 @@
9 #endif
12 +static gboolean use_overlay_scrollbar = FALSE;
13 +static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
15 +gboolean
16 +ubuntu_gtk_get_use_overlay_scrollbar (void)
18 + return use_overlay_scrollbar;
21 +void
22 +ubuntu_gtk_set_use_overlay_scrollbar (gboolean use)
24 + use_overlay_scrollbar = use;
27 +G_GNUC_INTERNAL
28 +GtkWidget*
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);
35 +/*
36 + * _overlay_scrollbar_init:
37 + *
38 + * Initialize local use of the overlay-scrollbar module.
39 + *
40 + * If the module is installed, this code checks both a whitelist
41 + * and a blacklist to decide whether to activate the remplacement
42 + * scrollbars.
43 + *
44 + * It is possible to force the feature to be disabled by setting
45 + * the LIBOVERLAY_SCROLLBAR environment variable to either '0' or an
46 + * empty value.
47 + */
48 +static void
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'))
59 + return;
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);
65 + if (module == NULL)
66 + return;
68 + /* check the blacklist, in all cases */
69 + if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
70 + {
71 + gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
72 + if (os_utils_is_blacklisted (g_get_prgname ()) == TRUE)
73 + return;
74 + }
76 + /* all controls are positive: the feature can be activated now */
77 + if (g_module_symbol (module, "os_scrollbar_new", &symbol))
78 + {
79 + os_scrollbar_new = symbol;
80 + use_overlay_scrollbar = TRUE;
81 + }
84 static void
85 do_post_parse_initialization (int *argc,
86 char ***argv)
87 @@ -752,6 +824,7 @@
89 _gtk_accel_map_init ();
90 _gtk_rc_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
99 @@ -71,6 +71,8 @@
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
107 typedef struct {
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())
140 + return 0;
142 if (class->scrollbar_spacing >= 0)
143 return class->scrollbar_spacing;
144 else
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
149 @@ -34,6 +34,9 @@
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);
156 static void
157 gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
159 @@ -61,6 +64,9 @@
160 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
161 NULL);
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,
168 NULL);
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
173 @@ -32,6 +32,9 @@
174 #include "gtkintl.h"
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
183 @@ -75,6 +78,9 @@
184 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
185 NULL);
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,
192 NULL);