1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2013, AdaCore                   -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  The Gtk_File_Chooser_Button is a widget that lets the user select a file. 
  31. --  It implements the Gtk_File_Chooser interface. Visually, it is a file name 
  32. --  with a button to bring up a Gtk_File_Chooser_Dialog. The user can then use 
  33. --  that dialog to change the file associated with that button. This widget 
  34. --  does not support setting the "select-multiple" property to TRUE. 
  35. -- 
  36. --  The Gtk_File_Chooser_Button supports the File_Chooser_Actions 
  37. --  Action_Open and Action_Select_Folder. 
  38. -- 
  39. --  The Gtk_File_Chooser_Button will ellipsize the label, and thus will request 
  40. --  little horizontal space. To give the button more space, you should call 
  41. --  Gtk.Widget.Size_Request, Set_Width_Chars, or pack the button in such a way 
  42. --  that other interface elements give space to the widget. 
  43. --  </description> 
  44. --  <c_version>2.16.6</c_version> 
  45. --  <group>Selectors</group> 
  46. --  <screenshot>file-button.png</screenshot> 
  47. --  <testgtk>create_file_chooser.adb</testgtk> 
  48.  
  49. with Glib.Properties; 
  50. with Glib.Types; 
  51. with Gtk.Box; 
  52. with Gtk.File_Chooser; 
  53. with Gtk.File_Chooser_Dialog; use Gtk.File_Chooser_Dialog; 
  54.  
  55. package Gtk.File_Chooser_Button is 
  56.  
  57.    type Gtk_File_Chooser_Button_Record is 
  58.      new Gtk.Box.Gtk_Hbox_Record with null record; 
  59.    type Gtk_File_Chooser_Button is 
  60.      access all Gtk_File_Chooser_Button_Record'Class; 
  61.  
  62.    function Get_Type return GType; 
  63.    --  Return the internal value associated with a Gtk_File_Chooser_Button 
  64.  
  65.    procedure Gtk_New 
  66.      (Button : out Gtk_File_Chooser_Button; 
  67.       Title  : String; 
  68.       Action : Gtk.File_Chooser.File_Chooser_Action); 
  69.    procedure Initialize 
  70.      (Button : access Gtk_File_Chooser_Button_Record'Class; 
  71.       Title  : String; 
  72.       Action : Gtk.File_Chooser.File_Chooser_Action); 
  73.    --  Creates a new file-selecting button widget. 
  74.    --  Title is the title of the browse dialog 
  75.  
  76.    procedure Gtk_New_With_Backend 
  77.      (Button  : out Gtk_File_Chooser_Button; 
  78.       Title   : String; 
  79.       Action  : Gtk.File_Chooser.File_Chooser_Action; 
  80.       Backend : String); 
  81.    pragma Obsolescent; --  Gtk_New_With_Backend 
  82.    procedure Initialize_With_Backend 
  83.      (Button  : access Gtk_File_Chooser_Button_Record'Class; 
  84.       Title   : String; 
  85.       Action  : Gtk.File_Chooser.File_Chooser_Action; 
  86.       Backend : String); 
  87.    --  Creates a new file-selecting button widget using Backend. See also 
  88.    --  Gtk.File_System. 
  89.  
  90.    procedure Gtk_New_With_Dialog 
  91.      (Button : out Gtk_File_Chooser_Button; 
  92.       Dialog : access Gtk_File_Chooser_Dialog_Record'Class); 
  93.    procedure Initialize_With_Dialog 
  94.      (Button : access Gtk_File_Chooser_Button_Record'Class; 
  95.       Dialog : access Gtk_File_Chooser_Dialog_Record'Class); 
  96.    --  Creates a button widget which uses Dialog as it's file-picking window. 
  97.    --  Note that dialog must not have Destroy_With_Parent set. 
  98.  
  99.    procedure Set_Title 
  100.      (Button : access Gtk_File_Chooser_Button_Record; Title  : String); 
  101.    function Get_Title 
  102.      (Button : access Gtk_File_Chooser_Button_Record) return String; 
  103.    --  Modifies the Title of the browse dialog used by Button. 
  104.  
  105.    procedure Set_Width_Chars 
  106.      (Button  : access Gtk_File_Chooser_Button_Record; 
  107.       N_Chars : Gint); 
  108.    function Get_Width_Chars 
  109.      (Button : access Gtk_File_Chooser_Button_Record) return Gint; 
  110.    --  Sets the width (in characters) that Button will use. 
  111.  
  112.    function Get_Focus_On_Click 
  113.      (Button : access Gtk_File_Chooser_Button_Record) 
  114.       return Boolean; 
  115.    procedure Set_Focus_On_Click 
  116.      (Button         : access Gtk_File_Chooser_Button_Record; 
  117.       Focus_On_Click : Boolean); 
  118.    --  Controls whether the button will grab focus when it is clicked with 
  119.    --  the mouse.  Making mouse clicks not grab focus is useful in places 
  120.    --  like toolbars where you don't want the keyboard focus removed from 
  121.    --  the main area of the application. 
  122.  
  123.    ---------------- 
  124.    -- Interfaces -- 
  125.    ---------------- 
  126.    --  This class implements several interfaces. See Glib.Types 
  127.    -- 
  128.    --  - "Gtk_File_Chooser" 
  129.  
  130.    package Implements_File_Chooser is new Glib.Types.Implements 
  131.      (Gtk.File_Chooser.Gtk_File_Chooser, 
  132.       Gtk_File_Chooser_Button_Record, Gtk_File_Chooser_Button); 
  133.    function "+" 
  134.      (Button : access Gtk_File_Chooser_Button_Record'Class) 
  135.       return Gtk.File_Chooser.Gtk_File_Chooser 
  136.       renames Implements_File_Chooser.To_Interface; 
  137.    function "-" 
  138.      (File : Gtk.File_Chooser.Gtk_File_Chooser) 
  139.       return Gtk_File_Chooser_Button 
  140.       renames Implements_File_Chooser.To_Object; 
  141.    --  Converts to and from the Gtk_File_Chooser interface 
  142.  
  143.    ---------------- 
  144.    -- Properties -- 
  145.    ---------------- 
  146.    --  <properties> 
  147.    --  Name:  Dialog_Property 
  148.    --  Type:  Object 
  149.    --  Descr: The file chooser dialog to use. 
  150.    -- 
  151.    --  Name:  Focus_On_Click_Property 
  152.    --  Type:  Boolean 
  153.    --  Descr: Whether the button grabs focus when it is clicked with the mouse 
  154.    -- 
  155.    --  Name:  Title_Property 
  156.    --  Type:  String 
  157.    --  Descr: The title of the file chooser dialog. 
  158.    -- 
  159.    --  Name:  Width_Chars_Property 
  160.    --  Type:  Int 
  161.    --  Descr: The desired width of the button widget, in characters. 
  162.    -- 
  163.    --  </properties> 
  164.  
  165.    Dialog_Property         : constant Glib.Properties.Property_Object; 
  166.    Focus_On_Click_Property : constant Glib.Properties.Property_Boolean; 
  167.    Title_Property          : constant Glib.Properties.Property_String; 
  168.    Width_Chars_Property    : constant Glib.Properties.Property_Int; 
  169.  
  170. private 
  171.    pragma Import (C, Get_Type, "gtk_file_chooser_button_get_type"); 
  172.  
  173.    Dialog_Property : constant Glib.Properties.Property_Object := 
  174.      Glib.Properties.Build ("dialog"); 
  175.    Focus_On_Click_Property : constant Glib.Properties.Property_Boolean := 
  176.      Glib.Properties.Build ("focus-on-click"); 
  177.    Title_Property : constant Glib.Properties.Property_String := 
  178.      Glib.Properties.Build ("title"); 
  179.    Width_Chars_Property : constant Glib.Properties.Property_Int := 
  180.      Glib.Properties.Build ("width-chars"); 
  181.  
  182. end Gtk.File_Chooser_Button;