Toc Gallery Index Tree Gtk.File_Chooser_Button

Screenshot

No screeshot

Hierarchy

Interfaces

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.

Types

  • type Gtk_File_Chooser_Button is access all Gtk_File_Chooser_Button_Record'Class;
  • type Gtk_File_Chooser_Button_Record is new Gtk.Box.Gtk_Hbox_Record with null record;

Subprograms

  • function Get_Type return GType;
    Return the internal value associated with a Gtk_File_Chooser_Button
  • procedure Gtk_New (Button : out Gtk_File_Chooser_Button; Title : String; Action : Gtk.File_Chooser.File_Chooser_Action);
    procedure Initialize (Button : access Gtk_File_Chooser_Button_Record'Class; Title : String; Action : Gtk.File_Chooser.File_Chooser_Action);
    Creates a new file-selecting button widget. Title is the title of the browse dialog
  • procedure Gtk_New_With_Backend (Button : out Gtk_File_Chooser_Button; Title : String; Action : Gtk.File_Chooser.File_Chooser_Action; Backend : String);
    procedure Initialize_With_Backend (Button : access Gtk_File_Chooser_Button_Record'Class; Title : String; Action : Gtk.File_Chooser.File_Chooser_Action; Backend : String);
    Creates a new file-selecting button widget using Backend. See also Gtk.File_System.
  • 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);
    Creates a button widget which uses Dialog as it's file-picking window. Note that dialog must not have Destroy_With_Parent set.
  • procedure Set_Title (Button : access Gtk_File_Chooser_Button_Record; Title : String);
    function Get_Title (Button : access Gtk_File_Chooser_Button_Record) return String;
    Modifies the Title of the browse dialog used by Button.
  • 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;
    Sets the width (in characters) that Button will use.
  • Interfaces

    This class implements several interfaces. See Glib.Types
  • function "+" (Button : access Gtk_File_Chooser_Button_Record'Class) return Gtk.File_Chooser.Gtk_File_Chooser renames Implements_File_Chooser.To_Interface;
    function "-" (File : Gtk.File_Chooser.Gtk_File_Chooser) return Gtk_File_Chooser_Button renames Implements_File_Chooser.To_Object;
    Converts to and from the Gtk_File_Chooser interface

Properties

  • Dialog_Property
    Object
    The file chooser dialog to use.
  • Title_Property
    String
    The title of the file chooser dialog.
  • Width_Chars_Property
    Int
    The desired width of the button widget, in characters.

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;

Alphabetical Index