Merge lp:~charlesk/ido/lp-906050 into lp:ido/0.3
- lp-906050
- Merge into trunk
Status: | Merged | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||||||||||||||||||
Approved revision: | 104 | ||||||||||||||||||||
Merge reported by: | Charles Kerr | ||||||||||||||||||||
Merged at revision: | not available | ||||||||||||||||||||
Proposed branch: | lp:~charlesk/ido/lp-906050 | ||||||||||||||||||||
Merge into: | lp:ido/0.3 | ||||||||||||||||||||
Diff against target: |
832 lines (+20/-695) 4 files modified
src/Makefile.am (+0/-15) src/idooffscreenproxy.c (+0/-515) src/idooffscreenproxy.h (+0/-62) src/idoscalemenuitem.c (+20/-103) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~charlesk/ido/lp-906050 | ||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Conor Curran (community) | Approve | ||
Indicator Applet Developers | Pending | ||
Review via email:
|
Commit message
Description of the change
Fix LP Bug #906050 by removing idoscalemenuitem's offscreen proxy.
NOTE TO REVIEWERS, please read before reviewing:
The offscreen proxy was added last September to fix bug #804009, but while testing in 12.04b1 I'm not able to reproduce that issue even after removing the offscreen proxy. This patch removes the offscreen proxy, and since I don't want to regress 804009 I would like more eyeballs on this one.
To test for a bug #804009 regression, try running indicator-sound with this branch's version of IDO, then test for 804009's behavior: "with the latest update of indicator sound, when you click on the volume slider to change the volumes, the SoundMenu closes and you have to open it again." and "It closes when the user clicks on the slider, then when it is reopened, the slider follow the mouse, then if you click on the slider again it selects the slider with a translucid orange area."

Conor Curran (cjcurran) : | # |

Conor Curran (cjcurran) wrote : | # |

Sebastien Bacher (seb128) wrote : | # |
It works fine for me but I don't know enough of the reason why the offscreen logic was added to start so I'm a bit nervous acking it being dropped, I figure it wouldn't have been added if it was not needed for a reason, I would prefer to have somebody who has a clue about the historical reason to ack it
Preview Diff
1 | === modified file 'src/Makefile.am' |
2 | --- src/Makefile.am 2011-09-13 16:21:24 +0000 |
3 | +++ src/Makefile.am 2012-03-10 01:21:16 +0000 |
4 | @@ -28,13 +28,6 @@ |
5 | idotypebuiltins.c.template |
6 | |
7 | |
8 | -if USE_GTK3 |
9 | -sources_h += idooffscreenproxy.h |
10 | -else |
11 | -EXTRA_DIST += idooffscreenproxy.h \ |
12 | - idooffscreenproxy.c |
13 | -endif |
14 | - |
15 | idotypebuiltins.h: stamp-idotypebuiltins.h |
16 | |
17 | stamp-idotypebuiltins.h: $(sources_h) |
18 | @@ -73,10 +66,6 @@ |
19 | idoscalemenuitem.c \ |
20 | idotimeline.c |
21 | |
22 | -if USE_GTK3 |
23 | -libido_0_1_la_SOURCES += idooffscreenproxy.c |
24 | -endif |
25 | - |
26 | libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) |
27 | |
28 | libidoincludedir=$(includedir)/libido$(VER)-0.1/libido |
29 | @@ -90,10 +79,6 @@ |
30 | idotimeline.h \ |
31 | libido.h |
32 | |
33 | -if USE_GTK3 |
34 | -libidoinclude_HEADERS += idooffscreenproxy.h |
35 | -endif |
36 | - |
37 | libido_0_1_la_LIBADD = $(GTK_LIBS) |
38 | libido_0_1_la_LDFLAGS = $(GTK_LT_LDFLAGS) |
39 | libido3_0_1_la_LIBADD = $(libido_0_1_la_LIBADD) |
40 | |
41 | === removed file 'src/idooffscreenproxy.c' |
42 | --- src/idooffscreenproxy.c 2012-02-09 04:18:09 +0000 |
43 | +++ src/idooffscreenproxy.c 1970-01-01 00:00:00 +0000 |
44 | @@ -1,515 +0,0 @@ |
45 | -/* |
46 | - * Copyright 2011 Canonical, Ltd. |
47 | - * |
48 | - * This program is free software: you can redistribute it and/or modify it |
49 | - * under the terms of either or both of the following licenses: |
50 | - * |
51 | - * 1) the GNU Lesser General Public License version 3, as published by the |
52 | - * Free Software Foundation; and/or |
53 | - * 2) the GNU Lesser General Public License version 2.1, as published by |
54 | - * the Free Software Foundation. |
55 | - * |
56 | - * This program is distributed in the hope that it will be useful, but |
57 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
58 | - * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
59 | - * PURPOSE. See the applicable version of the GNU Lesser General Public |
60 | - * License for more details. |
61 | - * |
62 | - * You should have received a copy of both the GNU Lesser General Public |
63 | - * License version 3 and version 2.1 along with this program. If not, see |
64 | - * <http://www.gnu.org/licenses/> |
65 | - * |
66 | - * Authors: |
67 | - * Robert Carr <racarr@canonical.com> |
68 | - */ |
69 | - |
70 | -#include <gtk/gtk.h> |
71 | -#include "idooffscreenproxy.h" |
72 | - |
73 | -struct _IdoOffscreenProxyPrivate |
74 | -{ |
75 | - GtkWidget *child; |
76 | - |
77 | - GdkWindow *offscreen_window; |
78 | -}; |
79 | - |
80 | -static void ido_offscreen_proxy_realize (GtkWidget *widget); |
81 | -static void ido_offscreen_proxy_unrealize (GtkWidget *widget); |
82 | -static void ido_offscreen_proxy_get_preferred_width (GtkWidget *widget, |
83 | - gint *minimum, |
84 | - gint *natural); |
85 | -static void ido_offscreen_proxy_get_preferred_height (GtkWidget *widget, |
86 | - gint *minimum, |
87 | - gint *natural); |
88 | - |
89 | -static void ido_offscreen_proxy_size_allocate (GtkWidget *widget, |
90 | - GtkAllocation *allocation); |
91 | -static gboolean ido_offscreen_proxy_damage (GtkWidget *widget, |
92 | - GdkEventExpose *event); |
93 | -static gboolean ido_offscreen_proxy_draw (GtkWidget *widget, |
94 | - cairo_t *cr); |
95 | -static void ido_offscreen_proxy_add (GtkContainer *container, |
96 | - GtkWidget *child); |
97 | -static void ido_offscreen_proxy_remove (GtkContainer *container, |
98 | - GtkWidget *widget); |
99 | -static void ido_offscreen_proxy_forall (GtkContainer *container, |
100 | - gboolean include_internals, |
101 | - GtkCallback callback, |
102 | - gpointer callback_data); |
103 | -static GType ido_offscreen_proxy_child_type (GtkContainer *container); |
104 | - |
105 | -static cairo_surface_t * ido_offscreen_proxy_create_alpha_image_surface (GdkWindow *offscreen, gint width, gint height); |
106 | - |
107 | - |
108 | - |
109 | -G_DEFINE_TYPE (IdoOffscreenProxy, ido_offscreen_proxy, GTK_TYPE_CONTAINER); |
110 | - |
111 | -#define IDO_OFFSCREEN_PROXY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IDO_TYPE_OFFSCREEN_PROXY, IdoOffscreenProxyPrivate)) |
112 | - |
113 | -static void |
114 | -ido_offscreen_proxy_class_init (IdoOffscreenProxyClass *klass) |
115 | -{ |
116 | - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
117 | - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); |
118 | - |
119 | - g_type_class_add_private (klass, sizeof (IdoOffscreenProxyPrivate)); |
120 | - |
121 | - widget_class->realize = ido_offscreen_proxy_realize; |
122 | - widget_class->unrealize = ido_offscreen_proxy_unrealize; |
123 | - widget_class->get_preferred_width = ido_offscreen_proxy_get_preferred_width; |
124 | - widget_class->get_preferred_height = ido_offscreen_proxy_get_preferred_height; |
125 | - widget_class->size_allocate = ido_offscreen_proxy_size_allocate; |
126 | - widget_class->draw = ido_offscreen_proxy_draw; |
127 | - |
128 | - g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET), |
129 | - IDO_TYPE_OFFSCREEN_PROXY, |
130 | - g_cclosure_new (G_CALLBACK (ido_offscreen_proxy_damage), |
131 | - NULL, NULL)); |
132 | - |
133 | - container_class->add = ido_offscreen_proxy_add; |
134 | - container_class->remove = ido_offscreen_proxy_remove; |
135 | - container_class->forall = ido_offscreen_proxy_forall; |
136 | - container_class->child_type = ido_offscreen_proxy_child_type; |
137 | - |
138 | -} |
139 | - |
140 | -static void |
141 | -ido_offscreen_proxy_init (IdoOffscreenProxy *proxy) |
142 | -{ |
143 | - proxy->priv = IDO_OFFSCREEN_PROXY_GET_PRIVATE (proxy); |
144 | - |
145 | - gtk_widget_set_has_window (GTK_WIDGET (proxy), TRUE); |
146 | - |
147 | - gtk_widget_set_events (GTK_WIDGET(proxy), gtk_widget_get_events (GTK_WIDGET(proxy)) |
148 | - | GDK_EXPOSURE_MASK |
149 | - | GDK_POINTER_MOTION_MASK |
150 | - | GDK_BUTTON_PRESS_MASK |
151 | - | GDK_BUTTON_RELEASE_MASK |
152 | - | GDK_SCROLL_MASK |
153 | - | GDK_ENTER_NOTIFY_MASK |
154 | - | GDK_LEAVE_NOTIFY_MASK); |
155 | - |
156 | - gtk_container_set_border_width (GTK_CONTAINER (proxy), 0); |
157 | -} |
158 | - |
159 | -GtkWidget * |
160 | -ido_offscreen_proxy_new (void) |
161 | -{ |
162 | - return g_object_new (IDO_TYPE_OFFSCREEN_PROXY, NULL); |
163 | -} |
164 | - |
165 | -static GdkWindow * |
166 | -pick_offscreen_child (GdkWindow *offscreen_window, |
167 | - double widget_x, double widget_y, |
168 | - IdoOffscreenProxy *proxy) |
169 | -{ |
170 | - GtkAllocation child_area; |
171 | - |
172 | - if (proxy->priv->child && gtk_widget_get_visible (proxy->priv->child)) |
173 | - { |
174 | - gtk_widget_get_allocation (proxy->priv->child, &child_area); |
175 | - |
176 | - // if (widget_x >= 0 && widget_x < child_area.width && |
177 | - // widget_y >= 0 && widget_y < child_area.height) |
178 | - //return proxy->priv->offscreen_window; |
179 | - return proxy->priv->offscreen_window; |
180 | - } |
181 | - |
182 | - return NULL; |
183 | -} |
184 | - |
185 | -static void |
186 | -offscreen_to_parent (GdkWindow *offscreen_window, |
187 | - double offscreen_x, |
188 | - double offscreen_y, |
189 | - double *parent_x, |
190 | - double *parent_y, |
191 | - gpointer user_data) |
192 | -{ |
193 | - *parent_x = offscreen_x; |
194 | - *parent_y = offscreen_y; |
195 | -} |
196 | - |
197 | -static void |
198 | -offscreen_from_parent (GdkWindow *window, |
199 | - double parent_x, |
200 | - double parent_y, |
201 | - double *offscreen_x, |
202 | - double *offscreen_y, |
203 | - gpointer user_data) |
204 | -{ |
205 | - *offscreen_x = parent_x; |
206 | - *offscreen_y = parent_y; |
207 | -} |
208 | - |
209 | -static cairo_surface_t * |
210 | -ido_offscreen_proxy_create_alpha_image_surface (GdkWindow *offscreen, gint width, gint height) |
211 | -{ |
212 | - return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); |
213 | -} |
214 | - |
215 | -static void |
216 | -proxy_add_css (GtkStyleContext *sc) |
217 | -{ |
218 | - GtkCssProvider *provider = gtk_css_provider_new(); |
219 | - const gchar *proxy_css = ".menu.ido-offscreen { \nborder-width: 0;\nborder-radius:0; \n}\n"; |
220 | - |
221 | - gtk_css_provider_load_from_data (provider, proxy_css, -1, NULL); |
222 | - |
223 | - gtk_style_context_add_provider (sc, GTK_STYLE_PROVIDER (provider), |
224 | - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
225 | - |
226 | -} |
227 | - |
228 | -static void |
229 | -ido_offscreen_proxy_realize (GtkWidget *widget) |
230 | -{ |
231 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (widget); |
232 | - GtkAllocation allocation, child_area; |
233 | - GtkStyleContext *context; |
234 | - GdkWindow *window; |
235 | - GdkWindowAttr attributes; |
236 | - gint attributes_mask; |
237 | - // GtkRequisition child_requisition; |
238 | - |
239 | - gtk_widget_set_realized (widget, TRUE); |
240 | - |
241 | - gtk_widget_get_allocation (widget, &allocation); |
242 | - |
243 | - attributes.x = allocation.x; |
244 | - attributes.y = allocation.y; |
245 | - attributes.width = allocation.width; |
246 | - attributes.height = allocation.height; |
247 | - |
248 | - attributes.window_type = GDK_WINDOW_CHILD; |
249 | - attributes.event_mask = gtk_widget_get_events (widget) |
250 | - | GDK_EXPOSURE_MASK |
251 | - | GDK_POINTER_MOTION_MASK |
252 | - | GDK_BUTTON_PRESS_MASK |
253 | - | GDK_BUTTON_RELEASE_MASK |
254 | - | GDK_SCROLL_MASK |
255 | - | GDK_ENTER_NOTIFY_MASK |
256 | - | GDK_LEAVE_NOTIFY_MASK; |
257 | - attributes.visual = gdk_screen_get_rgba_visual (gdk_screen_get_default ());//gtk_widget_get_visual (widget); |
258 | - if (!attributes.visual) |
259 | - { |
260 | - attributes.visual = gdk_screen_get_system_visual (gdk_screen_get_default ()); |
261 | - } |
262 | - attributes.wclass = GDK_INPUT_OUTPUT; |
263 | - |
264 | - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; |
265 | - |
266 | - window = gdk_window_new (gtk_widget_get_parent_window (widget), |
267 | - &attributes, attributes_mask); |
268 | - |
269 | - gtk_widget_set_window (widget, window); |
270 | - gdk_window_set_user_data (window, widget); |
271 | - |
272 | - g_signal_connect (window, "pick-embedded-child", |
273 | - G_CALLBACK (pick_offscreen_child), proxy); |
274 | - |
275 | - attributes.window_type = GDK_WINDOW_OFFSCREEN; |
276 | - attributes.x = attributes.y = 0; |
277 | - |
278 | - if (proxy->priv->child && gtk_widget_get_visible (proxy->priv->child)) |
279 | - { |
280 | - gtk_widget_get_allocation (proxy->priv->child, &child_area); |
281 | - attributes.width = child_area.width; |
282 | - attributes.height = child_area.height; |
283 | - } |
284 | - |
285 | - proxy->priv->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget), |
286 | - &attributes, attributes_mask); |
287 | - gdk_window_set_user_data (proxy->priv->offscreen_window, widget); |
288 | - |
289 | - if (proxy->priv->child) |
290 | - gtk_widget_set_parent_window (proxy->priv->child, proxy->priv->offscreen_window); |
291 | - |
292 | - gdk_offscreen_window_set_embedder (proxy->priv->offscreen_window, |
293 | - window); |
294 | - |
295 | - g_signal_connect(proxy->priv->offscreen_window, "create-surface", |
296 | - G_CALLBACK (ido_offscreen_proxy_create_alpha_image_surface), |
297 | - proxy); |
298 | - g_signal_connect (proxy->priv->offscreen_window, "to-embedder", |
299 | - G_CALLBACK (offscreen_to_parent), NULL); |
300 | - g_signal_connect (proxy->priv->offscreen_window, "from-embedder", |
301 | - G_CALLBACK (offscreen_from_parent), NULL); |
302 | - |
303 | - context = gtk_widget_get_style_context (widget); |
304 | - gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENUITEM); |
305 | - gtk_style_context_set_background (context, window); |
306 | - gtk_style_context_set_background (context, proxy->priv->offscreen_window); |
307 | - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM | GTK_JUNCTION_LEFT | GTK_JUNCTION_RIGHT); |
308 | - |
309 | - gtk_widget_set_name (widget, "IdoOffscreenProxy"); |
310 | - gtk_widget_path_iter_set_name (gtk_widget_get_path (widget), -1, "IdoOffscreenProxy"); |
311 | - |
312 | - gdk_window_show (proxy->priv->offscreen_window); |
313 | -} |
314 | - |
315 | -static void |
316 | -ido_offscreen_proxy_unrealize (GtkWidget *widget) |
317 | -{ |
318 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (widget); |
319 | - |
320 | - gdk_window_set_user_data (proxy->priv->offscreen_window, NULL); |
321 | - gdk_window_destroy (proxy->priv->offscreen_window); |
322 | - proxy->priv->offscreen_window = NULL; |
323 | - |
324 | - GTK_WIDGET_CLASS (ido_offscreen_proxy_parent_class)->unrealize (widget); |
325 | -} |
326 | - |
327 | -static GType |
328 | -ido_offscreen_proxy_child_type (GtkContainer *container) |
329 | -{ |
330 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (container); |
331 | - |
332 | - if (proxy->priv->child) |
333 | - return G_TYPE_NONE; |
334 | - |
335 | - return GTK_TYPE_WIDGET; |
336 | -} |
337 | - |
338 | -static void |
339 | -ido_offscreen_proxy_add (GtkContainer *container, |
340 | - GtkWidget *child) |
341 | -{ |
342 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (container); |
343 | - |
344 | - if (!proxy->priv->child) |
345 | - { |
346 | - gtk_widget_set_parent_window (child, proxy->priv->offscreen_window); |
347 | - gtk_widget_set_parent (child, GTK_WIDGET (proxy)); |
348 | - proxy->priv->child = child; |
349 | - } |
350 | - else |
351 | - { |
352 | - g_warning ("IdoOffscreenProxy can only have a single child\n"); |
353 | - } |
354 | -} |
355 | - |
356 | -static void |
357 | -ido_offscreen_proxy_remove (GtkContainer *container, |
358 | - GtkWidget *widget) |
359 | -{ |
360 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (container); |
361 | - gboolean was_visible; |
362 | - |
363 | - was_visible = gtk_widget_get_visible (widget); |
364 | - |
365 | - if (proxy->priv->child == widget) |
366 | - { |
367 | - gtk_widget_unparent (widget); |
368 | - proxy->priv->child = NULL; |
369 | - |
370 | - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) |
371 | - gtk_widget_queue_resize (GTK_WIDGET (container)); |
372 | - } |
373 | -} |
374 | - |
375 | -static void |
376 | -ido_offscreen_proxy_forall (GtkContainer *container, |
377 | - gboolean include_internals, |
378 | - GtkCallback callback, |
379 | - gpointer callback_data) |
380 | -{ |
381 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (container); |
382 | - |
383 | - g_return_if_fail (callback != NULL); |
384 | - |
385 | - if (proxy->priv->child) |
386 | - (*callback) (proxy->priv->child, callback_data); |
387 | -} |
388 | - |
389 | -static void |
390 | -ido_offscreen_proxy_size_request (GtkWidget *widget, |
391 | - GtkRequisition *requisition) |
392 | -{ |
393 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (widget); |
394 | - int w, h; |
395 | - |
396 | - w = 0; |
397 | - h = 0; |
398 | - |
399 | - if (proxy->priv->child && gtk_widget_get_visible (proxy->priv->child)) |
400 | - { |
401 | - GtkRequisition child_requisition; |
402 | - |
403 | - gtk_widget_get_preferred_size (proxy->priv->child, |
404 | - &child_requisition, NULL); |
405 | - w = child_requisition.width; |
406 | - h = child_requisition.height; |
407 | - } |
408 | - |
409 | - requisition->width = w; |
410 | - requisition->height = h; |
411 | - |
412 | -} |
413 | - |
414 | -static void |
415 | -ido_offscreen_proxy_get_preferred_width (GtkWidget *widget, |
416 | - gint *minimum, |
417 | - gint *natural) |
418 | -{ |
419 | - GtkRequisition requisition; |
420 | - |
421 | - ido_offscreen_proxy_size_request (widget, &requisition); |
422 | - |
423 | - *minimum = *natural = requisition.width; |
424 | -} |
425 | - |
426 | -static void |
427 | -ido_offscreen_proxy_get_preferred_height (GtkWidget *widget, |
428 | - gint *minimum, |
429 | - gint *natural) |
430 | -{ |
431 | - GtkRequisition requisition; |
432 | - |
433 | - ido_offscreen_proxy_size_request (widget, &requisition); |
434 | - |
435 | - *minimum = *natural = requisition.height; |
436 | - |
437 | -} |
438 | - |
439 | -static void |
440 | -ido_offscreen_proxy_size_allocate (GtkWidget *widget, |
441 | - GtkAllocation *allocation) |
442 | -{ |
443 | - IdoOffscreenProxy *proxy; |
444 | - |
445 | - proxy = IDO_OFFSCREEN_PROXY (widget); |
446 | - |
447 | - gtk_widget_set_allocation (widget, allocation); |
448 | - |
449 | - if (gtk_widget_get_realized (widget)) |
450 | - { |
451 | - gdk_window_move_resize (gtk_widget_get_window (widget), |
452 | - allocation->x, |
453 | - allocation->y, |
454 | - allocation->width, |
455 | - allocation->height); |
456 | - } |
457 | - |
458 | - if (proxy->priv->child && gtk_widget_get_visible (proxy->priv->child)) |
459 | - { |
460 | - GtkRequisition child_requisition; |
461 | - GtkAllocation child_allocation; |
462 | - |
463 | - gtk_widget_get_preferred_size (proxy->priv->child, |
464 | - &child_requisition, NULL); |
465 | - |
466 | - child_allocation.x = child_requisition.width; |
467 | - child_allocation.y = child_requisition.height; |
468 | - child_allocation.width = allocation->width; |
469 | - child_allocation.height = allocation->height; |
470 | - |
471 | - if (gtk_widget_get_realized (widget)) |
472 | - gdk_window_move_resize (proxy->priv->offscreen_window, |
473 | - child_allocation.x, |
474 | - child_allocation.y, |
475 | - child_allocation.width+4, |
476 | - child_allocation.height); |
477 | - |
478 | - child_allocation.x = child_allocation.y = 0; |
479 | - gtk_widget_size_allocate (proxy->priv->child, &child_allocation); |
480 | - } |
481 | -} |
482 | - |
483 | - |
484 | -static gboolean |
485 | -ido_offscreen_proxy_damage (GtkWidget *widget, |
486 | - GdkEventExpose *event) |
487 | -{ |
488 | - gdk_window_invalidate_rect (gtk_widget_get_window (widget), |
489 | - NULL, FALSE); |
490 | - return TRUE; |
491 | -} |
492 | - |
493 | -static GtkStyleContext * |
494 | -get_menu_style_context () |
495 | -{ |
496 | - GtkStyleContext *sc; |
497 | - GtkWidgetPath *path; |
498 | - |
499 | - path = gtk_widget_path_new (); |
500 | - gtk_widget_path_append_type (path, GTK_TYPE_MENU); |
501 | - |
502 | - sc = gtk_style_context_new(); |
503 | - |
504 | - proxy_add_css (sc); |
505 | - |
506 | - gtk_style_context_set_path (sc, path); |
507 | - gtk_style_context_add_class (sc, GTK_STYLE_CLASS_MENU); |
508 | - gtk_style_context_add_class (sc, "ido-offscreen"); |
509 | - |
510 | - |
511 | - |
512 | - gtk_widget_path_free (path); |
513 | - |
514 | - return sc; |
515 | -} |
516 | - |
517 | -static gboolean |
518 | -ido_offscreen_proxy_draw (GtkWidget *widget, |
519 | - cairo_t *cr) |
520 | -{ |
521 | - IdoOffscreenProxy *proxy = IDO_OFFSCREEN_PROXY (widget); |
522 | - GdkWindow *window; |
523 | - GtkStyleContext *sc; |
524 | - |
525 | - window = gtk_widget_get_window (widget); |
526 | - |
527 | - sc = get_menu_style_context(); |
528 | - |
529 | - gtk_style_context_add_class (sc, "menubar"); |
530 | - |
531 | - gtk_render_background (sc, cr, |
532 | - 0, 0, |
533 | - gdk_window_get_width (window), |
534 | - gdk_window_get_height (window)); |
535 | - |
536 | - g_object_unref (sc); |
537 | - |
538 | - if (gtk_cairo_should_draw_window (cr, window)) |
539 | - { |
540 | - cairo_surface_t *surface; |
541 | - |
542 | - if (proxy->priv->child && gtk_widget_get_visible (proxy->priv->child)) |
543 | - { |
544 | - surface = gdk_offscreen_window_get_surface (proxy->priv->offscreen_window); |
545 | - |
546 | - cairo_set_source_surface (cr, surface, 0, 0); |
547 | - cairo_paint (cr); |
548 | - } |
549 | - } |
550 | - else if (gtk_cairo_should_draw_window (cr, proxy->priv->offscreen_window)) |
551 | - { |
552 | - if (proxy->priv->child) |
553 | - gtk_container_propagate_draw (GTK_CONTAINER (widget), |
554 | - proxy->priv->child, |
555 | - cr); |
556 | - } |
557 | - |
558 | - return TRUE; |
559 | -} |
560 | |
561 | === removed file 'src/idooffscreenproxy.h' |
562 | --- src/idooffscreenproxy.h 2011-09-02 18:55:39 +0000 |
563 | +++ src/idooffscreenproxy.h 1970-01-01 00:00:00 +0000 |
564 | @@ -1,62 +0,0 @@ |
565 | -/* |
566 | - * Copyright 2011 Canonical, Ltd. |
567 | - * |
568 | - * This program is free software: you can redistribute it and/or modify it |
569 | - * under the terms of either or both of the following licenses: |
570 | - * |
571 | - * 1) the GNU Lesser General Public License version 3, as published by the |
572 | - * Free Software Foundation; and/or |
573 | - * 2) the GNU Lesser General Public License version 2.1, as published by |
574 | - * the Free Software Foundation. |
575 | - * |
576 | - * This program is distributed in the hope that it will be useful, but |
577 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
578 | - * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
579 | - * PURPOSE. See the applicable version of the GNU Lesser General Public |
580 | - * License for more details. |
581 | - * |
582 | - * You should have received a copy of both the GNU Lesser General Public |
583 | - * License version 3 and version 2.1 along with this program. If not, see |
584 | - * <http://www.gnu.org/licenses/> |
585 | - * |
586 | - * Authors: |
587 | - * Robert Carr <racarr@canonical.com> |
588 | - */ |
589 | - |
590 | -#ifndef __IDO_OFFSCREEN_PROXY_H__ |
591 | -#define __IDO_OFFSCREEN_PROXy_H__ |
592 | - |
593 | -#include <gdk/gdk.h> |
594 | -#include <gtk/gtk.h> |
595 | - |
596 | -G_BEGIN_DECLS |
597 | - |
598 | -#define IDO_TYPE_OFFSCREEN_PROXY (ido_offscreen_proxy_get_type ()) |
599 | -#define IDO_OFFSCREEN_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDO_TYPE_OFFSCREEN_PROXY, IdoOffscreenProxy)) |
600 | -#define IDO_OFFSCREEN_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDO_TYPE_OFFSCREEN_PROXY, IdoOffscreenProxyClass)) |
601 | -#define IDO_IS_OFFSCREEN_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDO_TYPE_OFFSCREEN_PROXY)) |
602 | -#define IDO_IS_OFFSCREEN_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDO_TYPE_OFFSCREEN_PROXY)) |
603 | -#define IDO_OFFSCREEN_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDO_TYPE_OFFSCREEN_PROXY, IdoOffscreenProxyClass)) |
604 | - |
605 | -typedef struct _IdoOffscreenProxy IdoOffscreenProxy; |
606 | -typedef struct _IdoOffscreenProxyClass IdoOffscreenProxyClass; |
607 | -typedef struct _IdoOffscreenProxyPrivate IdoOffscreenProxyPrivate; |
608 | - |
609 | -struct _IdoOffscreenProxyClass |
610 | -{ |
611 | - GtkBinClass parent_class; |
612 | -}; |
613 | - |
614 | -struct _IdoOffscreenProxy |
615 | -{ |
616 | - GtkContainer container; |
617 | - |
618 | - IdoOffscreenProxyPrivate *priv; |
619 | -}; |
620 | - |
621 | -GType ido_offscreen_proxy_get_type (void) G_GNUC_CONST; |
622 | -GtkWidget *ido_offscreen_proxy_new (void); |
623 | - |
624 | -G_END_DECLS |
625 | - |
626 | -#endif |
627 | |
628 | === modified file 'src/idoscalemenuitem.c' |
629 | --- src/idoscalemenuitem.c 2011-12-14 17:19:26 +0000 |
630 | +++ src/idoscalemenuitem.c 2012-03-10 01:21:16 +0000 |
631 | @@ -31,10 +31,6 @@ |
632 | #include "idoscalemenuitem.h" |
633 | #include "idotypebuiltins.h" |
634 | |
635 | -#ifdef USE_GTK3 |
636 | -#include "idooffscreenproxy.h" |
637 | -#endif |
638 | - |
639 | static void ido_scale_menu_item_set_property (GObject *object, |
640 | guint prop_id, |
641 | const GValue *value, |
642 | @@ -59,16 +55,10 @@ |
643 | GParamSpec *pspec, |
644 | gpointer user_data); |
645 | static void update_packing (IdoScaleMenuItem *self, |
646 | - IdoScaleMenuItemStyle style, |
647 | - IdoScaleMenuItemStyle old_style); |
648 | + IdoScaleMenuItemStyle style); |
649 | |
650 | struct _IdoScaleMenuItemPrivate { |
651 | GtkWidget *scale; |
652 | - |
653 | -#ifdef USE_GTK3 |
654 | - GtkWidget *proxy; |
655 | -#endif |
656 | - |
657 | GtkAdjustment *adjustment; |
658 | GtkWidget *primary_image; |
659 | GtkWidget *secondary_image; |
660 | @@ -105,13 +95,6 @@ |
661 | |
662 | #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_SCALE_MENU_ITEM, IdoScaleMenuItemPrivate)) |
663 | |
664 | -static void |
665 | -ido_scale_menu_item_state_changed (GtkWidget *widget, |
666 | - GtkStateType previous_state) |
667 | -{ |
668 | - gtk_widget_set_state (widget, GTK_STATE_NORMAL); |
669 | -} |
670 | - |
671 | static gboolean |
672 | ido_scale_menu_item_scroll_event (GtkWidget *menuitem, |
673 | GdkEventScroll *event) |
674 | @@ -250,14 +233,6 @@ |
675 | gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); |
676 | |
677 | #ifdef USE_GTK3 |
678 | - gtk_widget_set_can_focus (priv->scale, FALSE); |
679 | - |
680 | - priv->proxy = ido_offscreen_proxy_new (); |
681 | - g_object_ref (priv->proxy); |
682 | - gtk_container_add (GTK_CONTAINER (priv->proxy), priv->scale); |
683 | -#endif |
684 | - |
685 | -#ifdef USE_GTK3 |
686 | hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); |
687 | #else |
688 | hbox = gtk_hbox_new (FALSE, 0); |
689 | @@ -278,7 +253,7 @@ |
690 | |
691 | priv->hbox = hbox; |
692 | |
693 | - update_packing (self, priv->style, priv->style); |
694 | + update_packing (self, priv->style); |
695 | |
696 | g_signal_connect (self, "toggle-size-allocate", |
697 | G_CALLBACK (ido_scale_menu_item_toggle_size_allocate), |
698 | @@ -301,7 +276,6 @@ |
699 | widget_class->button_release_event = ido_scale_menu_item_button_release_event; |
700 | widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; |
701 | widget_class->scroll_event = ido_scale_menu_item_scroll_event; |
702 | - widget_class->state_changed = ido_scale_menu_item_state_changed; |
703 | widget_class->size_allocate = ido_scale_menu_item_size_allocate; |
704 | |
705 | gobject_class->constructed = ido_scale_menu_item_constructed; |
706 | @@ -362,91 +336,36 @@ |
707 | } |
708 | |
709 | static void |
710 | -update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style, IdoScaleMenuItemStyle old_style) |
711 | +update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style) |
712 | { |
713 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); |
714 | + GtkBox * box = GTK_BOX (priv->hbox); |
715 | GtkContainer *container = GTK_CONTAINER (priv->hbox); |
716 | |
717 | - if (style != old_style) |
718 | - { |
719 | - switch (old_style) |
720 | - { |
721 | - case IDO_SCALE_MENU_ITEM_STYLE_NONE: |
722 | -#ifdef USE_GTK3 |
723 | - gtk_container_remove (container, priv->proxy); |
724 | -#else |
725 | - gtk_container_remove (container, priv->scale); |
726 | -#endif |
727 | - break; |
728 | - |
729 | - case IDO_SCALE_MENU_ITEM_STYLE_IMAGE: |
730 | - gtk_container_remove (container, priv->primary_image); |
731 | - gtk_container_remove (container, priv->secondary_image); |
732 | -#ifdef USE_GTK3 |
733 | - gtk_container_remove (container, priv->proxy); |
734 | -#else |
735 | - gtk_container_remove (container, priv->scale); |
736 | -#endif |
737 | - break; |
738 | - |
739 | - case IDO_SCALE_MENU_ITEM_STYLE_LABEL: |
740 | - gtk_container_remove (container, priv->primary_label); |
741 | - gtk_container_remove (container, priv->secondary_label); |
742 | -#ifdef USE_GTK3 |
743 | - gtk_container_remove (container, priv->proxy); |
744 | -#else |
745 | - gtk_container_remove (container, priv->scale); |
746 | -#endif |
747 | - break; |
748 | - |
749 | - default: |
750 | -#ifdef USE_GTK3 |
751 | - gtk_container_remove (container, priv->proxy); |
752 | -#else |
753 | - gtk_container_remove (container, priv->scale); |
754 | -#endif |
755 | - break; |
756 | - } |
757 | - } |
758 | - |
759 | + /* remove the old layout */ |
760 | + GList * children = gtk_container_get_children (container); |
761 | + GList * l; |
762 | + for (l=children; l!=NULL; l=l->next) |
763 | + gtk_container_remove (container, l->data); |
764 | + g_list_free (children); |
765 | + |
766 | + /* add the new layout */ |
767 | switch (style) |
768 | { |
769 | - case IDO_SCALE_MENU_ITEM_STYLE_NONE: |
770 | -#ifdef USE_GTK3 |
771 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->proxy, FALSE, FALSE, 0); |
772 | -#else |
773 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); |
774 | -#endif |
775 | - break; |
776 | - |
777 | case IDO_SCALE_MENU_ITEM_STYLE_IMAGE: |
778 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->primary_image, FALSE, FALSE, 0); |
779 | - |
780 | -#ifdef USE_GTK3 |
781 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->proxy, FALSE, FALSE, 0); |
782 | -#else |
783 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); |
784 | -#endif |
785 | - |
786 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->secondary_image, FALSE, FALSE, 0); |
787 | + gtk_box_pack_start (box, priv->primary_image, FALSE, FALSE, 0); |
788 | + gtk_box_pack_start (box, priv->scale, FALSE, FALSE, 0); |
789 | + gtk_box_pack_start (box, priv->secondary_image, FALSE, FALSE, 0); |
790 | break; |
791 | |
792 | case IDO_SCALE_MENU_ITEM_STYLE_LABEL: |
793 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->primary_label, FALSE, FALSE, 0); |
794 | -#ifdef USE_GTK3 |
795 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->proxy, FALSE, FALSE, 0); |
796 | -#else |
797 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); |
798 | -#endif |
799 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->secondary_label, FALSE, FALSE, 0); |
800 | + gtk_box_pack_start (box, priv->primary_label, FALSE, FALSE, 0); |
801 | + gtk_box_pack_start (box, priv->scale, FALSE, FALSE, 0); |
802 | + gtk_box_pack_start (box, priv->secondary_label, FALSE, FALSE, 0); |
803 | break; |
804 | |
805 | default: |
806 | -#ifdef USE_GTK3 |
807 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->proxy, FALSE, FALSE, 0); |
808 | -#else |
809 | - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); |
810 | -#endif |
811 | + gtk_box_pack_start (box, priv->scale, FALSE, FALSE, 0); |
812 | break; |
813 | } |
814 | |
815 | @@ -812,16 +731,14 @@ |
816 | IdoScaleMenuItemStyle style) |
817 | { |
818 | IdoScaleMenuItemPrivate *priv; |
819 | - IdoScaleMenuItemStyle old_style; |
820 | |
821 | g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem)); |
822 | |
823 | priv = GET_PRIVATE (menuitem); |
824 | |
825 | - old_style = priv->style; |
826 | priv->style = style; |
827 | |
828 | - update_packing (menuitem, style, old_style); |
829 | + update_packing (menuitem, style); |
830 | } |
831 | |
832 | /** |
Looking good ! Finally a maintainer for our libido ;-)