Merge lp:~cimi/overlay-scrollbar/new-size-allocate into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 175
Proposed branch: lp:~cimi/overlay-scrollbar/new-size-allocate
Merge into: lp:overlay-scrollbar
Diff against target: 234 lines (+68/-86)
1 file modified
os/os-scrollbar.c (+68/-86)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/new-size-allocate
Reviewer Review Type Date Requested Status
Loïc Molinari (community) Approve
Review via email: mp+54732@code.launchpad.net

Description of the change

do the allocation in the proper way, update the position of the pager of adjustment changed. should be safer and maybe faster

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'os/os-scrollbar.c'
2--- os/os-scrollbar.c 2011-03-18 15:51:35 +0000
3+++ os/os-scrollbar.c 2011-03-24 16:52:34 +0000
4@@ -77,7 +77,7 @@
5 static void os_scrollbar_parent_set (GtkWidget *widget, GtkWidget *old_parent);
6 static void os_scrollbar_realize (GtkWidget *widget);
7 static void os_scrollbar_show (GtkWidget *widget);
8-static void os_scrollbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
9+static void os_scrollbar_size_allocate (GtkWidget *widget, GdkRectangle *allocation);
10 static void os_scrollbar_unmap (GtkWidget *widget);
11 static void os_scrollbar_unrealize (GtkWidget *widget);
12 static void os_scrollbar_dispose (GObject *object);
13@@ -108,7 +108,6 @@
14 static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
15 static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
16 static void parent_realize_cb (GtkWidget *widget, gpointer user_data);
17-static void parent_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data);
18 static void parent_unrealize_cb (GtkWidget *widget, gpointer user_data);
19 static gboolean toplevel_configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
20 static GdkFilterReturn toplevel_filter_func (GdkXEvent *gdkxevent, GdkEvent *event, gpointer user_data);
21@@ -179,11 +178,8 @@
22
23 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
24 {
25- gint tmp_height;
26 gint y, bottom, top, height;
27
28- tmp_height = priv->overlay.height;
29-
30 top = priv->trough.y;
31 bottom = priv->trough.y + priv->trough.height;
32
33@@ -211,17 +207,11 @@
34
35 priv->overlay.y = y;
36 priv->overlay.height = height;
37-
38- if (tmp_height != height)
39- pager_move (scrollbar);
40 }
41 else
42 {
43- gint tmp_width;
44 gint x, left, right, width;
45
46- tmp_width = priv->overlay.width;
47-
48 left = priv->trough.x;
49 right = priv->trough.x + priv->trough.width;
50
51@@ -249,9 +239,6 @@
52
53 priv->overlay.x = x;
54 priv->overlay.width = width;
55-
56- if (tmp_width != width)
57- pager_move (scrollbar);
58 }
59 }
60
61@@ -557,8 +544,6 @@
62 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->parent),
63 G_CALLBACK (parent_realize_cb), scrollbar);
64 g_signal_handlers_disconnect_by_func (G_OBJECT (priv->parent),
65- G_CALLBACK (parent_size_allocate_cb), scrollbar);
66- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->parent),
67 G_CALLBACK (parent_unrealize_cb), scrollbar);
68
69 g_object_unref (priv->parent);
70@@ -572,8 +557,6 @@
71
72 g_signal_connect (G_OBJECT (priv->parent), "realize",
73 G_CALLBACK (parent_realize_cb), scrollbar);
74- g_signal_connect (G_OBJECT (priv->parent), "size-allocate",
75- G_CALLBACK (parent_size_allocate_cb), scrollbar);
76 g_signal_connect (G_OBJECT (priv->parent), "unrealize",
77 G_CALLBACK (parent_unrealize_cb), scrollbar);
78 }
79@@ -931,6 +914,14 @@
80 if (priv->proximity != FALSE)
81 os_pager_hide (OS_PAGER (priv->pager));
82 }
83+
84+ os_scrollbar_calc_layout_pager (scrollbar, adjustment->value);
85+ os_scrollbar_calc_layout_slider (scrollbar, adjustment->value);
86+
87+ if (!priv->motion_notify_event && !priv->enter_notify_event)
88+ gtk_widget_hide (GTK_WIDGET (priv->thumb));
89+
90+ pager_move (scrollbar);
91 }
92
93 static void
94@@ -981,72 +972,6 @@
95 }
96
97 static void
98-parent_size_allocate_cb (GtkWidget *widget,
99- GtkAllocation *allocation,
100- gpointer user_data)
101-{
102- GdkRectangle rect;
103- OsScrollbar *scrollbar;
104- OsScrollbarPrivate *priv;
105- gint offset;
106-
107- scrollbar = OS_SCROLLBAR (user_data);
108- priv = scrollbar->priv;
109-
110- priv->trough.x = 0;
111- priv->trough.y = 0;
112- priv->trough.width = allocation->width;
113- priv->trough.height = allocation->height;
114-
115- priv->overlay_all = *allocation;
116- priv->thumb_all = *allocation;
117-
118- if (GTK_IS_SCROLLED_WINDOW (widget) &&
119- gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (widget)) != GTK_SHADOW_NONE)
120- offset = 1;
121- else
122- offset = 0;
123-
124- if (priv->orientation == GTK_ORIENTATION_VERTICAL)
125- {
126- priv->slider.width = DEFAULT_SCROLLBAR_WIDTH;
127- priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
128- priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH - offset;
129- priv->thumb_all.x = allocation->x + allocation->width - offset;
130-
131- rect.x = priv->overlay_all.x;
132- rect.y = priv->overlay_all.y + offset;
133- rect.width = DEFAULT_PAGER_WIDTH;
134- rect.height = priv->overlay_all.height - offset * 2;
135- }
136- else
137- {
138- priv->slider.width = DEFAULT_SCROLLBAR_HEIGHT;
139- priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
140- priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH - offset;
141- priv->thumb_all.y = allocation->y + allocation->height - offset;
142-
143- rect.x = priv->overlay_all.x + offset;
144- rect.y = priv->overlay_all.y;
145- rect.width = priv->overlay_all.width - offset * 2;
146- rect.height = DEFAULT_PAGER_WIDTH;
147- }
148-
149- if (priv->adjustment != NULL)
150- {
151- os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
152- os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
153- }
154-
155- os_pager_size_allocate (OS_PAGER (priv->pager), rect);
156-
157- pager_move (scrollbar);
158-
159- if (gtk_widget_get_realized (widget))
160- os_scrollbar_store_window_position (scrollbar);
161-}
162-
163-static void
164 parent_unrealize_cb (GtkWidget *widget,
165 gpointer user_data)
166 {
167@@ -1428,9 +1353,66 @@
168 }
169
170 static void
171-os_scrollbar_size_allocate (GtkWidget *widget,
172- GtkAllocation *allocation)
173+os_scrollbar_size_allocate (GtkWidget *widget,
174+ GdkRectangle *allocation)
175 {
176+ GdkRectangle rect;
177+ OsScrollbar *scrollbar;
178+ OsScrollbarPrivate *priv;
179+
180+ scrollbar = OS_SCROLLBAR (widget);
181+ priv = scrollbar->priv;
182+
183+ priv->trough.x = 0;
184+ priv->trough.y = 0;
185+ priv->trough.width = allocation->width;
186+ priv->trough.height = allocation->height;
187+
188+ priv->overlay_all = *allocation;
189+ priv->thumb_all = *allocation;
190+
191+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
192+ {
193+ priv->slider.width = DEFAULT_SCROLLBAR_WIDTH;
194+ priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
195+ priv->overlay_all.x = allocation->x - DEFAULT_PAGER_WIDTH;
196+ priv->thumb_all.x = allocation->x;
197+
198+ rect.x = priv->overlay_all.x;
199+ rect.y = priv->overlay_all.y;
200+ rect.width = DEFAULT_PAGER_WIDTH;
201+ rect.height = priv->overlay_all.height;
202+
203+ allocation->width = 0;
204+ }
205+ else
206+ {
207+ priv->slider.width = DEFAULT_SCROLLBAR_HEIGHT;
208+ priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
209+ priv->overlay_all.y = allocation->y - DEFAULT_PAGER_WIDTH ;
210+ priv->thumb_all.y = allocation->y;
211+
212+ rect.x = priv->overlay_all.x;
213+ rect.y = priv->overlay_all.y;
214+ rect.width = priv->overlay_all.width;
215+ rect.height = DEFAULT_PAGER_WIDTH;
216+
217+ allocation->height = 0;
218+ }
219+
220+ if (priv->adjustment != NULL)
221+ {
222+ os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
223+ os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
224+ }
225+
226+ os_pager_size_allocate (OS_PAGER (priv->pager), rect);
227+
228+ pager_move (scrollbar);
229+
230+ if (gtk_widget_get_realized (widget))
231+ os_scrollbar_store_window_position (scrollbar);
232+
233 widget->allocation = *allocation;
234 }
235

Subscribers

People subscribed via source and target branches