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