File: create_flow_box.adb

package info (click to toggle)
libgtkada 18-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 28,348 kB
  • sloc: ada: 61,514; xml: 7,709; python: 4,310; sh: 2,822; ansic: 1,598; makefile: 240; objc: 160; perl: 70
file content (644 lines) | stat: -rw-r--r-- 21,535 bytes parent folder | download
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
------------------------------------------------------------------------------
--               GtkAda - Ada95 binding for the Gimp Toolkit                --
--                                                                          --
--                     Copyright (C) 2014-2018, AdaCore                     --
--                                                                          --
-- This library is free software;  you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software  Foundation;  either version 3,  or (at your  option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------

with Glib;                use Glib;
with Glib.Object;         use Glib.Object;
with Gtk.Box;             use Gtk.Box;
with Gtk.Button;          use Gtk.Button;
with Gtk.Check_Button;    use Gtk.Check_Button;
with Gtk.Combo_Box;       use Gtk.Combo_Box;
with Gtk.Combo_Box_Text;  use Gtk.Combo_Box_Text;
with Gtk.Enums;           use Gtk.Enums;
with Gtk.Expander;        use Gtk.Expander;
with Gtk.Flow_Box;        use Gtk.Flow_Box;
with Gtk.Flow_Box_Child;  use Gtk.Flow_Box_Child;
with Gtk.Frame;           use Gtk.Frame;
with Gtk.GEntry;          use Gtk.GEntry;
with Gtk.Handlers;        use Gtk.Handlers;
with Gtk.Label;           use Gtk.Label;
with Gtk.Scrolled_Window; use Gtk.Scrolled_Window;
with Gtk.Spin_Button;     use Gtk.Spin_Button;
with Gtk.Toggle_Button;   use Gtk.Toggle_Button;
with Gtk.Widget;          use Gtk.Widget;
with GNAT.Strings;        use GNAT.Strings;
with Pango.Enums;         use Pango.Enums;

package body Create_Flow_Box is

   Strings : constant GNAT.Strings.String_List :=
      (new String'("These are"),
       new String'("some wrappy label"),
       new String'("texts"),
       new String'("of various"),
       new String'("lengths."),
       new String'("They should always be"),
       new String'("shown"),
       new String'("consecutively, Except it's"),
       new String'("hard to say"),
       new String'("where exactly the"),
       new String'("label"),
       new String'("will wrap"),
       new String'("and where exactly"),
       new String'("the actual"),
       new String'("container"),
       new String'("will wrap."),
       new String'("This label is really really really long !"),
       new String'("Let's add some more"),
       new String'("labels to the"),
       new String'("Mix. Just to"),
       new String'("make sure we"),
       new String'("got something to work"),
       new String'("with here."));

   Initial_Halign         : constant Gtk_Align := Align_Fill;
   Initial_Valign         : constant Gtk_Align := Align_Start;
   Initial_Minimum_Length : constant := 3;
   Initial_Maximum_Length : constant := 6;
   Initial_Cspacing       : constant := 2;
   Initial_Rspacing       : constant := 2;
   N_Items                : constant := 1000;

   type Item_Types is
      (Simple_Items,
       Focus_Items,
       Wrappy_Items);
   Items_Type : Item_Types := Simple_Items;

   Orientation : Gtk_Orientation := Orientation_Horizontal;

   package Flow_Cb is new Gtk.Handlers.User_Callback
      (Gtk_Widget_Record, Gtk_Flow_Box);

   procedure Populate_Items (Flow : not null access Gtk_Flow_Box_Record'Class);
   --   Add items to the flow box

   procedure Populate_Simple
      (Flow : not null access Gtk_Flow_Box_Record'Class);
   procedure Populate_Focus (Flow : not null access Gtk_Flow_Box_Record'Class);
   procedure Populate_Wrappy
      (Flow : not null access Gtk_Flow_Box_Record'Class);
   --  Add simple items to the flow box

   procedure Homogeneous_Toggled (Flow : access GObject_Record'Class);
   procedure Vertical_Alignment_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Horizontal_Alignment_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Orientation_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Text_Orientation_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Items_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Line_Length_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Max_Line_Length_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure H_Spacing_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure V_Spacing_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Filter_Toggled
      (Button : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Sort_Toggled
      (Button : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   procedure Selection_Mode_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box);
   --  Callbacks

   function Filter_Func
      (Child : not null access Gtk_Flow_Box_Child_Record'Class)
      return Boolean;
   --  Decides which children should be visible

   ----------
   -- Help --
   ----------

   function Help return String is
   begin
      return "";
   end Help;

   -------------------------
   -- Homogeneous_Toggled --
   -------------------------

   procedure Homogeneous_Toggled (Flow : access GObject_Record'Class) is
      F : constant Gtk_Flow_Box := Gtk_Flow_Box (Flow);
   begin
      F.Set_Homogeneous (not F.Get_Homogeneous);
   end Homogeneous_Toggled;

   ----------------------------------
   -- Horizontal_Alignment_Changed --
   ----------------------------------

   procedure Horizontal_Alignment_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Halign (Gtk_Align'Val (Gtk_Combo_Box_Text (Combo).Get_Active));
   end Horizontal_Alignment_Changed;

   --------------------------------
   -- Vertical_Alignment_Changed --
   --------------------------------

   procedure Vertical_Alignment_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Valign (Gtk_Align'Val (Gtk_Combo_Box_Text (Combo).Get_Active));
   end Vertical_Alignment_Changed;

   ------------------------------
   -- Text_Orientation_Changed --
   ------------------------------

   procedure Text_Orientation_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Orientation :=
         Gtk_Orientation'Val (Gtk_Combo_Box_Text (Combo).Get_Active);
      Populate_Items (Flow);
   end Text_Orientation_Changed;

   ----------------------------
   -- Selection_Mode_Changed --
   ----------------------------

   procedure Selection_Mode_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Selection_Mode
         (Gtk_Selection_Mode'Val (Gtk_Combo_Box_Text (Combo).Get_Active));
   end Selection_Mode_Changed;

   -------------------
   -- Items_Changed --
   -------------------

   procedure Items_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Items_Type :=
         Item_Types'Val (Gtk_Combo_Box_Text (Combo).Get_Active);
      Populate_Items (Flow);
   end Items_Changed;

   -----------------------
   -- V_Spacing_Changed --
   -----------------------

   procedure V_Spacing_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Row_Spacing
         (Guint (Gtk_Spin_Button (Spin).Get_Value_As_Int));
   end V_Spacing_Changed;

   -----------------------
   -- H_Spacing_Changed --
   -----------------------

   procedure H_Spacing_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Column_Spacing
         (Guint (Gtk_Spin_Button (Spin).Get_Value_As_Int));
   end H_Spacing_Changed;

   -----------------
   -- Filter_Func --
   -----------------

   function Filter_Func
      (Child : not null access Gtk_Flow_Box_Child_Record'Class)
      return Boolean
   is
   begin
      return Child.Get_Index mod 3 = 0;
   end Filter_Func;

   --------------------
   -- Filter_Toggled --
   --------------------

   procedure Filter_Toggled
      (Button : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      if Gtk_Check_Button (Button).Get_Active then
         Flow.Set_Filter_Func (Filter_Func'Access);
      else
         Flow.Set_Filter_Func (null);
      end if;
   end Filter_Toggled;

   ---------------
   -- Sort_Func --
   ---------------

   function Sort_Func
      (A, B : not null access Gtk_Flow_Box_Child_Record'Class)
      return Gint
   is
      Str1 : constant String :=
         Gtk_Label (Gtk_Frame (A.Get_Child).Get_Child).Get_Label;
      Str2 : constant String :=
         Gtk_Label (Gtk_Frame (B.Get_Child).Get_Child).Get_Label;
   begin
      if Str1 < Str2 then
         return -1;
      else
         return 1;
      end if;
   end Sort_Func;

   ------------------
   -- Sort_Toggled --
   ------------------

   procedure Sort_Toggled
      (Button : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      if Items_Type /= Simple_Items then
         Flow.Set_Sort_Func (null);
      elsif Gtk_Check_Button (Button).Get_Active then
         Flow.Set_Sort_Func (Sort_Func'Access);
      else
         Flow.Set_Sort_Func (null);
      end if;
   end Sort_Toggled;

   -------------------------
   -- Line_Length_Changed --
   -------------------------

   procedure Line_Length_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Min_Children_Per_Line
         (Guint (Gtk_Spin_Button (Spin).Get_Value_As_Int));
   end Line_Length_Changed;

   -----------------------------
   -- Max_Line_Length_Changed --
   -----------------------------

   procedure Max_Line_Length_Changed
      (Spin : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Max_Children_Per_Line
         (Guint (Gtk_Spin_Button (Spin).Get_Value_As_Int));
   end Max_Line_Length_Changed;

   -------------------------
   -- Orientation_Changed --
   -------------------------

   procedure Orientation_Changed
      (Combo : access Gtk_Widget_Record'Class; Flow : Gtk_Flow_Box)
   is
   begin
      Flow.Set_Orientation
         (Gtk_Orientation'Val (Gtk_Combo_Box_Text (Combo).Get_Active));
   end Orientation_Changed;

   ---------------------
   -- Populate_Simple --
   ---------------------

   procedure Populate_Simple
      (Flow : not null access Gtk_Flow_Box_Record'Class)
   is
      Label : Gtk_Label;
      Frame : Gtk_Frame;
   begin
      for J in 0 .. N_Items loop
         Gtk_New (Label, "Item" & J'Img);
         Gtk_New (Frame);
         Frame.Add (Label);

         if Orientation = Orientation_Vertical then
            Label.Set_Angle (90.0);
         end if;
         Flow.Add (Frame);
      end loop;
   end Populate_Simple;

   --------------------
   -- Populate_Focus --
   --------------------

   procedure Populate_Focus
      (Flow : not null access Gtk_Flow_Box_Record'Class)
   is
      Label : Gtk_Label;
      Frame : Gtk_Frame;
      Box   : Gtk_Box;
      Ent   : Gtk_Entry;
      Button : Gtk_Button;
   begin
      for J in 0 .. N_Items loop
         Gtk_New (Frame);
         Gtk_New (Box, Orientation_Horizontal, Spacing => 6);
         Frame.Add (Box);

         Gtk_New (Label, "Item" & J'Img);
         Box.Add (Label);

         case J mod 4 is
            when 0 =>
               Gtk_New (Ent);
               Box.Add (Ent);
            when 1 =>
               Gtk_New (Button, "Button");
               Box.Add (Button);
            when 2 =>
               Gtk_New (Label, "bla");
               Box.Add (Label);
            when others =>
               Gtk_New (Label, "bla");
               Label.Set_Sensitive (False);
               Box.Add (Label);
         end case;

         Flow.Add (Frame);
      end loop;
   end Populate_Focus;

   ---------------------
   -- Populate_Wrappy --
   ---------------------

   procedure Populate_Wrappy
      (Flow : not null access Gtk_Flow_Box_Record'Class)
   is
      Label : Gtk_Label;
      Frame : Gtk_Frame;
   begin
      for J in Strings'Range loop
         Gtk_New (Label, Strings (J).all);
         Gtk_New (Frame);
         Frame.Add (Label);

         if Orientation = Orientation_Vertical then
            Label.Set_Angle (90.0);
         end if;

         Label.Set_Line_Wrap (True);
         Label.Set_Line_Wrap_Mode (Pango_Wrap_Word);
         Label.Set_Width_Chars (10);
         Flow.Add (Frame);
      end loop;
   end Populate_Wrappy;

   --------------------
   -- Populate_Items --
   --------------------

   procedure Populate_Items
      (Flow : not null access Gtk_Flow_Box_Record'Class)
   is
      use Widget_List;
      Children : Widget_List.Glist := Flow.Get_Children;
      Iter     : Widget_List.Glist := Children;
   begin
      while Iter /= Null_List loop
         Flow.Remove (Widget_List.Get_Data (Iter));
         Iter := Next (Iter);
      end loop;
      Widget_List.Free (Children);

      case Items_Type is
         when Simple_Items =>
            Populate_Simple (Flow);
         when Focus_Items =>
            Populate_Focus (Flow);
         when Wrappy_Items =>
            Populate_Wrappy (Flow);
      end case;

      Flow.Show_All;
   end Populate_Items;

   ---------
   -- Run --
   ---------

   procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is
      Hbox, Vbox : Gtk_Box;
      Scrolled   : Gtk_Scrolled_Window;
      Flow       : Gtk_Flow_Box;
      Expander   : Gtk_Expander;
      Control    : Gtk_Box;
      Button     : Gtk_Check_Button;
      Combo      : Gtk_Combo_Box_Text;
      Spin       : Gtk_Spin_Button;
      Label      : Gtk_Label;
   begin
      Gtk_New (Hbox, Orientation_Horizontal, Spacing => 6);
      Frame.Add (Hbox);

      Gtk_New (Vbox, Orientation_Vertical, Spacing => 6);
      Hbox.Pack_Start (Vbox, Expand => False, Fill => False);

      Gtk_New (Scrolled);
      Scrolled.Set_Policy (Policy_Automatic, Policy_Automatic);
      Hbox.Pack_Start (Scrolled, Expand => True, Fill => True);

      Gtk_New (Flow);
      Flow.Set_Halign (Initial_Halign);
      Flow.Set_Valign (Initial_Valign);
      Flow.Set_Column_Spacing (Initial_Cspacing);
      Flow.Set_Row_Spacing (Initial_Rspacing);
      Flow.Set_Min_Children_Per_Line (Initial_Minimum_Length);
      Flow.Set_Max_Children_Per_Line (Initial_Maximum_Length);
      Scrolled.Add (Flow);

      Gtk_New (Expander, "Flow box controls");
      Expander.Set_Expanded (True);
      Vbox.Pack_Start (Expander);

      Gtk_New (Control, Orientation_Vertical, Spacing => 2);
      Expander.Add (Control);

      Gtk_New (Button, "Homogeneous");
      Button.Set_Active (False);
      Button.Set_Tooltip_Text
         ("Set whether the items should be displayed at the same size");
      Control.Pack_Start (Button, Expand => False, Fill => False);
      Button.On_Toggled (Homogeneous_Toggled'Access, Flow);

      Gtk_New (Combo);
      Combo.Append_Text ("Fill");
      Combo.Append_Text ("Start");
      Combo.Append_Text ("End");
      Combo.Append_Text ("Center");
      Combo.Set_Active (Gtk_Align'Pos (Initial_Halign));
      Combo.Set_Tooltip_Text ("Set the horizontal alignment policy");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Horizontal_Alignment_Changed'Access, Flow);

      Gtk_New (Combo);
      Combo.Append_Text ("Fill");
      Combo.Append_Text ("Start");
      Combo.Append_Text ("End");
      Combo.Append_Text ("Center");
      Combo.Set_Active (Gtk_Align'Pos (Initial_Valign));
      Combo.Set_Tooltip_Text ("Set the vertical alignment policy");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Vertical_Alignment_Changed'Access, Flow);

      Gtk_New (Combo);
      Combo.Append_Text ("Horizontal");
      Combo.Append_Text ("Vertical");
      Combo.Set_Active (0);
      Combo.Set_Tooltip_Text ("Set the flowbox orientation");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Orientation_Changed'Access, Flow);

      Gtk_New (Combo);
      Combo.Append_Text ("None");
      Combo.Append_Text ("Single");
      Combo.Append_Text ("Browse");
      Combo.Append_Text ("Multiple");
      Combo.Set_Active (1);
      Combo.Set_Tooltip_Text ("Set the selection mode");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Selection_Mode_Changed'Access, Flow);

      Gtk_New (Spin, 1.0, 10.0, 1.0);
      Spin.Set_Value (Gdouble (Initial_Minimum_Length));
      Spin.Set_Tooltip_Text ("Set the minimum amount of items per line");
      Control.Pack_Start (Spin, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Spin, Gtk.Spin_Button.Signal_Value_Changed,
          Line_Length_Changed'Access, Flow);

      Gtk_New (Spin, 1.0, 10.0, 1.0);
      Spin.Set_Value (Gdouble (Initial_Maximum_Length));
      Spin.Set_Tooltip_Text ("Set the natural amount of items per line");
      Control.Pack_Start (Spin, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Spin, Gtk.Spin_Button.Signal_Value_Changed,
          Max_Line_Length_Changed'Access, Flow);

      Gtk_New (Hbox, Orientation_Horizontal, Spacing => 2);
      Control.Pack_Start (Hbox, Expand => False, Fill => False);

      Gtk_New (Label, "H Spacing");
      Hbox.Pack_Start (Label, Expand => True, Fill => True);

      Gtk_New (Spin, 0.0, 30.0, 1.0);
      Spin.Set_Value (Gdouble (Initial_Cspacing));
      Spin.Set_Tooltip_Text ("Set the horizontal spacing between children");
      Hbox.Pack_Start (Spin, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Spin, Gtk.Spin_Button.Signal_Value_Changed,
          H_Spacing_Changed'Access, Flow);

      Gtk_New (Hbox, Orientation_Horizontal, Spacing => 2);
      Control.Pack_Start (Hbox, Expand => False, Fill => False);

      Gtk_New (Label, "V Spacing");
      Hbox.Pack_Start (Label, Expand => True, Fill => True);

      Gtk_New (Spin, 0.0, 30.0, 1.0);
      Spin.Set_Value (Gdouble (Initial_Cspacing));
      Spin.Set_Tooltip_Text ("Set the vertical spacing between children");
      Hbox.Pack_Start (Spin, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Spin, Gtk.Spin_Button.Signal_Value_Changed,
          V_Spacing_Changed'Access, Flow);

      Gtk_New (Button, "Filter");
      Button.Set_Active (False);
      Button.Set_Tooltip_Text
         ("Set whether some items should be filtered out");
      Control.Pack_Start (Button, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Button, Gtk.Toggle_Button.Signal_Toggled,
          Filter_Toggled'Access, Flow);

      Gtk_New (Button, "Sort");
      Button.Set_Active (False);
      Control.Pack_Start (Button, Expand => False, Fill => False);
      Button.Set_Tooltip_Text ("Set whether items should be sorted");
      Flow_Cb.Connect
         (Button, Gtk.Toggle_Button.Signal_Toggled,
          Sort_Toggled'Access, Flow);

      Gtk_New (Expander, "Test item controls");
      Expander.Set_Expanded (True);

      Gtk_New (Control, Orientation_Vertical, Spacing => 2);
      Expander.Add (Control);
      Vbox.Pack_Start (Expander, Expand => False, Fill => False);

      Gtk_New (Combo);
      Combo.Append_Text ("Simple");
      Combo.Append_Text ("Focus");
      Combo.Append_Text ("Wrappy");
      Combo.Set_Active (0);
      Combo.Set_Tooltip_Text ("Set the item set to use");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Items_Changed'Access, Flow);

      Gtk_New (Combo);
      Combo.Append_Text ("Horizontal");
      Combo.Append_Text ("Vertical");
      Combo.Set_Active (0);
      Combo.Set_Tooltip_Text
         ("Set the item's text orientation (can't be done for stock buttons)");
      Control.Pack_Start (Combo, Expand => False, Fill => False);
      Flow_Cb.Connect
         (Combo, Gtk.Combo_Box.Signal_Changed,
          Text_Orientation_Changed'Access, Flow);

      Populate_Items (Flow);

      Frame.Show_All;
   end Run;

end Create_Flow_Box;