begin background computation implementation
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / gtkmultivpaned.c
CommitLineData
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
13f86ce2 21#include <lttvwindow/gtkmultivpaned.h>
daecc161 22//#include "gtkintl.h"
13f86ce2 23#include <lttvwindow/mainwindow.h>
36b40c74 24#include <lttvwindow/viewer.h>
daecc161 25
26static void gtk_multi_vpaned_class_init (GtkMultiVPanedClass *klass);
27static void gtk_multi_vpaned_init (GtkMultiVPaned *multi_vpaned);
28
29
30static void gtk_multi_vpaned_size_request (GtkWidget *widget,
31 GtkRequisition *requisition);
32static void gtk_multi_vpaned_size_allocate (GtkWidget *widget,
33 GtkAllocation *allocation);
34
a43d67ba 35void gtk_multi_vpaned_scroll_value_changed (GtkAdjustment *adjust, gpointer multi_vpaned);
daecc161 36
0ed9daf7 37gboolean 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 47GType
48gtk_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
75static void
76gtk_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
86static void
87gtk_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
107GtkWidget* 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 116GtkWidget * 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
122GtkWidget * 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
129GtkWidget * 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
139void 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
144gpointer 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
5a5b35c5 150void gtk_multi_vpaned_set_focus (GtkWidget * widget, GtkPaned* paned)
daecc161 151{
5a5b35c5 152 GtkMultiVPaned * multi_vpaned = GTK_MULTI_VPANED(widget);
daecc161 153 GtkPaned * pane;
154 if(!multi_vpaned->first_pane) return;
155
156
157 pane = multi_vpaned->first_pane;
158 while(1){
7afc14aa 159 if((GtkWidget*)pane == GTK_WIDGET(paned)){
daecc161 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
a43d67ba 171void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, const TimeWindow *time_window, gboolean first_time)
daecc161 172{
a43d67ba 173 //TimeWindow time_window = multi_vpaned->mw->current_tab->time_window;
daecc161 174 TimeInterval *time_span;
a43d67ba 175 double len, start;
daecc161 176
297f7a48 177
daecc161 178 if(first_time){
7afc14aa 179 time_span = &LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->
180 traceset_info->traceset_context)->time_span ;
daecc161 181
7afc14aa 182 multi_vpaned->hadjust->lower = ltt_time_to_double(time_span->start_time) *
daecc161 183 NANOSECONDS_PER_SECOND;
184 multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
7afc14aa 185 multi_vpaned->hadjust->upper = ltt_time_to_double(time_span->end_time) *
daecc161 186 NANOSECONDS_PER_SECOND;
187 }
188
189 /* Page increment of whole visible area */
190 if(multi_vpaned->hadjust == NULL){
191 g_warning("Insert a viewer first");
192 return;
193 }
194
a43d67ba 195 start = ltt_time_to_double(time_window->start_time) * NANOSECONDS_PER_SECOND;
196 len = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower;
daecc161 197
198 multi_vpaned->hadjust->page_increment = ltt_time_to_double(
a43d67ba 199 time_window->time_width) * NANOSECONDS_PER_SECOND;
daecc161 200
a43d67ba 201 //if(multi_vpaned->hadjust->page_increment >= len )
202 // multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
203 //if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper )
204 // multi_vpaned->hadjust->value = start;
205 multi_vpaned->hadjust->value = start;
daecc161 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);
a43d67ba 214
daecc161 215}
216
217void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1)
218{
219 GtkPaned * tmpPane;
220 GtkWidget * w;
221
222 g_return_if_fail(GTK_IS_MULTI_VPANED(multi_vpaned));
223 g_object_ref(G_OBJECT(widget1));
224
225
226 if(!multi_vpaned->first_pane){
227 multi_vpaned->first_pane = (GtkPaned *)gtk_vpaned_new();
228 multi_vpaned->last_pane = multi_vpaned->first_pane;
229
230 multi_vpaned->hscrollbar = gtk_hscrollbar_new (NULL);
231 gtk_widget_show(multi_vpaned->hscrollbar);
232
233 multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar));
a43d67ba 234 gtk_multi_vpaned_set_adjust(multi_vpaned, &multi_vpaned->mw->current_tab->time_window, TRUE);
daecc161 235
236 gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar),
4a93bd36 237 GTK_UPDATE_CONTINUOUS);
238 //changed by Mathieu Desnoyers, was :
239 // GTK_UPDATE_DISCONTINUOUS);
a43d67ba 240 g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "value-changed",
daecc161 241 G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
a43d67ba 242 g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "changed",
243 G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
244
daecc161 245
246 multi_vpaned->vbox = gtk_vbox_new(FALSE,0);
247 gtk_widget_show(multi_vpaned->vbox);
248
249 // multi_vpaned->viewport = gtk_viewport_new (NULL,NULL);
250 // gtk_widget_show(multi_vpaned->viewport);
251
252 // gtk_container_add(GTK_CONTAINER(multi_vpaned->viewport), (GtkWidget*)multi_vpaned->vbox);
253 gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->hscrollbar,FALSE,FALSE,0);
254 gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
255
256 // multi_vpaned->scrollWindow = gtk_scrolled_window_new (NULL, NULL);
257 // gtk_widget_show(multi_vpaned->scrollWindow);
258 // gtk_container_add (GTK_CONTAINER (multi_vpaned->scrollWindow), (GtkWidget*)multi_vpaned->viewport);
259 // gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->scrollWindow,FALSE, TRUE);
260
261 gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->vbox,FALSE, TRUE);
262 }else{
263 tmpPane = multi_vpaned->last_pane;
264 multi_vpaned->last_pane = (GtkPaned *)gtk_vpaned_new();
265 gtk_paned_pack1 (tmpPane,(GtkWidget*)multi_vpaned->last_pane, FALSE,TRUE);
266 }
267 gtk_widget_show((GtkWidget *)multi_vpaned->last_pane);
268
269 gtk_paned_pack2 (multi_vpaned->last_pane,widget1, TRUE, TRUE);
270 multi_vpaned->focused_pane = multi_vpaned->last_pane;
271 multi_vpaned->num_children++;
272
273}
274
275void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned)
276{
277 GtkPaned * tmp, *prev, *next;
278
279 if(!multi_vpaned->focused_pane) return;
280
281 tmp = (GtkPaned*)multi_vpaned->focused_pane->child2; //widget in vpaned
282 g_object_unref(G_OBJECT(tmp));
283
284 if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
285 multi_vpaned->focused_pane == multi_vpaned->last_pane){
286 // gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->scrollWindow);
287 gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->vbox);
288 multi_vpaned->first_pane = NULL;
289 multi_vpaned->last_pane = NULL;
290 multi_vpaned->focused_pane = NULL;
291 }else if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
292 multi_vpaned->focused_pane != multi_vpaned->last_pane){
293 next = (GtkPaned*)multi_vpaned->first_pane->child1;
294 g_object_ref(G_OBJECT(next));
295 gtk_container_remove(GTK_CONTAINER(multi_vpaned->first_pane),(GtkWidget*)next);
296 gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane);
297 multi_vpaned->first_pane = next;
298 gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
299 multi_vpaned->focused_pane = multi_vpaned->first_pane;
300 g_object_unref(G_OBJECT(next));
301 }else if(multi_vpaned->focused_pane != multi_vpaned->first_pane &&
302 multi_vpaned->focused_pane == multi_vpaned->last_pane){
303 tmp = multi_vpaned->last_pane;
304 multi_vpaned->last_pane = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->last_pane);
305 multi_vpaned->focused_pane = multi_vpaned->last_pane;
306 gtk_container_remove(GTK_CONTAINER(multi_vpaned->last_pane),(GtkWidget*)tmp);
307 }else{
308 tmp = multi_vpaned->focused_pane;
309 prev = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)tmp);
310 next = (GtkPaned*)tmp->child1;
311 g_object_ref(G_OBJECT(next));
312 gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)next);
313 gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)multi_vpaned->focused_pane);
314 gtk_paned_pack1(prev, (GtkWidget*)next, FALSE, TRUE);
315 multi_vpaned->focused_pane = next;
316 g_object_unref(G_OBJECT(next));
317 }
318
319 multi_vpaned->num_children--;
320}
321
322
323void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned)
324{
325 GtkWidget* upWidget, *downWidget;
326 GtkPaned * prev,*next, *prevPrev;
327
328 if(multi_vpaned->last_pane == multi_vpaned->focused_pane) return;
329
330 // move VPane
331 prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
332 g_object_ref(G_OBJECT(prev));
333 gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);
334
335 if(prev == multi_vpaned->last_pane){
336 prevPrev = NULL;
337 multi_vpaned->last_pane = multi_vpaned->focused_pane;
338 }else{
339 prevPrev = (GtkPaned*)prev->child1;
340 g_object_ref(G_OBJECT(prevPrev));
341 gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)prevPrev);
342 }
343
344 g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
345 if(multi_vpaned->first_pane == multi_vpaned->focused_pane){
346 gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane);
347 gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)prev,TRUE,TRUE,0);
348 multi_vpaned->first_pane = prev;
349 }else{
350 next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
351 gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
352 gtk_paned_pack1(GTK_PANED(next), (GtkWidget*)prev, FALSE,TRUE);
353 }
354 gtk_paned_pack1(GTK_PANED(prev),(GtkWidget*)multi_vpaned->focused_pane, FALSE,TRUE);
355 if(prevPrev)
356 gtk_paned_pack1(GTK_PANED(multi_vpaned->focused_pane),(GtkWidget*)prevPrev, FALSE,TRUE);
357
358 g_object_unref(G_OBJECT(prev));
359 if(prevPrev) g_object_unref(G_OBJECT(prevPrev));
360 g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
361}
362
363
364void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned)
365{
366 GtkWidget* upWidget, *downWidget;
367 GtkPaned * prev,*next, *nextNext;
368
369 if(multi_vpaned->first_pane == multi_vpaned->focused_pane) return;
370
371 //move VPane
372 next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
373 g_object_ref(G_OBJECT(next));
374
375 if(multi_vpaned->last_pane == multi_vpaned->focused_pane){
376 prev = NULL;
377 multi_vpaned->last_pane = next;
378 }else{
379 prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
380 g_object_ref(G_OBJECT(prev));
381 gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);
382 }
383
384 g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
385 gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
386
387 if(next == multi_vpaned->first_pane){
388 multi_vpaned->first_pane = multi_vpaned->focused_pane;
389 gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)next);
390 gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane,TRUE,TRUE,0);
391 }else{
392 nextNext = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)next);
393 gtk_container_remove(GTK_CONTAINER(nextNext),(GtkWidget*)next);
394 gtk_paned_pack1(nextNext, (GtkWidget*)multi_vpaned->focused_pane, FALSE, TRUE);
395 }
396 gtk_paned_pack1(multi_vpaned->focused_pane,(GtkWidget*)next, FALSE,TRUE);
397 if(prev)
398 gtk_paned_pack1(next,(GtkWidget*)prev, FALSE,TRUE);
399
400 if(prev)g_object_unref(G_OBJECT(prev));
401 g_object_unref(G_OBJECT(next));
402 g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
403}
404
bca085a1 405void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value)
406{
407 gtk_adjustment_set_value(multi_vpaned->hadjust, value);
a43d67ba 408 //g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed");
bca085a1 409}
410
a43d67ba 411void gtk_multi_vpaned_scroll_value_changed(GtkAdjustment *adjust, gpointer multi_vpaned_arg)
daecc161 412{
58eecf4a 413 TimeWindow time_window;
414 TimeInterval *time_span;
daecc161 415 LttTime time;
416 GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg;
a43d67ba 417 gdouble value = gtk_adjustment_get_value(adjust);
58eecf4a 418 gdouble upper, lower, ratio;
419
420 time_window = multi_vpaned->mw->current_tab->time_window;
421
7afc14aa 422 time_span = &LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info->
423 traceset_context)->time_span ;
58eecf4a 424 lower = multi_vpaned->hadjust->lower;
425 upper = multi_vpaned->hadjust->upper;
426 ratio = (value - lower) / (upper - lower);
427
7afc14aa 428 time = ltt_time_sub(time_span->end_time, time_span->start_time);
58eecf4a 429 time = ltt_time_mul(time, (float)ratio);
7afc14aa 430 time = ltt_time_add(time_span->start_time, time);
58eecf4a 431
432 time_window.start_time = time;
433
7afc14aa 434 time = ltt_time_sub(time_span->end_time, time);
58eecf4a 435 if(ltt_time_compare(time,time_window.time_width) < 0){
436 time_window.time_width = time;
437 }
a43d67ba 438 set_time_window(multi_vpaned->mw, &time_window);
439 // done in expose now call_pending_read_hooks(multi_vpaned->mw);
daecc161 440}
441
442
443static void
444gtk_multi_vpaned_size_request (GtkWidget *widget,
445 GtkRequisition *requisition)
446{
447 GtkPaned *paned = GTK_PANED (widget);
448 GtkRequisition child_requisition;
449
450 requisition->width = 0;
451 requisition->height = 0;
452
453 if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
454 {
455 gtk_widget_size_request (paned->child1, &child_requisition);
456
457 requisition->height = child_requisition.height;
458 requisition->width = child_requisition.width;
459 }
460
461 if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
462 {
463 gtk_widget_size_request (paned->child2, &child_requisition);
464
465 requisition->width = MAX (requisition->width, child_requisition.width);
466 requisition->height += child_requisition.height;
467 }
468
469 requisition->height += GTK_CONTAINER (paned)->border_width * 2;
470 requisition->width += GTK_CONTAINER (paned)->border_width * 2;
471
472 if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
473 paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
474 {
475 gint handle_size;
476
477 gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
478 requisition->height += handle_size;
479 }
480
481}
482
483static void
484gtk_multi_vpaned_size_allocate (GtkWidget *widget,
485 GtkAllocation *allocation)
486{
487 GtkPaned *paned = GTK_PANED (widget);
488 gint border_width = GTK_CONTAINER (paned)->border_width;
489
490 widget->allocation = *allocation;
491
492 if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
493 paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
494 {
495 GtkRequisition child1_requisition;
496 GtkRequisition child2_requisition;
497 GtkAllocation child1_allocation;
498 GtkAllocation child2_allocation;
499 gint handle_size;
500
501 gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
502
503 gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
504 gtk_widget_get_child_requisition (paned->child2, &child2_requisition);
505
506 gtk_paned_compute_position (paned,
507 MAX (1, widget->allocation.height
508 - handle_size
509 - 2 * border_width),
510 child1_requisition.height,
511 child2_requisition.height);
512
513 paned->handle_pos.x = widget->allocation.x + border_width;
514 paned->handle_pos.y = widget->allocation.y + paned->child1_size + border_width;
515 paned->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
516 paned->handle_pos.height = handle_size;
517
518 if (GTK_WIDGET_REALIZED (widget))
519 {
520 if (GTK_WIDGET_MAPPED (widget))
521 gdk_window_show (paned->handle);
522 gdk_window_move_resize (paned->handle,
523 paned->handle_pos.x,
524 paned->handle_pos.y,
525 paned->handle_pos.width,
526 handle_size);
527 }
528
529 child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
530 child1_allocation.height = MAX (1, paned->child1_size);
531 child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width;
532 child1_allocation.y = widget->allocation.y + border_width;
533
534 child2_allocation.y = child1_allocation.y + paned->child1_size + paned->handle_pos.height;
535 child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width);
536
537 if (GTK_WIDGET_MAPPED (widget) &&
538 paned->child1->allocation.height < child1_allocation.height)
539 {
540 gtk_widget_size_allocate (paned->child2, &child2_allocation);
541 gtk_widget_size_allocate (paned->child1, &child1_allocation);
542 }
543 else
544 {
545 gtk_widget_size_allocate (paned->child1, &child1_allocation);
546 gtk_widget_size_allocate (paned->child2, &child2_allocation);
547 }
548 }
549 else
550 {
551 GtkAllocation child_allocation;
552
553 if (GTK_WIDGET_REALIZED (widget))
554 gdk_window_hide (paned->handle);
555
556 if (paned->child1)
557 gtk_widget_set_child_visible (paned->child1, TRUE);
558 if (paned->child2)
559 gtk_widget_set_child_visible (paned->child2, TRUE);
560
561 child_allocation.x = widget->allocation.x + border_width;
562 child_allocation.y = widget->allocation.y + border_width;
563 child_allocation.width = MAX (1, allocation->width - 2 * border_width);
564 child_allocation.height = MAX (1, allocation->height - 2 * border_width);
565
566 if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
567 gtk_widget_size_allocate (paned->child1, &child_allocation);
568 else if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
569 gtk_widget_size_allocate (paned->child2, &child_allocation);
570 }
571}
572
This page took 0.069623 seconds and 4 git commands to generate.