Description
The
Gtk_About_Dialog offers a simple way to display information about a
program like its logo, name, copyright, website and license. It is also
possible to give credits to the authors, documenters, translators and
artists who have worked on the program. An about dialog is typically opened
when the user selects the About option from the Help menu. All parts of the
dialog are optional.
About dialog often contain links and email addresses. Gtk_About_Dialog
supports this by offering global hooks, which are called when the user
clicks on a link or email address, see Set_Email_Hook and Set_Url_Hook.
Email addresses in the authors, documenters and artists properties are
recognized by looking for , URLs are recognized by looking for
http://url, with url extending to the next space, tab or line break.
To make constructing a Gtk_About_Dialog as convenient as possible, you can
use the function gtk_show_about_dialog which constructs and shows a dialog
and keeps it around so that it can be shown again.
Subprograms
-
procedure Gtk_New (About : out Gtk_About_Dialog);
procedure Initialize (About : access Gtk_About_Dialog_Record'Class);
-
-
procedure Set_Artists
(About : access Gtk_About_Dialog_Record;
Artists : GNAT.Strings.String_List);
function Get_Artists
(About : access Gtk_About_Dialog_Record) return GNAT.Strings.String_List;
-
procedure Set_Authors
(About : access Gtk_About_Dialog_Record;
Authors : GNAT.Strings.String_List);
function Get_Authors
(About : access Gtk_About_Dialog_Record) return GNAT.Strings.String_List;
-
procedure Set_Comments
(About : access Gtk_About_Dialog_Record; Comments : String);
function Get_Comments
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Copyright
(About : access Gtk_About_Dialog_Record; Copyright : String);
function Get_Copyright
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Documenters
(About : access Gtk_About_Dialog_Record;
Documenters : GNAT.Strings.String_List);
function Get_Documenters
(About : access Gtk_About_Dialog_Record) return GNAT.Strings.String_List;
-
procedure Set_License
(About : access Gtk_About_Dialog_Record; License : String);
function Get_License
(About : access Gtk_About_Dialog_Record) return String;
-
-
procedure Set_Logo_Icon_Name
(About : access Gtk_About_Dialog_Record;
Icon_Name : String := "");
function Get_Logo_Icon_Name
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Name
(About : access Gtk_About_Dialog_Record; Name : String);
function Get_Name
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Translator_Credits
(About : access Gtk_About_Dialog_Record;
Translator_Credits : String);
function Get_Translator_Credits
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Version
(About : access Gtk_About_Dialog_Record; Version : String);
function Get_Version
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Website
(About : access Gtk_About_Dialog_Record; Website : String);
function Get_Website
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Website_Label
(About : access Gtk_About_Dialog_Record;
Website_Label : String);
function Get_Website_Label
(About : access Gtk_About_Dialog_Record) return String;
-
procedure Set_Wrap_License
(About : access Gtk_About_Dialog_Record;
Wrap_License : Boolean);
function Get_Wrap_License
(About : access Gtk_About_Dialog_Record) return Boolean;
-
-
Testgtk source code
This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
-----------------------------------------------------------------------
-- GtkAda - Ada95 binding for the Gimp Toolkit --
-- --
-- Copyright (C) 2006, 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 GNAT.Strings;
use GNAT.Strings;
with Gtk.About_Dialog;
use Gtk.About_Dialog;
with Gtk.Dialog;
use Gtk.Dialog;
with Gtk.Frame;
use Gtk.Frame;
with Gtk.Window;
use Gtk.Window;
with Interfaces.C.Strings;
use Interfaces.C.Strings;
with System;
use System;
package body Create_About
is
procedure On_Email_Clicked
(About : System.Address;
Link : Interfaces.C.Strings.chars_ptr;
Data : System.Address);
pragma Convention (C, On_Email_Clicked);
procedure On_Url_Clicked
(About : System.Address;
Link : Interfaces.C.Strings.chars_ptr;
Data : System.Address);
pragma Convention (C, On_Url_Clicked);
----------------------
-- On_Email_Clicked --
----------------------
procedure On_Email_Clicked
(About : System.Address;
Link : Interfaces.C.Strings.chars_ptr;
Data : System.Address)
is
pragma Unreferenced (About, Data);
begin
Put_Line ("Email clicked: " & Value (Link));
end On_Email_Clicked;
--------------------
-- On_Url_Clicked --
--------------------
procedure On_Url_Clicked
(About : System.Address;
Link : Interfaces.C.Strings.chars_ptr;
Data : System.Address)
is
pragma Unreferenced (About, Data);
begin
Put_Line ("Url clicked: " & Value (Link));
end On_Url_Clicked;
----------
-- Help --
----------
function Help
return String
is
begin
return "The @bGtk_About_Dialog@B
is used to display information about"
& " your application, like its name, version, developers, website";
end Help;
---------
-- Run --
---------
procedure Run (Frame :
access Gtk.Frame.Gtk_Frame_Record'Class)
is
Dialog : Gtk_About_Dialog;
Tmp : Activate_Link_Func;
pragma Unreferenced (Tmp);
begin
Set_Label (Frame, "About dialog");
Gtk_New (Dialog);
Set_Transient_For (Dialog, Gtk_Window (Get_Toplevel (Frame)));
Set_Destroy_With_Parent (Dialog, True);
Set_Modal (Dialog, True);
Tmp := Set_Email_Hook
(On_Email_Clicked'Access,
Data => System.Null_Address,
Destroy =>
null);
Tmp := Set_Url_Hook
(On_Url_Clicked'Access,
Data => System.Null_Address,
Destroy =>
null);
-- In real applications, you will need to free the allocate strings
Set_Artists (Dialog, (1 =>
new String'("Artist1
"),
2 => new String'("Artist2 ")));
Set_Authors (Dialog, (1 => new String'("Author1 "),
2 => new String'("Author2 ")));
Set_Documenters
(Dialog, (1 => new String'("Documenter1"),
2 => new String'("Documenter2 ")));
Set_Comments (Dialog, "Comment about the application");
Set_Copyright (Dialog, "Copyright (c) 2006, AdaCore");
Set_License
(Dialog,
"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."
& ASCII.LF
& "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.");
Set_Wrap_License (Dialog, True);
Set_Name (Dialog, "Testgtk");
Set_Version (Dialog, "2.8.17");
Set_Website (Dialog, "http://www.adacore.com");
Set_Website_Label (Dialog, "AdaCore");
-- Just checking that this works correctly
declare
Artists : String_List := Get_Artists (Dialog);
begin
for A in Artists'Range loop
Put_Line ("Artist: " & Artists (A).all);
Free (Artists (A));
end loop;
end;
-- In real application, you might not want to call Run here, just
-- Present (Dialog)
-- so that it doesn't block the rest of your application
if Run (Dialog) /= Gtk_Response_Close then
-- Dialog was destroyed by user, not closed through Close button
null;
end if;
Destroy (Dialog);
end Run;
end Create_About;