summaryrefslogtreecommitdiff
path: root/src/gui/panels/panel.c
blob: cf4423ddce6917bf43f5eff83469c8ec0b3cf0f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896

/* OpenIDA - Outil d'analyse de fichiers binaires
 * panel.c - prototypes pour la gestion des éléments réactifs spécifiques aux panneaux
 *
 * Copyright (C) 2009-2012 Cyrille Bagard
 *
 *  This file is part of OpenIDA.
 *
 *  OpenIDA is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  OpenIDA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


#include "panel.h"


#include <ctype.h>
#include <string.h>
#include <sys/param.h>


#include "log.h"
#include "panel-int.h"
#include "symbols.h"
#include "welcome.h"
#include "../../gtkext/easygtk.h"
#include "../../gtkext/gtkdockstation.h"



/* Support de fond pour les composants. */
static GtkWidget *_support;
static panel_node *_nodes = NULL;

/* Procédure à appeler lors des changements de panneaux. */
static GCallback _handler;
static gpointer _data;

/* Liste des panneaux en place. */
static GPanelItem *_panels_list = NULL;


/* Initialise la classe des éléments réactifs de l'éditeur. */
static void g_panel_item_class_init(GPanelItemClass *);

/* Initialise une instance d'élément réactif pour l'éditeur. */
static void g_panel_item_init(GPanelItem *);



/* ---------------------- MECANISMES DE PLACEMENT DES PANNEAUX ---------------------- */


/* Crée un nouveau noeud pour un panneau particulier. */
static panel_node *create_simple_panel_node_for_item(GPanelItem *, const char *, size_t);

/* Prépare une nouvelle sous-division pour deux panneaux. */
static void switch_panel_node_into_paned(panel_node *, bool, bool);

/* Met en place un nouveau noeud dans une division. */
static void attach_panel_node_to_paned(panel_node *, panel_node *, bool);

/* Indique si un noeud correspond à la branche recherchée. */
static bool is_panel_node_matching(const panel_node *, char);

/* Place au bon endroit un panneau donné. */
static void insert_item_as_panel_node(GPanelItem *, panel_node *, const char *, size_t);

/* Met à jour l'affichage suite à un changement hiérarchique. */
static void rebuild_panels_interface(const panel_node *);



/* ---------------------- REAJUSTEMENT AUTOMATIQUE DE L'ESPACE ---------------------- */


/* Part réservée aux parties principales (en %) */
#define MAIN_PART_PERCENT 70


/* Met à jour l'affichage suite à un changement hiérarchique. */
static void auto_resize_panels(GtkWidget *, GdkRectangle *, gpointer);

/* S'enquiert de la taille idéale pour un noeud. */
static void get_panel_node_size_request(const panel_node *, GtkRequisition *);

/* Impose une taille accordée à un noeud. */
static void set_panel_node_size_request(const panel_node *, const GtkRequisition *);



/* Indique le type défini pour un élément destiné à un panneau. */
G_DEFINE_TYPE(GPanelItem, g_panel_item, G_TYPE_EDITOR_ITEM);


/******************************************************************************
*                                                                             *
*  Paramètres  : klass = classe à initialiser.                                *
*                                                                             *
*  Description : Initialise la classe des éléments réactifs de l'éditeur.     *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_panel_item_class_init(GPanelItemClass *klass)
{

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item = instance à initialiser.                               *
*                                                                             *
*  Description : Initialise une instance d'élément réactif pour l'éditeur.    *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_panel_item_init(GPanelItem *item)
{
    DL_LIST_ITEM_INIT(&item->link);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item   = composant à présenter à l'affichage.                *
*                ref    = espace de référencement global.                     *
*                name   = nom associé à l'élément.                            *
*                lname  = description longue du panneau.                      *
*                widget = composant à présenter à l'affichage.                *
*                path   = chemin vers la place idéale pour le futur panneau.  *
*                                                                             *
*  Description : Initialise dynamique les propriétés de l'instance.           *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_panel_item_init_ext(GPanelItem *item, GObject *ref, const char *name, const char *lname, GtkWidget *widget, const char *path)
{
    GEditorItem *parent;                    /* Autre version de l'élément  */

    parent = G_EDITOR_ITEM(item);

    g_object_ref(ref);
    parent->ref = ref;

    parent->name = name;
    item->lname = lname;

    g_object_ref(widget);
    parent->widget = widget;
    g_object_set_data(G_OBJECT(widget), "pitem", item);

    item->path = path;

    panels_list_add_tail(item, &_panels_list);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : ref    = espace de référencement global.                     *
*                name   = nom associé à l'élément.                            *
*                lname  = description longue du panneau.                      *
*                widget = composant à présenter à l'affichage.                *
*                path   = chemin vers la place idéale pour le futur panneau.  *
*                                                                             *
*  Description : Crée un élément de panneau réactif.                          *
*                                                                             *
*  Retour      : Adresse de la structure mise en place.                       *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GEditorItem *g_panel_item_new(GObject *ref, const char *name, const char *lname, GtkWidget *widget, const char *path)
{
    GPanelItem *result;                     /* Structure à retourner       */

    result = g_object_new(G_TYPE_PANEL_ITEM, NULL);

    g_panel_item_init_ext(result, ref, name, lname, widget, path);

    return G_EDITOR_ITEM(result);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : name = désignation courte servant de clef.                   *
*                                                                             *
*  Description : Recherche un panneau à partir de son nom court.              *
*                                                                             *
*  Retour      : Panneau trouvé ou NULL si aucun.                             *
*                                                                             *
*  Remarques   : Le parcours peut se faire aussi depuis la classe parente,    *
*                mais il est plus rapide par ici.                             *
*                                                                             *
******************************************************************************/

GPanelItem *g_panel_item_get(const char *name)
{
    GPanelItem *iter;                       /* Boucle de parcours          */

    panels_list_for_each(iter, _panels_list)
    {
        if (strcmp(G_EDITOR_ITEM(iter)->name, name) == 0)
            return iter;

    }

    return NULL;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item = composant à présenter à l'affichage.                  *
*                                                                             *
*  Description : Place un panneau dans l'ensemble affiché.                    *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_panel_item_dock(GPanelItem *item)
{
    /* Tout est à faire... */
    if (_nodes == NULL)
    {
        _nodes = create_simple_panel_node_for_item(item, item->path, 0);
        gtk_container_add(GTK_CONTAINER(_support), _nodes->station);
    }
    else insert_item_as_panel_node(item, _nodes, item->path, 0);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item = composant à retirer de l'affichage.                   *
*                                                                             *
*  Description : Supprime un panneau de l'ensemble affiché.                   *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_panel_item_undock(GPanelItem *item)
{
    GtkWidget *station;                     /* Base du remplacement        */

    station = gtk_widget_get_parent(G_EDITOR_ITEM(item)->widget);   /* NoteBook */
    station = gtk_widget_get_parent(station);   /* DockStation */

    gtk_dock_panel_remove_widget(GTK_DOCK_STATION(station), G_EDITOR_ITEM(item)->widget);

}



/* ---------------------------------------------------------------------------------- */
/*                         PLACEMENTS DES DIFFERENTS PANNEAUX                         */
/* ---------------------------------------------------------------------------------- */


/******************************************************************************
*                                                                             *
*  Paramètres  : handler = procédure à réveiller en cas de changements.       *
*                data    = donnée à faire suivre.                             *
*                                                                             *
*  Description : Prépare le terrain pour l'affichage central.                 *
*                                                                             *
*  Retour      : Composant de support sur lequel tout va se placer.           *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GtkWidget *init_panels2(GCallback handler, gpointer data)
{
    GtkWidget *result;                      /* Support à retourner         */

    result = qck_create_padded_alignment(0, 0, 0, 0);
    gtk_widget_show(result);

    g_signal_connect(result, "size-allocate", G_CALLBACK(auto_resize_panels), NULL);

    _support = result;
    _handler = handler;
    _data = data;

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : ref = espace de référencement global.                        *
*                                                                             *
*  Description : Charge les principaux panneaux de l'éditeur.                 *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void load_main_panels(GObject *ref)
{
    GPanelItem *item;                       /* Panneau de base à charger   */

    item = create_welcome_panel(ref);
    g_panel_item_dock(item);

    item = create_log_panel(ref);
    g_panel_item_dock(item);

    item = create_symbols_panel(ref);
    g_panel_item_dock(item);

}


/* ---------------------------------------------------------------------------------- */
/*                        MECANISMES DE PLACEMENT DES PANNEAUX                        */
/* ---------------------------------------------------------------------------------- */


/******************************************************************************
*                                                                             *
*  Paramètres  : item  = composant à présenter à l'affichage.                 *
*                path  = partie du chemin représentée ici.                    *
*                depth = profondeur du chemin utilisé.                        *
*                                                                             *
*  Description : Crée un nouveau noeud pour un panneau particulier.           *
*                                                                             *
*  Retour      : Structure d'accueil mise en place.                           *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static panel_node *create_simple_panel_node_for_item(GPanelItem *item, const char *path, size_t depth)
{
    panel_node *result;                     /* Structure à retourner       */
    GtkWidget *station;                     /* Premier support concentré   */
    GEditorItem *editem;                    /* Autre vision des choses     */

    result = (panel_node *)calloc(1, sizeof(panel_node));

    result->path = path[depth];
    result->depth = depth;

    result->simple = true;

    station = gtk_dock_station_new();
    g_signal_connect(station, "switch-widget", _handler, _data);
    gtk_widget_show(station);

    result->station = station;

    editem = G_EDITOR_ITEM(item);
    gtk_dock_panel_add_widget(GTK_DOCK_STATION(station),
                              editem->widget, editem->name);

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item  = composant à présenter à l'affichage.                 *
*                horiz = indique le type d'orientation désiré.                *
*                first = indication sur l'emplacement à utiliser.             *
*                                                                             *
*  Description : Prépare une nouvelle sous-division pour deux panneaux.       *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void switch_panel_node_into_paned(panel_node *current, bool horiz, bool first)
{
    panel_node *moved;                      /* Noeud descendu d'un étage   */
    GtkWidget *widget;                      /* Composant à traiter         */

    /* Descend l'élément actuel */

    moved = (panel_node *)calloc(1, sizeof(panel_node));

    memcpy(moved, current, sizeof(panel_node));
    moved->parent = current;

    widget = GET_PANEL_NODE_WIDGET(current);

    g_object_ref(G_OBJECT(widget));
    gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(widget)), widget);

    if (first)
        current->first = moved;
    else
        current->second = moved;

    /* Achève la transformation */

    current->path = '\0';

    current->simple = false;

    current->station = NULL;

    if (horiz)
        current->paned = gtk_hpaned_new();
    else
        current->paned = gtk_vpaned_new();

    gtk_widget_show(current->paned);

    /* Replace le composant d'origine */

    if (first)
        gtk_paned_add1(GTK_PANED(current->paned), widget);
    else
        gtk_paned_add2(GTK_PANED(current->paned), widget);

    g_object_unref(G_OBJECT(widget));

}


/******************************************************************************
*                                                                             *
*  Paramètres  : parent = noeud d'accueil pour le nouveau noeud.              *
*                node   = nouveau noeud à intégrer dans l'ensemble.           *
*                first  = indication sur l'emplacement à utiliser.            *
*                                                                             *
*  Description : Met en place un nouveau noeud dans une division.             *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void attach_panel_node_to_paned(panel_node *parent, panel_node *node, bool first)
{
    GtkWidget *widget;                      /* Composant à traiter         */

    /* Raccordement hiérarchique */

    if (first)
        parent->first = node;
    else
        parent->second = node;

    node->parent = parent;

    /* Raccordement graphique */

    widget = GET_PANEL_NODE_WIDGET(node);

    if (first)
        gtk_paned_add1(GTK_PANED(parent->paned), widget);
    else
        gtk_paned_add2(GTK_PANED(parent->paned), widget);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : node   = noeud d'où lancer les recherches.                   *
*                target = identifiant de la position visée.                   *
*                                                                             *
*  Description : Indique si un noeud correspond à la branche recherchée.      *
*                                                                             *
*  Retour      : Bilan de l'évaluation.                                       *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static bool is_panel_node_matching(const panel_node *node, char target)
{
    if (node->path == target)
        return true;

    if (node->simple)
        return false;

    return is_panel_node_matching(node->first, target)
        || is_panel_node_matching(node->second, target);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : item  = composant à présenter à l'affichage.                 *
*                node  = point d'insertion courant.                           *
*                path  = partie du chemin représentée ici.                    *
*                depth = profondeur du chemin utilisé.                        *
*                                                                             *
*  Description : Place au bon endroit un panneau donné.                       *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void insert_item_as_panel_node(GPanelItem *item, panel_node *node, const char *path, size_t depth)
{
    char div;                               /* Division demandée           */
    bool horiz;                             /* Traduction en composant     */
    bool first;                             /* Point d'insertion           */
    panel_node *new;                        /* Nouveau noeud créé          */
    panel_node *support;                    /* Noeud d'accueil désigné     */

    if (node->simple)
    {
        /* Si on est sur la bonne voie... */
        if (path[depth] == '\0' || path[depth] == node->path)
        {
            /* Le parcours s'arrête ici ! */
            if (path[depth] == '\0' || path[depth + 1] == '\0')
                gtk_dock_panel_add_widget(GTK_DOCK_STATION(node->station),
                                          G_EDITOR_ITEM(item)->widget,
                                          G_EDITOR_ITEM(item)->name);

            /* On ne peut aller plus loin, on doit diviser... */
            else
            {
                div = toupper(path[depth + 1]);
                first = (div == 'E' || div == 'S');
                horiz = (div == 'W' || div == 'E');

                switch_panel_node_into_paned(node, horiz, first);

                new = create_simple_panel_node_for_item(item, path, depth + 1);

                attach_panel_node_to_paned(node, new, !first);

                rebuild_panels_interface(node);

            }

        }

        /* On ne peut aller plus loin, on doit diviser... */
        else
        {
            div = toupper(path[depth]);
            first = (div == 'E' || div == 'S');
            horiz = (div == 'W' || div == 'E');

            switch_panel_node_into_paned(node, horiz, first);

            new = create_simple_panel_node_for_item(item, path, depth);

            attach_panel_node_to_paned(node, new, !first);

            rebuild_panels_interface(node);

        }

    }

    /* On regarde des autres côtés... */

    else if (is_panel_node_matching(node->first, path[depth]))
        insert_item_as_panel_node(item, node->first, path, depth + (node->first->simple ? 1 : 0));

    else if (is_panel_node_matching(node->second, path[depth]))
        insert_item_as_panel_node(item, node->second, path, depth + (node->second->simple ? 1 : 0));

    /* On doit diviser qqch... */
    else
    {
        /* Si l'élément doit passer en force */
        if (isupper(path[depth]))
        {
            div = path[depth];
            first = (div == 'E' || div == 'S');
            horiz = (div == 'W' || div == 'E');

            switch_panel_node_into_paned(node, horiz, first);

            new = create_simple_panel_node_for_item(item, path, depth);

            attach_panel_node_to_paned(node, new, !first);

            rebuild_panels_interface(node);

        }

        else
        {
            if (is_panel_node_matching(node->second, 'M'))
                support = node->second;
            else
                support = node->first;

            div = toupper(path[depth]);
            first = (div == 'E' || div == 'S');
            horiz = (div == 'W' || div == 'E');

            switch_panel_node_into_paned(support, horiz, first);

            new = create_simple_panel_node_for_item(item, path, depth);

            attach_panel_node_to_paned(support, new, !first);

            rebuild_panels_interface(support);

        }

    }

}


/******************************************************************************
*                                                                             *
*  Paramètres  : current = point de départ de la réorganisation graphique.    *
*                                                                             *
*  Description : Met à jour l'affichage suite à un changement hiérarchique.   *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void rebuild_panels_interface(const panel_node *current)
{
    GtkWidget *widget;                      /* Composant à traiter         */
    panel_node *parent;                     /* Raccourci confortable       */

    widget = GET_PANEL_NODE_WIDGET(current);

    /* On se trouve à la racine... */
    if (current->parent == NULL)
            gtk_container_add(GTK_CONTAINER(_support), widget);

    /* Sinon, une sous-division ne peut venir que d'une division... */
    else
    {
        /* BUG_ON(parent->simple) */

        parent = current->parent;

        if (current == parent->first)
            gtk_paned_add1(GTK_PANED(parent->paned), widget);
        else
            gtk_paned_add2(GTK_PANED(parent->paned), widget);

    }

}



/* ---------------------------------------------------------------------------------- */
/*                        REAJUSTEMENT AUTOMATIQUE DE L'ESPACE                        */
/* ---------------------------------------------------------------------------------- */


/******************************************************************************
*                                                                             *
*  Paramètres  : current = point de départ de la réorganisation graphique.    *
*                                                                             *
*  Description : Met à jour l'affichage suite à un changement hiérarchique.   *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void auto_resize_panels(GtkWidget *support, GdkRectangle *alloc, gpointer data)
{
    GtkRequisition available;               /* Taille disponible           */

    //g_signal_handlers_disconnect_by_func(support, G_CALLBACK(auto_resize_panels), NULL);

    available.width = alloc->width;
    available.height = alloc->height;

    set_panel_node_size_request(_nodes, &available);

    //g_signal_connect(support, "size-allocate", G_CALLBACK(auto_resize_panels), NULL);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : node = noeud à consulter.                                    *
*                req  = taille demandée par le noeud. [OUT]                   *
*                                                                             *
*  Description : S'enquiert de la taille idéale pour un noeud.                *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void get_panel_node_size_request(const panel_node *node, GtkRequisition *req)
{
    gint handle_size;                       /* Taille de la séparation     */
    GtkRequisition tmp;                     /* Stockage temporaire         */

    if (node->simple)
        gtk_widget_size_request(node->station, req);

    else
    {
        gtk_widget_style_get(node->paned, "handle-size", &handle_size, NULL);

        if (GTK_IS_HPANED(node->paned))
        {
            req->width = handle_size;
            req->height = 0;
        }
        else
        {
            req->width = 0;
            req->height = handle_size;
        }

        get_panel_node_size_request(node->first, &tmp);
        req->width += tmp.width;
        req->height += tmp.height;

        get_panel_node_size_request(node->second, &tmp);
        req->width += tmp.width;
        req->height += tmp.height;

    }

}


/******************************************************************************
*                                                                             *
*  Paramètres  : node  = noeud à consulter.                                   *
*                space = taille disponible pour le noeud.                     *
*                                                                             *
*  Description : Impose une taille accordée à un noeud.                       *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void set_panel_node_size_request(const panel_node *node, const GtkRequisition *space)
{
    GtkRequisition first_req;               /* Taille demandée par n°1     */
    GtkRequisition second_req;              /* Taille demandée par n°2     */
    gint handle_size;                       /* Taille de la séparation     */
    gint position;                          /* Position de la séparation   */
    bool can_lower;                         /* Diminution possible ?       */
    bool can_upper;                         /* Augmentation possible ?     */
    GtkAllocation allocation;               /* Taille allouée              */

    /* Pour les cas simple, GTK gère très bien... */
    if (node->simple) return;

    get_panel_node_size_request(node->first, &first_req);
    get_panel_node_size_request(node->second, &second_req);

    gtk_widget_style_get(node->paned, "handle-size", &handle_size, NULL);

    /**
     * Définitions des bornes dans chacun des cas.
     */

    /* Le premier noeud est le principal... */
    if (is_panel_node_matching(node->first, 'M'))
    {
        if (GTK_IS_HPANED(node->paned))
            position = (space->width * MAIN_PART_PERCENT) / 100;
        else
            position = (space->height * MAIN_PART_PERCENT) / 100;

        can_lower = false;
        can_upper = true;

    }

    /* Le second noeud est le principal... */
    else if (is_panel_node_matching(node->second, 'M'))
    {
        if (GTK_IS_HPANED(node->paned))
            position = space->width - (space->width * MAIN_PART_PERCENT) / 100;
        else
            position = space->height - (space->height * MAIN_PART_PERCENT) / 100;

        can_lower = true;
        can_upper = false;

    }

    /* Les éléments sont quelconques... */
    else
    {
        if (GTK_IS_HPANED(node->paned))
            position = space->width / 2;
        else
            position = space->height / 2;

        can_lower = true;
        can_upper = true;

    }

    /**
     * Calcul des valeurs applicables et mise en application.
     */

    /* Une partie principale arrive en premier */
    if (!can_lower && can_upper)
    {
        if (GTK_IS_HPANED(node->paned))
            position = MAX(position, space->width - second_req.width - handle_size);
        else
            position = MAX(position, space->height - second_req.height - handle_size);
    }

    /* Une partie principale arrive en second */
    else if (can_lower && !can_upper)
    {
        if (GTK_IS_HPANED(node->paned))
            position = MIN(position, second_req.width + handle_size);
        else
            position = MIN(position, second_req.height + handle_size);
    }

    /* Chacun pour soit ! */
    else
    {


        /* TODO */;



    }

    gtk_paned_set_position(GTK_PANED(node->paned), position);

    gtk_widget_get_allocation(GET_PANEL_NODE_WIDGET(node->first), &allocation);
    set_panel_node_size_request(node->first, ALLOC_2_REQ(&allocation));

    gtk_widget_get_allocation(GET_PANEL_NODE_WIDGET(node->second), &allocation);
    set_panel_node_size_request(node->second, ALLOC_2_REQ(&allocation));

}