Description
The
Gtk_File_Chooser_Button is a widget that lets the user select a file.
It implements the Gtk_File_Chooser interface. Visually, it is a file name
with a button to bring up a Gtk_File_Chooser_Dialog. The user can then use
that dialog to change the file associated with that button. This widget
does not support setting the "select-multiple" property to TRUE.
The Gtk_File_Chooser_Button supports the File_Chooser_Actions
Action_Open and Action_Select_Folder.
The Gtk_File_Chooser_Button will ellipsize the label, and thus will request
little horizontal space. To give the button more space, you should call
Gtk.Widget.Size_Request, Set_Width_Chars, or pack the button in such a way
that other interface elements give space to the widget.
Subprograms
-
function Get_Type return GType;
-
-
-
procedure Gtk_New_With_Dialog
(Button : out Gtk_File_Chooser_Button;
Dialog : access Gtk_File_Chooser_Dialog_Record'Class);
procedure Initialize_With_Dialog
(Button : access Gtk_File_Chooser_Button_Record'Class;
Dialog : access Gtk_File_Chooser_Dialog_Record'Class);
-
procedure Set_Title
(Button : access Gtk_File_Chooser_Button_Record; Title : String);
function Get_Title
(Button : access Gtk_File_Chooser_Button_Record) return String;
-
procedure Set_Width_Chars
(Button : access Gtk_File_Chooser_Button_Record;
N_Chars : Gint);
function Get_Width_Chars
(Button : access Gtk_File_Chooser_Button_Record) return Gint;
Interfaces
This class implements several interfaces. See
Glib.Types
-
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 Glib.Error;
use Glib.Error;
with GNAT.Directory_Operations;
use GNAT.Directory_Operations;
with Gtk.Box;
use Gtk.Box;
with Gtk.Button;
use Gtk.Button;
with Gtk.File_Chooser;
use Gtk.File_Chooser;
with Gtk.File_Chooser_Button;
use Gtk.File_Chooser_Button;
with Gtk.Frame;
use Gtk.Frame;
with Gtk.Stock;
use Gtk.Stock;
with Gtkada.Handlers;
use Gtkada.Handlers;
with Gtkada.Properties;
use Gtkada.Properties;
with Gtk.Widget;
use Gtk.Widget;
package body Create_File_Chooser
is
procedure Show_Properties (Widget :
access Gtk_Widget_Record'Class);
-- Opens a properties editor for Widget
-----------------
-- Help_Button --
-----------------
function Help_Button
return String
is
begin
return "The Gtk_File_Chooser_Button
is a widget that lets the user"
& "
select a file." & ASCII.LF
& "It can exist
in several modes, which influence its behavior.";
end Help_Button;
---------------------
-- Show_Properties --
---------------------
procedure Show_Properties (Widget :
access Gtk_Widget_Record'Class)
is
begin
Popup_Properties_Editor (Widget);
end Show_Properties;
----------------
-- Run_Button --
----------------
procedure Run_Button (Frame :
access Gtk.Frame.Gtk_Frame_Record'Class)
is
Box : Gtk_Box;
Hbox : Gtk_Box;
Button : Gtk_Button;
File : Gtk_File_Chooser_Button;
Error : GError;
begin
Set_Label (Frame, "File Chooser Button");
Gtk_New_Vbox (Box, Homogeneous => False);
Add (Frame, Box);
Gtk_New_Hbox (Hbox, Homogeneous => False);
Pack_Start (Box, Hbox, Fill => False);
Gtk_New (File,
Title => "Select a file (Open mode)",
Action => Action_Open);
Pack_Start (Hbox, File, Expand => True);
Gtk_New_From_Stock (Button, Stock_Properties);
Pack_Start (Hbox, Button, Expand => False);
Widget_Callback.Object_Connect
(Button, "clicked", Show_Properties'Access, File);
Error := Add_Shortcut_Folder (+File, Get_Current_Dir);
if Error /=
null then
Put_Line (Get_Message (Error));
end if;
Show_All (Frame);
end Run_Button;
end Create_File_Chooser;