~ubuntu-branches/ubuntu/intrepid/libgtkada2/intrepid

« back to all changes in this revision

Viewing changes to src/tools/gdialog.adb

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-08-11 09:46:51 UTC
  • mfrom: (6.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080811094651-9mjd6acwa98ffw5c
Tags: 2.12.0-2ubuntu1
Add lpia to supported architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-----------------------------------------------------------------------
 
2
--                 GDialog - GtkAda Components                       --
 
3
--                                                                   --
 
4
--                      Copyright (C) 2000                           --
 
5
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
 
6
--                                                                   --
 
7
-- Dialog is free software; you can redistribute it and/or modify it --
 
8
-- under the terms of the GNU General Public License as published by --
 
9
-- the Free Software Foundation; either version 2 of the License, or --
 
10
-- (at your option) any later version.                               --
 
11
--                                                                   --
 
12
-- This program is  distributed in the hope that it will be  useful, --
 
13
-- but  WITHOUT ANY WARRANTY;  without even the  implied warranty of --
 
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
 
15
-- General Public License for more details. You should have received --
 
16
-- a copy of the GNU General Public License along with this library; --
 
17
-- if not,  write to the  Free Software Foundation, Inc.,  59 Temple --
 
18
-- Place - Suite 330, Boston, MA 02111-1307, USA.                    --
 
19
-----------------------------------------------------------------------
 
20
 
 
21
--  Display a GtkAda dialog on the screen with the contents of the standard
 
22
--  input file until an end of file is encountered.
 
23
--
 
24
--  Example using a unix-like shell:
 
25
--
 
26
--  $ cat << EOF | gdialog error justify_fill
 
27
--  > Merge of some changes failed. It usually means that some modified code
 
28
--  > is obsolete in the current project file.
 
29
--  >
 
30
--  > Files with the ".rej" extension have been generated to help merging
 
31
--  > manually if needed.
 
32
--  > EOF
 
33
 
 
34
with Gtk.Main;  use Gtk.Main;
 
35
with Gtk.Enums; use Gtk.Enums;
 
36
 
 
37
with Gtkada.Dialogs; use Gtkada.Dialogs;
 
38
 
 
39
with Ada.Text_IO; use Ada.Text_IO;
 
40
with Ada.Command_Line; use Ada.Command_Line;
 
41
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
 
42
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
 
43
 
 
44
with GNAT.OS_Lib; use GNAT.OS_Lib;
 
45
 
 
46
procedure GDialog is
 
47
   Button        : Message_Dialog_Buttons;
 
48
   pragma Warnings (Off, Button);
 
49
 
 
50
   Buffer        : String (1 .. 8192);
 
51
   Last          : Natural := 0;
 
52
   Kind          : Message_Dialog_Type := Information;
 
53
   Justification : Gtk_Justification   := Justify_Center;
 
54
 
 
55
begin
 
56
   Init;
 
57
 
 
58
   if Argument_Count > 0 then
 
59
      begin
 
60
         Kind := Message_Dialog_Type'Value (Argument (1));
 
61
      exception
 
62
         when Constraint_Error =>
 
63
            Put_Line (Standard_Error, "Wrong message dialog type: " &
 
64
              Argument (1));
 
65
            Put_Line (Standard_Error, "Possible values are:");
 
66
 
 
67
            for J in Message_Dialog_Type'Range loop
 
68
               Put_Line (Standard_Error,
 
69
                 Translate (Message_Dialog_Type'Image (J), Lower_Case_Map));
 
70
            end loop;
 
71
 
 
72
            OS_Exit (1);
 
73
      end;
 
74
   end if;
 
75
 
 
76
   if Argument_Count > 1 then
 
77
      begin
 
78
         Justification := Gtk_Justification'Value (Argument (2));
 
79
      exception
 
80
         when Constraint_Error =>
 
81
            Put_Line (Standard_Error, "Wrong justification value: " &
 
82
              Argument (2));
 
83
            Put_Line (Standard_Error, "Possible values are:");
 
84
 
 
85
            for J in Gtk_Justification'Range loop
 
86
               Put_Line (Standard_Error,
 
87
                 Translate (Gtk_Justification'Image (J), Lower_Case_Map));
 
88
            end loop;
 
89
 
 
90
            OS_Exit (2);
 
91
      end;
 
92
   end if;
 
93
 
 
94
   begin
 
95
      loop
 
96
         Get_Line (Buffer (Last + 1 .. Buffer'Last), Last);
 
97
         Last := Last + 1;
 
98
         Buffer (Last) := ASCII.LF;
 
99
      end loop;
 
100
   exception
 
101
      when End_Error =>
 
102
         null;
 
103
   end;
 
104
 
 
105
   Button := Message_Dialog
 
106
     (Buffer (1 .. Last), Kind, Button_OK,
 
107
      Justification => Justification);
 
108
end GDialog;