~cimi/overlay-scrollbar/fix-window-group

« back to all changes in this revision

Viewing changes to misc/gtk+-2.0-maverick-use-overlay-scrollbar-from-module.patch

  • Committer: Andrea Cimitan
  • Date: 2011-06-08 16:44:43 UTC
  • mfrom: (243.1.7 gtk3)
  • Revision ID: andrea.cimitan@canonical.com-20110608164443-sd6oehapwu7j6lwp
Merged branch gtk3, started from the precious work by Andrea Azzarone

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=== modified file 'gtk/gtkmain.c'
2
 
--- old/gtk/gtkmain.c   2010-08-18 17:15:22 +0000
3
 
+++ new/gtk/gtkmain.c   2011-03-01 17:17:23 +0000
4
 
@@ -740,6 +740,7 @@
5
 
 
6
 
   _gtk_accel_map_init ();
7
 
   _gtk_rc_init ();
8
 
+  _gtk_scrolled_window_init ();
9
 
 
10
 
   /* Set the 'initialized' flag.
11
 
    */
12
 
 
13
 
=== modified file 'gtk/gtkscrolledwindow.c'
14
 
--- old/gtk/gtkscrolledwindow.c 2010-05-18 12:35:39 +0000
15
 
+++ new/gtk/gtkscrolledwindow.c 2011-03-03 10:53:04 +0000
16
 
@@ -144,6 +144,9 @@
17
 
 
18
 
 static guint signals[LAST_SIGNAL] = {0};
19
 
 
20
 
+static GtkWidget* (*os_scrollbar_new) (GtkOrientation, GtkAdjustment*) = NULL;
21
 
+static gboolean use_overlay_scrollbar = FALSE;
22
 
+
23
 
 G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
24
 
 
25
 
 static void
26
 
@@ -434,7 +437,12 @@
27
 
   if (!scrolled_window->hscrollbar)
28
 
     {
29
 
       gtk_widget_push_composite_child ();
30
 
-      scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
31
 
+
32
 
+      if (use_overlay_scrollbar == FALSE)
33
 
+        scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
34
 
+      else
35
 
+        scrolled_window->hscrollbar = os_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadjustment);
36
 
+
37
 
       gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
38
 
       gtk_widget_pop_composite_child ();
39
 
 
40
 
@@ -495,7 +503,12 @@
41
 
   if (!scrolled_window->vscrollbar)
42
 
     {
43
 
       gtk_widget_push_composite_child ();
44
 
-      scrolled_window->vscrollbar = gtk_vscrollbar_new (vadjustment);
45
 
+
46
 
+      if (use_overlay_scrollbar == FALSE)
47
 
+        scrolled_window->vscrollbar = gtk_vscrollbar_new (vadjustment);
48
 
+      else
49
 
+        scrolled_window->vscrollbar = os_scrollbar_new (GTK_ORIENTATION_VERTICAL, vadjustment);
50
 
+
51
 
       gtk_widget_set_composite_name (scrolled_window->vscrollbar, "vscrollbar");
52
 
       gtk_widget_pop_composite_child ();
53
 
 
54
 
@@ -1366,7 +1379,10 @@
55
 
            priv->real_window_placement == GTK_CORNER_BOTTOM_LEFT)))
56
 
        allocation->x += (vscrollbar_requisition.width +  scrollbar_spacing);
57
 
 
58
 
-      allocation->width = MAX (1, allocation->width - (vscrollbar_requisition.width + scrollbar_spacing));
59
 
+      if (use_overlay_scrollbar == FALSE)
60
 
+        allocation->width = MAX (1, allocation->width - (vscrollbar_requisition.width + scrollbar_spacing));
61
 
+      else
62
 
+        allocation->width = MAX (1, allocation->width);
63
 
     }
64
 
   if (scrolled_window->hscrollbar_visible)
65
 
     {
66
 
@@ -1378,7 +1394,10 @@
67
 
          priv->real_window_placement == GTK_CORNER_BOTTOM_RIGHT)
68
 
        allocation->y += (hscrollbar_requisition.height + scrollbar_spacing);
69
 
 
70
 
-      allocation->height = MAX (1, allocation->height - (hscrollbar_requisition.height + scrollbar_spacing));
71
 
+      if (use_overlay_scrollbar == FALSE)
72
 
+        allocation->height = MAX (1, allocation->height - (hscrollbar_requisition.height + scrollbar_spacing));
73
 
+      else
74
 
+        allocation->height = MAX (1, allocation->height);
75
 
     }
76
 
 }
77
 
 
78
 
@@ -1764,6 +1783,59 @@
79
 
 }
80
 
 
81
 
 /*
82
 
+ * _gtk_scrolled_window_init:
83
 
+ *
84
 
+ * Initialize local use of the overlay-scrollbar library.
85
 
+ *
86
 
+ * In order to be activated for an application, the LIBOVERLAY_SCROLLBAR
87
 
+ * environment variable must be set and the liboverlay-scrollbar shared library
88
 
+ * must be installed. If it's installed locally, a custom path to
89
 
+ * liboverlay-scrollbar can be set using the LIBOVERLAY_SCROLLBAR_PATH
90
 
+ * environment variable. liboverlay-scrollbar is loaded at run-time so that it
91
 
+ * can be installed separately.
92
 
+ *
93
 
+ * NOTE: This is a beta feature meant for demonstration and early adopters only.
94
 
+ */
95
 
+void
96
 
+_gtk_scrolled_window_init (void)
97
 
+{
98
 
+  static gboolean init_once = FALSE;
99
 
+
100
 
+  if (init_once == FALSE)
101
 
+    {
102
 
+      if (g_getenv ("LIBOVERLAY_SCROLLBAR") != NULL)
103
 
+        {
104
 
+          GModule *module = NULL;
105
 
+          gpointer symbol = NULL;
106
 
+          gchar *path;
107
 
+
108
 
+          path = (gchar*) g_getenv ("LIBOVERLAY_SCROLLBAR_PATH");
109
 
+          if (path == NULL)
110
 
+            path = "/usr/lib/liboverlay-scrollbar-0.1.so.0";
111
 
+
112
 
+          module = g_module_open (path, G_MODULE_BIND_LOCAL);
113
 
+          if (module != NULL)
114
 
+            {
115
 
+              if (g_module_symbol (module, "os_utils_is_blacklisted", &symbol))
116
 
+                {
117
 
+                  gboolean (*os_utils_is_blacklisted) (const gchar*) = symbol;
118
 
+                  if (os_utils_is_blacklisted (g_get_prgname ()) == FALSE)
119
 
+                    {
120
 
+                      if (g_module_symbol (module, "os_scrollbar_new", &symbol))
121
 
+                        {
122
 
+                          os_scrollbar_new = symbol;
123
 
+                          use_overlay_scrollbar = TRUE;
124
 
+                        }
125
 
+                    }
126
 
+                }
127
 
+            }
128
 
+        }
129
 
+
130
 
+      init_once = TRUE;
131
 
+    }
132
 
+}
133
 
+
134
 
+/*
135
 
  * _gtk_scrolled_window_get_spacing:
136
 
  * @scrolled_window: a scrolled window
137
 
  * 
138
 
 
139
 
=== modified file 'gtk/gtkscrolledwindow.h'
140
 
--- old/gtk/gtkscrolledwindow.h 2009-09-05 07:16:24 +0000
141
 
+++ new/gtk/gtkscrolledwindow.h 2011-03-01 17:18:02 +0000
142
 
@@ -127,6 +127,7 @@
143
 
 void          gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
144
 
                                                      GtkWidget         *child);
145
 
 
146
 
+void _gtk_scrolled_window_init                  (void);
147
 
 gint _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window);
148
 
 
149
 
 
150