Toc Gallery Index Tree Gtk.About_Dialog

Hierarchy

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.

Types

  • type Activate_Link_Func is access procedure (About : System.Address; Link : Interfaces.C.Strings.chars_ptr; Data : System.Address);
  • type Gtk_About_Dialog is access all Gtk_About_Dialog_Record'Class;
  • type Gtk_About_Dialog_Record is new Gtk.Dialog.Gtk_Dialog_Record with null record;

Subprograms

  • procedure Gtk_New (About : out Gtk_About_Dialog);
    procedure Initialize (About : access Gtk_About_Dialog_Record'Class);
    Creates a new Gtk_About_Dialog.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Button.
  • 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;
    Returns the strings which are displayed in the artists tab of the secondary credits dialog. The returned value must be freed by the caller, as well as the Artists parameter.
  • 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;
    Returns the string which are displayed in the authors tab of the secondary credits dialog. The returned value must be freed by the caller, as well as the Authors paramaeter.
  • procedure Set_Comments (About : access Gtk_About_Dialog_Record; Comments : String);
    function Get_Comments (About : access Gtk_About_Dialog_Record) return String;
    Returns the comments string.
  • procedure Set_Copyright (About : access Gtk_About_Dialog_Record; Copyright : String);
    function Get_Copyright (About : access Gtk_About_Dialog_Record) return String;
    Returns the copyright 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;
    Returns the string which are displayed in the documenters tab of the secondary credits dialog. The returned value must be freed by the caller, as well as the Documenters parameter.
  • procedure Set_License (About : access Gtk_About_Dialog_Record; License : String);
    function Get_License (About : access Gtk_About_Dialog_Record) return String;
    Returns the license information.
  • procedure Set_Logo (About : access Gtk_About_Dialog_Record; Logo : Gdk.Pixbuf.Gdk_Pixbuf);
    function Get_Logo (About : access Gtk_About_Dialog_Record) return Gdk.Pixbuf.Gdk_Pixbuf;
    Returns the pixbuf displayed as logo in the about dialog. The returned value is owned by the dialog. If you want to keep a reference to it, you must call Ref on it. Set_Logo sets the pixbuf to be displayed as logo in the about dialog. If it is null, the default window icon set with Gtk.Window.Set_Default_Icon will be used.
  • 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;
    Returns the icon name displayed as logo in the about dialog. If the Icon_Name is set to the empty string, the default window icon set with Gtk.Window.Set_Default_Icon will be used.
  • procedure Set_Name (About : access Gtk_About_Dialog_Record; Name : String);
    function Get_Name (About : access Gtk_About_Dialog_Record) return String;
    Returns the program name displayed in the about dialog.
  • 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;
    Sets the translator credits string which is displayed in the translators tab of the secondary credits dialog.

    The intended use for this string is to display the translator of the language which is currently used in the user interface. Using Gtkada.Intl.Gettext, a simple way to achieve that is to mark the string for translation: Set_Translator_Credits (About, -"translator-credits"); It is a good idea to use the customary msgid "translator-credits" for this purpose, since translators will already know the purpose of that msgid, and since Gtk_About_Dialog will detect if "translator-credits" is untranslated and hide the tab.

  • procedure Set_Version (About : access Gtk_About_Dialog_Record; Version : String);
    function Get_Version (About : access Gtk_About_Dialog_Record) return String;
    Returns the version string.
  • procedure Set_Website (About : access Gtk_About_Dialog_Record; Website : String);
    function Get_Website (About : access Gtk_About_Dialog_Record) return String;
    Returns the website URL. This URL must start with http:// to be properly recognized as an hyper link. You must also have called Set_Url_Hook before calling this function.
  • 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;
    Returns the label used for the website link. It defaults to the URL.
  • 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;
    Returns whether the license text in About is automatically wrapped.
  • function Set_Email_Hook (Func : Activate_Link_Func; Data : System.Address; Destroy : Glib.G_Destroy_Notify_Address) return Activate_Link_Func;
    Installs a global function to be called whenever the user activates an email link in an about dialog. Return value: the previous email hook.
  • function Set_Url_Hook (Func : Activate_Link_Func; Data : System.Address; Destroy : Glib.G_Destroy_Notify_Address) return Activate_Link_Func;
    Installs a global function to be called whenever the user activates a URL link in an about dialog. Return value: the previous URL hook.

Properties

  • Artists_Property
    Boxed
    List of people who have contributed artwork to the program
  • Authors_Property
    Boxed
    List of authors of the program
  • Comments_Property
    String
    Comments about the program
  • Copyright_Property
    String
    Copyright information for the program
  • Documenters_Property
    Boxed
    List of people documenting the program
  • Logo_Icon_Name_Property
    String
    A named icon to use as the logo for the about box.
  • Logo_Property
    Object
    A logo for the about box. If this is not set, it defaults to
  • Name_Property
    String
    The name of the program. If this is not set, it defaults to
  • Translator_Credits_Property
    String
    Credits to the translators. This string should be marked as
  • Version_Property
    String
    The version of the program
  • Website_Label_Property
    String
    The label for the link to the website of the program. If this is
  • Website_Property
    String
    The URL for the link to the website of the program
  • Wrap_License_Property
    Boolean
    Whether to wrap the license text.

Style Properties

  • Link_Color_Property
    Boxed
    Color of hyperlinks

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;

Alphabetical Index