e076699e |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 XangXiu Yang |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
daecc161 |
19 | #include <gtk/gtk.h> |
20 | |
21 | #include <lttv/gtkmultivpaned.h> |
22 | //#include "gtkintl.h" |
637bd544 |
23 | #include <lttv/mainwindow.h> |
cef97e7c |
24 | #include <lttv/gtktraceset.h> |
daecc161 |
25 | |
26 | static void gtk_multi_vpaned_class_init (GtkMultiVPanedClass *klass); |
27 | static void gtk_multi_vpaned_init (GtkMultiVPaned *multi_vpaned); |
28 | |
29 | |
30 | static void gtk_multi_vpaned_size_request (GtkWidget *widget, |
31 | GtkRequisition *requisition); |
32 | static void gtk_multi_vpaned_size_allocate (GtkWidget *widget, |
33 | GtkAllocation *allocation); |
34 | |
35 | void gtk_multi_vpaned_scroll_value_changed (GtkRange *range, gpointer multi_vpaned); |
36 | |
0ed9daf7 |
37 | gboolean gtk_multi_vpaned_destroy(GtkObject *object, |
38 | gpointer user_data) |
39 | { |
40 | GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned * )object; |
41 | while(multi_vpaned->num_children){ |
42 | gtk_multi_vpaned_widget_delete(multi_vpaned); |
43 | } |
44 | return FALSE; |
45 | } |
46 | |
daecc161 |
47 | GType |
48 | gtk_multi_vpaned_get_type (void) |
49 | { |
50 | static GType multi_vpaned_type = 0; |
51 | |
52 | if (!multi_vpaned_type) |
53 | { |
54 | static const GTypeInfo multi_vpaned_info = |
55 | { |
56 | sizeof (GtkMultiVPanedClass), |
57 | NULL, /* base_init */ |
58 | NULL, /* base_finalize */ |
59 | (GClassInitFunc) gtk_multi_vpaned_class_init, |
60 | NULL, /* class_finalize */ |
61 | NULL, /* class_data */ |
62 | sizeof (GtkMultiVPaned), |
63 | 0, /* n_preallocs */ |
64 | (GInstanceInitFunc) gtk_multi_vpaned_init, |
65 | NULL, /* value_table */ |
66 | }; |
67 | |
68 | multi_vpaned_type = g_type_register_static (GTK_TYPE_PANED, "GtkMultiVPaned", |
69 | &multi_vpaned_info, 0); |
70 | } |
71 | |
72 | return multi_vpaned_type; |
73 | } |
74 | |
75 | static void |
76 | gtk_multi_vpaned_class_init (GtkMultiVPanedClass *class) |
77 | { |
78 | GtkWidgetClass *widget_class; |
79 | |
80 | widget_class = (GtkWidgetClass *) class; |
81 | |
82 | widget_class->size_request = gtk_multi_vpaned_size_request; |
83 | widget_class->size_allocate = gtk_multi_vpaned_size_allocate; |
84 | } |
85 | |
86 | static void |
87 | gtk_multi_vpaned_init (GtkMultiVPaned * multi_vpaned) |
88 | { |
89 | GtkWidget * button; |
90 | |
91 | GTK_WIDGET_SET_FLAGS (multi_vpaned, GTK_NO_WINDOW); |
92 | gtk_widget_set_redraw_on_allocate (GTK_WIDGET (multi_vpaned), FALSE); |
93 | |
94 | multi_vpaned->first_pane = NULL; |
95 | multi_vpaned->last_pane = NULL; |
96 | multi_vpaned->focused_pane = NULL; |
49bf71b5 |
97 | multi_vpaned->iter = NULL; |
daecc161 |
98 | multi_vpaned->num_children = 0; |
99 | |
100 | multi_vpaned->vbox = NULL; |
101 | // multi_vpaned->scrollWindow = NULL; |
102 | // multi_vpaned->viewport = NULL; |
103 | multi_vpaned->hscrollbar = NULL; |
104 | } |
105 | |
106 | |
107 | GtkWidget* gtk_multi_vpaned_new () |
108 | { |
0ed9daf7 |
109 | GtkWidget * widget = GTK_WIDGET (g_object_new (gtk_multi_vpaned_get_type (), NULL)); |
110 | g_signal_connect(G_OBJECT(widget), "destroy", |
111 | G_CALLBACK(gtk_multi_vpaned_destroy),NULL); |
112 | |
113 | return widget; |
daecc161 |
114 | } |
115 | |
49bf71b5 |
116 | GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned) |
117 | { |
118 | if(multi_vpaned->focused_pane == NULL)return NULL; |
119 | return (GtkWidget*)multi_vpaned->focused_pane->child2; |
120 | } |
121 | |
122 | GtkWidget * gtk_multi_vpaned_get_first_widget(GtkMultiVPaned * multi_vpaned) |
123 | { |
124 | if(multi_vpaned->first_pane == NULL)return NULL; |
125 | multi_vpaned->iter = multi_vpaned->first_pane; |
126 | return multi_vpaned->first_pane->child2; |
127 | } |
128 | |
129 | GtkWidget * gtk_multi_vpaned_get_next_widget(GtkMultiVPaned * multi_vpaned) |
130 | { |
131 | if(multi_vpaned->iter != multi_vpaned->last_pane){ |
132 | multi_vpaned->iter = (GtkPaned *)multi_vpaned->iter->child1; |
133 | return multi_vpaned->iter->child2; |
134 | }else { |
135 | return NULL; |
136 | } |
137 | } |
138 | |
139 | void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned,char * key, gpointer value) |
140 | { |
141 | g_object_set_data(G_OBJECT(multi_vpaned->focused_pane), key, value); |
142 | } |
143 | |
144 | gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned,char * key) |
145 | { |
146 | if(multi_vpaned->focused_pane == NULL)return NULL; |
147 | return g_object_get_data(G_OBJECT(multi_vpaned->focused_pane), key); |
148 | } |
daecc161 |
149 | |
150 | void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data) |
151 | { |
152 | GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*) widget; |
153 | GtkPaned * pane; |
154 | if(!multi_vpaned->first_pane) return; |
155 | |
156 | |
157 | pane = multi_vpaned->first_pane; |
158 | while(1){ |
159 | if((GtkWidget*)pane == (GtkWidget*)user_data){ |
160 | multi_vpaned->focused_pane = pane; |
161 | break; |
162 | } |
163 | if(pane == multi_vpaned->last_pane){ |
164 | multi_vpaned->focused_pane = NULL; |
165 | break; |
166 | } |
167 | pane = (GtkPaned*)pane->child1; |
168 | } |
169 | } |
170 | |
171 | void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time) |
172 | { |
173 | TimeWindow time_window; |
174 | TimeInterval *time_span; |
175 | double tmp, start; |
176 | double range = 0; |
177 | |
178 | get_time_window(multi_vpaned->mw,&time_window); |
179 | if(first_time){ |
180 | time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info-> |
181 | traceset_context)->Time_Span ; |
182 | |
183 | multi_vpaned->hadjust->lower = ltt_time_to_double(time_span->startTime) * |
184 | NANOSECONDS_PER_SECOND; |
185 | multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower; |
186 | multi_vpaned->hadjust->upper = ltt_time_to_double(time_span->endTime) * |
187 | NANOSECONDS_PER_SECOND; |
188 | } |
189 | |
190 | /* Page increment of whole visible area */ |
191 | if(multi_vpaned->hadjust == NULL){ |
192 | g_warning("Insert a viewer first"); |
193 | return; |
194 | } |
195 | |
196 | start = ltt_time_to_double(time_window.start_time) * NANOSECONDS_PER_SECOND; |
197 | tmp = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower; |
198 | |
199 | multi_vpaned->hadjust->page_increment = ltt_time_to_double( |
200 | time_window.time_width) * NANOSECONDS_PER_SECOND; |
201 | |
202 | if(multi_vpaned->hadjust->page_increment >= tmp - range) |
203 | multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower; |
204 | if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper - range) |
205 | multi_vpaned->hadjust->value = start; |
206 | |
207 | /* page_size to the whole visible area will take care that the |
208 | * scroll value + the shown area will never be more than what is |
209 | * in the trace. */ |
210 | multi_vpaned->hadjust->page_size = multi_vpaned->hadjust->page_increment; |
211 | multi_vpaned->hadjust->step_increment = multi_vpaned->hadjust->page_increment / 10; |
212 | |
213 | gtk_adjustment_changed (multi_vpaned->hadjust); |
214 | } |
215 | |
216 | void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1) |
217 | { |
218 | GtkPaned * tmpPane; |
219 | GtkWidget * w; |
220 | |
221 | g_return_if_fail(GTK_IS_MULTI_VPANED(multi_vpaned)); |
222 | g_object_ref(G_OBJECT(widget1)); |
223 | |
224 | |
225 | if(!multi_vpaned->first_pane){ |
226 | multi_vpaned->first_pane = (GtkPaned *)gtk_vpaned_new(); |
227 | multi_vpaned->last_pane = multi_vpaned->first_pane; |
228 | |
229 | multi_vpaned->hscrollbar = gtk_hscrollbar_new (NULL); |
230 | gtk_widget_show(multi_vpaned->hscrollbar); |
231 | |
232 | multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar)); |
233 | gtk_multi_vpaned_set_adjust(multi_vpaned, TRUE); |
234 | |
235 | gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar), |
4a93bd36 |
236 | GTK_UPDATE_CONTINUOUS); |
237 | //changed by Mathieu Desnoyers, was : |
238 | // GTK_UPDATE_DISCONTINUOUS); |
daecc161 |
239 | g_signal_connect(G_OBJECT(multi_vpaned->hscrollbar), "value-changed", |
240 | G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned); |
241 | |
242 | multi_vpaned->vbox = gtk_vbox_new(FALSE,0); |
243 | gtk_widget_show(multi_vpaned->vbox); |
244 | |
245 | // multi_vpaned->viewport = gtk_viewport_new (NULL,NULL); |
246 | // gtk_widget_show(multi_vpaned->viewport); |
247 | |
248 | // gtk_container_add(GTK_CONTAINER(multi_vpaned->viewport), (GtkWidget*)multi_vpaned->vbox); |
249 | gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->hscrollbar,FALSE,FALSE,0); |
250 | gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0); |
251 | |
252 | // multi_vpaned->scrollWindow = gtk_scrolled_window_new (NULL, NULL); |
253 | // gtk_widget_show(multi_vpaned->scrollWindow); |
254 | // gtk_container_add (GTK_CONTAINER (multi_vpaned->scrollWindow), (GtkWidget*)multi_vpaned->viewport); |
255 | // gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->scrollWindow,FALSE, TRUE); |
256 | |
257 | gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->vbox,FALSE, TRUE); |
258 | }else{ |
259 | tmpPane = multi_vpaned->last_pane; |
260 | multi_vpaned->last_pane = (GtkPaned *)gtk_vpaned_new(); |
261 | gtk_paned_pack1 (tmpPane,(GtkWidget*)multi_vpaned->last_pane, FALSE,TRUE); |
262 | } |
263 | gtk_widget_show((GtkWidget *)multi_vpaned->last_pane); |
264 | |
265 | gtk_paned_pack2 (multi_vpaned->last_pane,widget1, TRUE, TRUE); |
266 | multi_vpaned->focused_pane = multi_vpaned->last_pane; |
267 | multi_vpaned->num_children++; |
268 | |
269 | } |
270 | |
271 | void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned) |
272 | { |
273 | GtkPaned * tmp, *prev, *next; |
274 | |
275 | if(!multi_vpaned->focused_pane) return; |
276 | |
277 | tmp = (GtkPaned*)multi_vpaned->focused_pane->child2; //widget in vpaned |
278 | g_object_unref(G_OBJECT(tmp)); |
279 | |
280 | if(multi_vpaned->focused_pane == multi_vpaned->first_pane && |
281 | multi_vpaned->focused_pane == multi_vpaned->last_pane){ |
282 | // gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->scrollWindow); |
283 | gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->vbox); |
284 | multi_vpaned->first_pane = NULL; |
285 | multi_vpaned->last_pane = NULL; |
286 | multi_vpaned->focused_pane = NULL; |
287 | }else if(multi_vpaned->focused_pane == multi_vpaned->first_pane && |
288 | multi_vpaned->focused_pane != multi_vpaned->last_pane){ |
289 | next = (GtkPaned*)multi_vpaned->first_pane->child1; |
290 | g_object_ref(G_OBJECT(next)); |
291 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->first_pane),(GtkWidget*)next); |
292 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane); |
293 | multi_vpaned->first_pane = next; |
294 | gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0); |
295 | multi_vpaned->focused_pane = multi_vpaned->first_pane; |
296 | g_object_unref(G_OBJECT(next)); |
297 | }else if(multi_vpaned->focused_pane != multi_vpaned->first_pane && |
298 | multi_vpaned->focused_pane == multi_vpaned->last_pane){ |
299 | tmp = multi_vpaned->last_pane; |
300 | multi_vpaned->last_pane = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->last_pane); |
301 | multi_vpaned->focused_pane = multi_vpaned->last_pane; |
302 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->last_pane),(GtkWidget*)tmp); |
303 | }else{ |
304 | tmp = multi_vpaned->focused_pane; |
305 | prev = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)tmp); |
306 | next = (GtkPaned*)tmp->child1; |
307 | g_object_ref(G_OBJECT(next)); |
308 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)next); |
309 | gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)multi_vpaned->focused_pane); |
310 | gtk_paned_pack1(prev, (GtkWidget*)next, FALSE, TRUE); |
311 | multi_vpaned->focused_pane = next; |
312 | g_object_unref(G_OBJECT(next)); |
313 | } |
314 | |
315 | multi_vpaned->num_children--; |
316 | } |
317 | |
318 | |
319 | void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned) |
320 | { |
321 | GtkWidget* upWidget, *downWidget; |
322 | GtkPaned * prev,*next, *prevPrev; |
323 | |
324 | if(multi_vpaned->last_pane == multi_vpaned->focused_pane) return; |
325 | |
326 | // move VPane |
327 | prev = (GtkPaned*)multi_vpaned->focused_pane->child1; |
328 | g_object_ref(G_OBJECT(prev)); |
329 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev); |
330 | |
331 | if(prev == multi_vpaned->last_pane){ |
332 | prevPrev = NULL; |
333 | multi_vpaned->last_pane = multi_vpaned->focused_pane; |
334 | }else{ |
335 | prevPrev = (GtkPaned*)prev->child1; |
336 | g_object_ref(G_OBJECT(prevPrev)); |
337 | gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)prevPrev); |
338 | } |
339 | |
340 | g_object_ref(G_OBJECT(multi_vpaned->focused_pane)); |
341 | if(multi_vpaned->first_pane == multi_vpaned->focused_pane){ |
342 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane); |
343 | gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)prev,TRUE,TRUE,0); |
344 | multi_vpaned->first_pane = prev; |
345 | }else{ |
346 | next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane); |
347 | gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane); |
348 | gtk_paned_pack1(GTK_PANED(next), (GtkWidget*)prev, FALSE,TRUE); |
349 | } |
350 | gtk_paned_pack1(GTK_PANED(prev),(GtkWidget*)multi_vpaned->focused_pane, FALSE,TRUE); |
351 | if(prevPrev) |
352 | gtk_paned_pack1(GTK_PANED(multi_vpaned->focused_pane),(GtkWidget*)prevPrev, FALSE,TRUE); |
353 | |
354 | g_object_unref(G_OBJECT(prev)); |
355 | if(prevPrev) g_object_unref(G_OBJECT(prevPrev)); |
356 | g_object_unref(G_OBJECT(multi_vpaned->focused_pane)); |
357 | } |
358 | |
359 | |
360 | void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned) |
361 | { |
362 | GtkWidget* upWidget, *downWidget; |
363 | GtkPaned * prev,*next, *nextNext; |
364 | |
365 | if(multi_vpaned->first_pane == multi_vpaned->focused_pane) return; |
366 | |
367 | //move VPane |
368 | next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane); |
369 | g_object_ref(G_OBJECT(next)); |
370 | |
371 | if(multi_vpaned->last_pane == multi_vpaned->focused_pane){ |
372 | prev = NULL; |
373 | multi_vpaned->last_pane = next; |
374 | }else{ |
375 | prev = (GtkPaned*)multi_vpaned->focused_pane->child1; |
376 | g_object_ref(G_OBJECT(prev)); |
377 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev); |
378 | } |
379 | |
380 | g_object_ref(G_OBJECT(multi_vpaned->focused_pane)); |
381 | gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane); |
382 | |
383 | if(next == multi_vpaned->first_pane){ |
384 | multi_vpaned->first_pane = multi_vpaned->focused_pane; |
385 | gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)next); |
386 | gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane,TRUE,TRUE,0); |
387 | }else{ |
388 | nextNext = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)next); |
389 | gtk_container_remove(GTK_CONTAINER(nextNext),(GtkWidget*)next); |
390 | gtk_paned_pack1(nextNext, (GtkWidget*)multi_vpaned->focused_pane, FALSE, TRUE); |
391 | } |
392 | gtk_paned_pack1(multi_vpaned->focused_pane,(GtkWidget*)next, FALSE,TRUE); |
393 | if(prev) |
394 | gtk_paned_pack1(next,(GtkWidget*)prev, FALSE,TRUE); |
395 | |
396 | if(prev)g_object_unref(G_OBJECT(prev)); |
397 | g_object_unref(G_OBJECT(next)); |
398 | g_object_unref(G_OBJECT(multi_vpaned->focused_pane)); |
399 | } |
400 | |
bca085a1 |
401 | void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value) |
402 | { |
403 | gtk_adjustment_set_value(multi_vpaned->hadjust, value); |
404 | g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed"); |
405 | } |
406 | |
daecc161 |
407 | void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg) |
408 | { |
58eecf4a |
409 | TimeWindow time_window; |
410 | TimeInterval *time_span; |
daecc161 |
411 | LttTime time; |
412 | GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg; |
413 | gdouble value = gtk_range_get_value(range); |
58eecf4a |
414 | gdouble upper, lower, ratio; |
415 | |
416 | time_window = multi_vpaned->mw->current_tab->time_window; |
417 | |
418 | time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info-> |
419 | traceset_context)->Time_Span ; |
420 | lower = multi_vpaned->hadjust->lower; |
421 | upper = multi_vpaned->hadjust->upper; |
422 | ratio = (value - lower) / (upper - lower); |
423 | |
424 | time = ltt_time_sub(time_span->endTime, time_span->startTime); |
425 | time = ltt_time_mul(time, (float)ratio); |
426 | time = ltt_time_add(time_span->startTime, time); |
427 | |
428 | time_window.start_time = time; |
429 | |
430 | time = ltt_time_sub(time_span->endTime, time); |
431 | if(ltt_time_compare(time,time_window.time_width) < 0){ |
432 | time_window.time_width = time; |
433 | } |
434 | set_time_window(multi_vpaned->mw, &time_window); |
daecc161 |
435 | } |
436 | |
437 | |
438 | static void |
439 | gtk_multi_vpaned_size_request (GtkWidget *widget, |
440 | GtkRequisition *requisition) |
441 | { |
442 | GtkPaned *paned = GTK_PANED (widget); |
443 | GtkRequisition child_requisition; |
444 | |
445 | requisition->width = 0; |
446 | requisition->height = 0; |
447 | |
448 | if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1)) |
449 | { |
450 | gtk_widget_size_request (paned->child1, &child_requisition); |
451 | |
452 | requisition->height = child_requisition.height; |
453 | requisition->width = child_requisition.width; |
454 | } |
455 | |
456 | if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) |
457 | { |
458 | gtk_widget_size_request (paned->child2, &child_requisition); |
459 | |
460 | requisition->width = MAX (requisition->width, child_requisition.width); |
461 | requisition->height += child_requisition.height; |
462 | } |
463 | |
464 | requisition->height += GTK_CONTAINER (paned)->border_width * 2; |
465 | requisition->width += GTK_CONTAINER (paned)->border_width * 2; |
466 | |
467 | if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) && |
468 | paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) |
469 | { |
470 | gint handle_size; |
471 | |
472 | gtk_widget_style_get (widget, "handle_size", &handle_size, NULL); |
473 | requisition->height += handle_size; |
474 | } |
475 | |
476 | } |
477 | |
478 | static void |
479 | gtk_multi_vpaned_size_allocate (GtkWidget *widget, |
480 | GtkAllocation *allocation) |
481 | { |
482 | GtkPaned *paned = GTK_PANED (widget); |
483 | gint border_width = GTK_CONTAINER (paned)->border_width; |
484 | |
485 | widget->allocation = *allocation; |
486 | |
487 | if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) && |
488 | paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) |
489 | { |
490 | GtkRequisition child1_requisition; |
491 | GtkRequisition child2_requisition; |
492 | GtkAllocation child1_allocation; |
493 | GtkAllocation child2_allocation; |
494 | gint handle_size; |
495 | |
496 | gtk_widget_style_get (widget, "handle_size", &handle_size, NULL); |
497 | |
498 | gtk_widget_get_child_requisition (paned->child1, &child1_requisition); |
499 | gtk_widget_get_child_requisition (paned->child2, &child2_requisition); |
500 | |
501 | gtk_paned_compute_position (paned, |
502 | MAX (1, widget->allocation.height |
503 | - handle_size |
504 | - 2 * border_width), |
505 | child1_requisition.height, |
506 | child2_requisition.height); |
507 | |
508 | paned->handle_pos.x = widget->allocation.x + border_width; |
509 | paned->handle_pos.y = widget->allocation.y + paned->child1_size + border_width; |
510 | paned->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width); |
511 | paned->handle_pos.height = handle_size; |
512 | |
513 | if (GTK_WIDGET_REALIZED (widget)) |
514 | { |
515 | if (GTK_WIDGET_MAPPED (widget)) |
516 | gdk_window_show (paned->handle); |
517 | gdk_window_move_resize (paned->handle, |
518 | paned->handle_pos.x, |
519 | paned->handle_pos.y, |
520 | paned->handle_pos.width, |
521 | handle_size); |
522 | } |
523 | |
524 | child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2); |
525 | child1_allocation.height = MAX (1, paned->child1_size); |
526 | child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width; |
527 | child1_allocation.y = widget->allocation.y + border_width; |
528 | |
529 | child2_allocation.y = child1_allocation.y + paned->child1_size + paned->handle_pos.height; |
530 | child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width); |
531 | |
532 | if (GTK_WIDGET_MAPPED (widget) && |
533 | paned->child1->allocation.height < child1_allocation.height) |
534 | { |
535 | gtk_widget_size_allocate (paned->child2, &child2_allocation); |
536 | gtk_widget_size_allocate (paned->child1, &child1_allocation); |
537 | } |
538 | else |
539 | { |
540 | gtk_widget_size_allocate (paned->child1, &child1_allocation); |
541 | gtk_widget_size_allocate (paned->child2, &child2_allocation); |
542 | } |
543 | } |
544 | else |
545 | { |
546 | GtkAllocation child_allocation; |
547 | |
548 | if (GTK_WIDGET_REALIZED (widget)) |
549 | gdk_window_hide (paned->handle); |
550 | |
551 | if (paned->child1) |
552 | gtk_widget_set_child_visible (paned->child1, TRUE); |
553 | if (paned->child2) |
554 | gtk_widget_set_child_visible (paned->child2, TRUE); |
555 | |
556 | child_allocation.x = widget->allocation.x + border_width; |
557 | child_allocation.y = widget->allocation.y + border_width; |
558 | child_allocation.width = MAX (1, allocation->width - 2 * border_width); |
559 | child_allocation.height = MAX (1, allocation->height - 2 * border_width); |
560 | |
561 | if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1)) |
562 | gtk_widget_size_allocate (paned->child1, &child_allocation); |
563 | else if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) |
564 | gtk_widget_size_allocate (paned->child2, &child_allocation); |
565 | } |
566 | } |
567 | |