File: create_assistant.adb

package info (click to toggle)
libgtkada 2.24.4dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,208 kB
  • ctags: 1,676
  • sloc: ada: 119,686; ansic: 4,719; sh: 3,003; makefile: 690; xml: 338; perl: 70
file content (704 lines) | stat: -rw-r--r-- 23,917 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
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
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                  Copyright (C) 2010-2013, AdaCore                 --
--                                                                   --
-- This library 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 2 of the License, 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    --
-- 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 library; if not, write to the             --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
-- Boston, MA 02111-1307, USA.                                       --
--                                                                   --
-----------------------------------------------------------------------

with Ada.Text_IO;         use Ada.Text_IO;

with Glib;                use Glib;
with Glib.Main;           use Glib.Main;

with Gdk.Pixbuf;          use Gdk.Pixbuf;

with Gtk;                 use Gtk;
with Gtk.Alignment;       use Gtk.Alignment;
with Gtk.Assistant;       use Gtk.Assistant;
with Gtk.Bin;             use Gtk.Bin;
with Gtk.Box;             use Gtk.Box;
with Gtk.Button;          use Gtk.Button;
with Gtk.Check_Button;    use Gtk.Check_Button;
with Gtk.Enums;           use Gtk.Enums;
with Gtk.Frame;           use Gtk.Frame;
with Gtk.Handlers;        use Gtk.Handlers;
with Gtk.Label;           use Gtk.Label;
with Gtk.Progress_Bar;    use Gtk.Progress_Bar;
with Gtk.Radio_Button;    use Gtk.Radio_Button;
with Gtk.Stock;           use Gtk.Stock;
with Gtk.Toggle_Button;   use Gtk.Toggle_Button;
with Gtk.Widget;          use Gtk.Widget;

with Common;              use Common;

package body Create_Assistant is

   -----------------
   -- Local Types --
   -----------------

   type Page_Data_Record is record
      Assistant : Gtk_Assistant;
      Page      : Gtk_Vbox;
   end record;
   type Page_Data is access Page_Data_Record;
   --  User data for Check_Button_Page_Data_Cb callback package.

   type Assistant_Type is
     (Simple, Generous, Nonlinear, Looping, Full_Featured);
   All_Assistants : array (Assistant_Type) of Gtk_Assistant :=
     (others => null);
   --  For every assistant type, we toggle assistants on and off on
   --  each main window button click.  In order to do this we need
   --  to keep track of all assistants that we bring up.

   -------------------------------------
   -- Callback Package Instantiations --
   -------------------------------------

   package Time_Cb is new Glib.Main.Generic_Sources (Gtk_Assistant);
   package Assistant_Cb is new Handlers.Callback (Gtk_Assistant_Record);
   package Check_Button_Widget_Cb is new Handlers.User_Callback
     (Gtk_Check_Button_Record, Gtk_Widget);
   package Check_Button_Page_Data_Cb is new Handlers.User_Callback
     (Gtk_Check_Button_Record, Page_Data);
   package Radio_Button_Char_Cb is new Handlers.User_Callback
     (Gtk_Radio_Button_Record, Character);
   package Forward_Page_Functions is new Generic_Assistant_Functions
     (Gtk_Assistant);
   use Forward_Page_Functions;

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

   function Help return String is
   begin
      return "a @bGtk_Assistant@B is a kind of @bGtk_Window@B that is used"
        & " to guide users through multi-step operations, and appears as a"
        & " dialog with multiple stages.  An application might use this type"
        & " of functionality to create wizards.";
   end Help;

   -----------------------
   -- Complete_Callback --
   -----------------------

   procedure Complete_Callback
     (Check : access Gtk_Check_Button_Record'Class;
      Data  : Page_Data)
   is
      Complete : Boolean;
   begin
      Complete := Get_Active (Check);
      Set_Page_Complete (Data.Assistant, Data.Page, Complete);
   end Complete_Callback;

   ------------------------------
   -- Add_Completion_Test_Page --
   ------------------------------

   function Add_Completion_Test_Page
     (Assistant : Gtk_Assistant;
      Text      : String;
      Visible   : Boolean;
      Complete  : Boolean)
     return Gtk_Vbox
   is
      Page   : Gtk_Vbox;
      Check  : Gtk_Check_Button;
      Label1 : Gtk_Label;
      Data   : constant Page_Data := new Page_Data_Record;
      Tmp    : Gint;
      pragma Warnings (Off, Tmp);
   begin
      Gtk_New_Vbox (Page);
      Gtk_New (Check, "Complete");
      Gtk_New (Label1, Text);

      Add (Page, Label1);
      Add (Page, Check);

      Set_Active (Check, Complete);

      Data.Assistant := Assistant;
      Data.Page := Page;
      Check_Button_Page_Data_Cb.Connect
        (Check, "toggled", Complete_Callback'Access, Data);

      if Visible then
         Show_All (Page);
      end if;

      Tmp := Append_Page (Assistant, Page);
      Set_Page_Title (Assistant, Page, Text);
      Set_Page_Complete (Assistant, Page, Complete);

      return Page;
   end Add_Completion_Test_Page;

   ---------------------
   -- Cancel_Callback --
   ---------------------

   procedure Cancel_Callback (Assistant : access Gtk_Assistant_Record'Class) is
   begin
      Put_Line ("cancel");
      Hide (Assistant);
   end Cancel_Callback;

   --------------------
   -- Close_Callback --
   --------------------

   procedure Close_Callback (Assistant : access Gtk_Assistant_Record'Class) is
   begin
      Put_Line ("close");
      Hide (Assistant);
   end Close_Callback;

   --------------------
   -- Apply_Callback --
   --------------------

   procedure Apply_Callback (Assistant : access Gtk_Assistant_Record'Class) is
      pragma Unreferenced (Assistant);
   begin
      Put_Line ("apply");
   end Apply_Callback;

   ----------------------
   -- Progress_Timeout --
   ----------------------

   function Progress_Timeout (Assistant : Gtk_Assistant) return Boolean is
      Page_Num : constant Gint := Get_Current_Page (Assistant);
      Page     : constant Gtk_Bin :=
                   Gtk_Bin (Get_Nth_Page (Assistant, Page_Num));
      Progress : constant Gtk_Progress_Bar :=
                   Gtk_Progress_Bar (Get_Child (Page));

      Value    : Gdouble;
   begin
      Value := Get_Fraction (Progress);
      Value := Value + 0.1;
      Set_Fraction (Progress, Value);

      if Value >= 1.0 then
         Set_Page_Complete (Assistant, Page, True);
         return False;
      end if;

      return True;
   end Progress_Timeout;

   ----------------------
   -- Prepare_Callback --
   ----------------------

   procedure Prepare_Callback
     (Assistant : access Gtk_Assistant_Record'Class)
   is
      Page : constant Gtk_Widget :=
        Get_Nth_Page (Assistant, Get_Current_Page (Assistant));
   begin
      if Page.all in Gtk_Label_Record'Class then
         Put_Line ("prepare: " & Get_Text (Gtk_Label (Page)));

      elsif Get_Page_Type (Assistant, Page) = Gtk_Assistant_Page_Progress then
         declare
            Progress : constant Gtk_Progress_Bar :=
                       Gtk_Progress_Bar (Get_Child (Gtk_Alignment (Page)));
            Timer    : G_Source_Id;
            pragma Warnings (Off, Timer);
         begin
            Set_Page_Complete (Assistant, Page, False);
            Set_Fraction (Progress, 0.0);
            Timer := Time_Cb.Timeout_Add
              (300, Progress_Timeout'Access, Gtk_Assistant (Assistant));
         end;

      else
         Put_Line ("prepare: " & Get_Current_Page (Assistant)'Img);
      end if;
   end Prepare_Callback;

   -----------------------------
   -- Create_Simple_Assistant --
   -----------------------------

   procedure Create_Simple_Assistant
     (Widget : access Gtk_Button_Record'Class)
   is
      pragma Warnings (Off, Widget);
      Assistant : Gtk_Assistant renames All_Assistants (Simple);
      Page      : Gtk_Label;
      Page_Num  : Gint;
      pragma Warnings (Off, Page_Num);
   begin
      if Assistant = null then
         Gtk_New (Assistant);
         Set_Default_Size (Assistant, 400, 300);

         Assistant_Cb.Connect (Assistant, "cancel",  Cancel_Callback'Access);
         Assistant_Cb.Connect (Assistant, "close",   Close_Callback'Access);
         Assistant_Cb.Connect (Assistant, "apply",   Apply_Callback'Access);
         Assistant_Cb.Connect (Assistant, "prepare", Prepare_Callback'Access);

         Gtk_New (Page, "Page 1");
         Show (Page);
         Page_Num := Append_Page (Assistant, Page);
         Set_Page_Title (Assistant, Page, "Page 1");
         Set_Page_Complete (Assistant, Page, True);

         Gtk_New (Page, "Page 2");
         Show (Page);
         Page_Num := Append_Page (Assistant, Page);
         Set_Page_Title (Assistant, Page, "Page 2");
         Set_Page_Type (Assistant, Page, Gtk_Assistant_Page_Confirm);
         Set_Page_Complete (Assistant, Page, True);
      end if;

      if not Visible_Is_Set (Assistant) then
         Show (Assistant);
      else
         Destroy (Assistant);
         Assistant := null;
      end if;
   end Create_Simple_Assistant;

   ----------------------
   -- Visible_Callback --
   ----------------------

   procedure Visible_Callback
     (Check : access Gtk_Check_Button_Record'Class;
      Page  : Gtk_Widget)
   is
      Visible : constant Boolean := Get_Active (Check);
   begin
      if Visible then
         Show (Page);
      else
         Hide (Page);
      end if;
   end Visible_Callback;

   -------------------------------
   -- Create_Generous_Assistant --
   -------------------------------

   procedure Create_Generous_Assistant
     (Widget : access Gtk_Button_Record'Class)
   is
      pragma Unreferenced (Widget);
      Assistant : Gtk_Assistant renames All_Assistants (Generous);
   begin
      if Assistant = null then
         Gtk_New (Assistant);
         Set_Default_Size (Assistant, 400, 300);

         Assistant_Cb.Connect (Assistant, "cancel",  Cancel_Callback'Access);
         Assistant_Cb.Connect (Assistant, "close",   Close_Callback'Access);
         Assistant_Cb.Connect (Assistant, "apply",   Apply_Callback'Access);
         Assistant_Cb.Connect (Assistant, "prepare", Prepare_Callback'Access);

         declare
            Tmp                    : Gint;
            Label1                 : Gtk_Label;
            Content_Page,
            More_Content_Page,
            Even_More_Content_Page : Gtk_Vbox;
            Check                  : Gtk_Check_Button;
            Alignment1             : Gtk_Alignment;
            Progress_Bar1          : Gtk_Progress_Bar;
            pragma Warnings (Off, Tmp);
            pragma Warnings (Off, Even_More_Content_Page);
         begin
            Gtk_New (Label1, "Introduction");
            Show (Label1);
            Tmp := Append_Page (Assistant, Label1);
            Set_Page_Title (Assistant, Label1, "Introduction");
            Set_Page_Type (Assistant, Label1, Gtk_Assistant_Page_Intro);
            Set_Page_Complete (Assistant, Label1, True);

            Content_Page := Add_Completion_Test_Page
              (Assistant, "Content", True, False);
            More_Content_Page := Add_Completion_Test_Page
              (Assistant, "More Content", True, True);

            Gtk_New (Check, "Next page visible");
            Set_Active (Check, True);
            Check_Button_Widget_Cb.Connect
              (Check, "toggled",
               Check_Button_Widget_Cb.To_Marshaller (Visible_Callback'Access),
               Gtk_Widget (More_Content_Page));
            Show (Check);
            Add (Content_Page, Check);

            Even_More_Content_Page := Add_Completion_Test_Page
              (Assistant, "Even More Content", True, True);

            Gtk_New (Label1, "Confirmation");
            Show (Label1);
            Tmp := Append_Page (Assistant, Label1);
            Set_Page_Title (Assistant, Label1, "Confirmation");
            Set_Page_Type (Assistant, Label1, Gtk_Assistant_Page_Confirm);
            Set_Page_Complete (Assistant, Label1, True);

            Gtk_New (Alignment1, 0.5, 0.5, 0.9, 0.0);
            Gtk_New (Progress_Bar1);
            Add (Alignment1, Progress_Bar1);
            Show_All (Alignment1);
            Tmp := Append_Page (Assistant, Alignment1);
            Set_Page_Title (Assistant, Alignment1, "Progress");
            Set_Page_Type (Assistant, Alignment1, Gtk_Assistant_Page_Progress);

            Gtk_New (Label1, "Summary");
            Show (Label1);
            Tmp := Append_Page (Assistant, Label1);
            Set_Page_Title (Assistant, Label1, "Summary");
            Set_Page_Type (Assistant, Label1, Gtk_Assistant_Page_Summary);
            Set_Page_Complete (Assistant, Label1, True);
         end;

      end if;

      if not Visible_Is_Set (Assistant) then
         Show (Assistant);
      else
         Destroy (Assistant);
         Assistant := null;
      end if;
   end Create_Generous_Assistant;

   -------------------
   -- Select_Branch --
   -------------------

   Selected_Branch : Character := 'A';

   procedure Select_Branch
     (Button : access Gtk_Radio_Button_Record'Class;
      Branch : Character)
   is
      pragma Unreferenced (Button);
   begin
      Selected_Branch := Branch;
   end Select_Branch;

   --------------------------------------
   -- Nonlinear_Assistant_Forward_Page --
   --------------------------------------

   function Nonlinear_Assistant_Forward_Page
     (Current_Page : Gint;
      Assistant    : Gtk_Assistant)
      return Gint
   is
      pragma Unreferenced (Assistant);
   begin
      case Current_Page is
         when 0 =>
            case Selected_Branch is
               when 'A' => return 1;
               when 'B' => return 2;
               when others => return -1;
            end case;
         when 1 | 2 =>
            return 3;
         when others =>
            return -1;
      end case;
   end Nonlinear_Assistant_Forward_Page;

   --------------------------------
   -- Create_Nonlinear_Assistant --
   --------------------------------

   procedure Create_Nonlinear_Assistant
     (Widget : access Gtk_Button_Record'Class)
   is
      Assistant    : Gtk_Assistant renames All_Assistants (Nonlinear);
      Page         : Gtk_Vbox;
      Label        : Gtk_Label;
      Radio_Button : Gtk_Radio_Button;
      Tmp          : Gint;
      pragma Unreferenced (Widget);
      pragma Warnings (Off, Tmp);
   begin
      if Assistant = null then
         Gtk_New (Assistant);
         Set_Default_Size (Assistant, 400, 300);

         Assistant_Cb.Connect (Assistant, "cancel",  Cancel_Callback'Access);
         Assistant_Cb.Connect (Assistant, "close",   Close_Callback'Access);
         Assistant_Cb.Connect (Assistant, "apply",   Apply_Callback'Access);
         Assistant_Cb.Connect (Assistant, "prepare", Prepare_Callback'Access);

         Set_Forward_Page_Func
           (Assistant, Nonlinear_Assistant_Forward_Page'Access, null);

         Gtk_New_Vbox (Page, False, 6);

         Gtk_New (Radio_Button, Label => "branch A");
         Pack_Start (Page, Radio_Button, False, False, 0);
         Radio_Button_Char_Cb.Connect
           (Radio_Button, "toggled", Select_Branch'Access, 'A');
         Set_Active (Radio_Button, True);

         Gtk_New (Radio_Button, Radio_Button, "branch B");
         Pack_Start (Page, Radio_Button, False, False, 0);
         Radio_Button_Char_Cb.Connect
           (Radio_Button, "toggled", Select_Branch'Access, 'B');

         Show_All (Page);
         Tmp := Append_Page (Assistant, Page);
         Set_Page_Title (Assistant, Page, "Page 1");
         Set_Page_Complete (Assistant, Page, True);

         Gtk_New (Label, "Page 2A");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Page 2A");
         Set_Page_Complete (Assistant, Label, True);

         Gtk_New (Label, "Page 2B");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Page 2B");
         Set_Page_Complete (Assistant, Label, True);

         Gtk_New (Label, "Confirmation");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Confirmation");
         Set_Page_Type (Assistant, Label, Gtk_Assistant_Page_Confirm);
         Set_Page_Complete (Assistant, Label, True);
      end if;

      if not Visible_Is_Set (Assistant) then
         Show (Assistant);
      else
         Destroy (Assistant);
         Assistant := null;
      end if;
   end Create_Nonlinear_Assistant;

   ------------------------------------
   -- Looping_Assistant_Forward_Page --
   ------------------------------------

   function Looping_Assistant_Forward_Page
     (Current_Page : Gint;
      Assistant    : Gtk_Assistant)
      return Gint
   is
   begin
      case Current_Page is
         when 0 .. 2 =>
            return Current_Page + 1;
         when 3 =>
            declare
               Loop_Toggle_Button : constant Gtk_Toggle_Button :=
                 Gtk_Toggle_Button (Get_Nth_Page (Assistant, Current_Page));
               Should_Loop : constant Boolean :=
                 Get_Active (Loop_Toggle_Button);
            begin
               if Should_Loop then
                  return 0;
               else
                  return 4;
               end if;
            end;
         when others =>
            return -1;
      end case;
   end Looping_Assistant_Forward_Page;

   ------------------------------
   -- Create_Looping_Assistant --
   ------------------------------

   procedure Create_Looping_Assistant
     (Widget : access Gtk_Button_Record'Class)
   is
      Assistant    : Gtk_Assistant renames All_Assistants (Looping);
      Label        : Gtk_Label;
      Check_Button : Gtk_Check_Button;
      Tmp          : Gint;
      pragma Unreferenced (Widget);
      pragma Warnings (Off, Tmp);
   begin
      if Assistant = null then
         Gtk_New (Assistant);
         Set_Default_Size (Assistant, 400, 300);

         Assistant_Cb.Connect (Assistant, "cancel",  Cancel_Callback'Access);
         Assistant_Cb.Connect (Assistant, "close",   Close_Callback'Access);
         Assistant_Cb.Connect (Assistant, "apply",   Apply_Callback'Access);
         Assistant_Cb.Connect (Assistant, "prepare", Prepare_Callback'Access);

         Set_Forward_Page_Func
           (Assistant, Looping_Assistant_Forward_Page'Access, Assistant);

         Gtk_New (Label, "Introduction");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Introduction");
         Set_Page_Type (Assistant, Label, Gtk_Assistant_Page_Intro);
         Set_Page_Complete (Assistant, Label, True);

         Gtk_New (Label, "Content");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Content");
         Set_Page_Complete (Assistant, Label, True);

         Gtk_New (Label, "More content");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "More content");
         Set_Page_Complete (Assistant, Label, True);

         Gtk_New (Check_Button, "Loop?");
         Show (Check_Button);
         Tmp := Append_Page (Assistant, Check_Button);
         Set_Page_Title (Assistant, Check_Button, "Loop?");
         Set_Page_Complete (Assistant, Check_Button, True);

         Gtk_New (Label, "Confirmation");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Confirmation");
         Set_Page_Type (Assistant, Label, Gtk_Assistant_Page_Confirm);
         Set_Page_Complete (Assistant, Label, True);
      end if;

      if not Visible_Is_Set (Assistant) then
         Show (Assistant);
      else
         Destroy (Assistant);
         Assistant := null;
      end if;
   end Create_Looping_Assistant;

   ------------------------------------
   -- Create_Full_Featured_Assistant --
   ------------------------------------

   procedure Create_Full_Featured_Assistant
     (Widget : access Gtk_Button_Record'Class)
   is
      Assistant : Gtk_Assistant renames All_Assistants (Full_Featured);
      Button    : Gtk_Button;
      Label     : Gtk_Label;
      Pixbuf    : Gdk_Pixbuf;
      Tmp       : Gint;
      pragma Unreferenced (Widget);
      pragma Warnings (Off, Tmp);
   begin
      if Assistant = null then
         Gtk_New (Assistant);
         Set_Default_Size (Assistant, 400, 300);

         Gtk_New_From_Stock (Button, Stock_Stop);
         Show (Button);
         Add_Action_Widget (Assistant, Button);

         Assistant_Cb.Connect (Assistant, "cancel",  Cancel_Callback'Access);
         Assistant_Cb.Connect (Assistant, "close",   Close_Callback'Access);
         Assistant_Cb.Connect (Assistant, "apply",   Apply_Callback'Access);
         Assistant_Cb.Connect (Assistant, "prepare", Prepare_Callback'Access);

         Gtk_New (Label, "Page 1");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Page 1");
         Set_Page_Complete (Assistant, Label, True);

         --  Set a side image
         Pixbuf := Render_Icon (Label, Stock_Dialog_Warning, Icon_Size_Dialog);
         Set_Page_Side_Image (Assistant, Label, Pixbuf);

         --  Set a header image
         Pixbuf := Render_Icon (Label, Stock_Dialog_Info, Icon_Size_Dialog);
         Set_Page_Header_Image (Assistant, Label, Pixbuf);

         Gtk_New (Label, "Invisible page");
         Tmp := Append_Page (Assistant, Label);

         Gtk_New (Label, "Page 3");
         Show (Label);
         Tmp := Append_Page (Assistant, Label);
         Set_Page_Title (Assistant, Label, "Page 3");
         Set_Page_Type (Assistant, Label, Gtk_Assistant_Page_Confirm);
         Set_Page_Complete (Assistant, Label, True);

         --  Set a header image
         Pixbuf := Render_Icon (Label, Stock_Dialog_Info, Icon_Size_Dialog);
         Set_Page_Header_Image (Assistant, Label, Pixbuf);
      end if;

      if not Visible_Is_Set (Assistant) then
         Show (Assistant);
      else
         Destroy (Assistant);
         Assistant := null;
      end if;
   end Create_Full_Featured_Assistant;

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

   procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is
      Box1 : Gtk_Box;

      ---------
      -- Add --
      ---------

      procedure Add
        (Description : String;
         Callback    : Button_Handler.Simple_Handler)
      is
         Button : Gtk_Button;
      begin
         Gtk_New (Button, Description);
         Button_Handler.Connect (Button, "clicked", Callback);
         Pack_Start
           (Box1, Button, Expand => False, Fill => False, Padding => 10);
      end Add;

   begin
      Set_Label (Frame, "Assistant");

      Gtk_New_Vbox (Box1);
      Add (Frame, Box1);

      Add ("Simple Assistant",        Create_Simple_Assistant'Access);
      Add ("Generous Assistant",      Create_Generous_Assistant'Access);
      Add ("Nonlinear Assistant",     Create_Nonlinear_Assistant'Access);
      Add ("Looping Assistant",       Create_Looping_Assistant'Access);
      Add ("Full Featured Assistant", Create_Full_Featured_Assistant'Access);

      Show_All (Frame);
   end Run;

end Create_Assistant;