[GtkAda] Patch - binding for missing Gtk.File_Selection.Complete

Bobby D. Bryant bdbryant at mail.utexas.edu
Fri Apr 7 08:48:01 CEST 2000


[I understand from the GtkAda Web site that patches are supposed to go
to this list.  Is that still the plan now that this is an open
subscription list?]


The attached files will provide a temporary binding for
gtk_file_selection_complete until such time as an official binding is
included in the GtkAda distribution.

The 'Complete' procedure lets you apply a filter to the files shown in a
File_Selection widget.  For example, if you only want to see the *.tsp
files in a TSPlib subdirectory, do the following while configuring the
widget:

   Gtk.File_Selection.Set_Filename(File_Selection => File_Selector,
                                    Filename       => "~/TSPlib/");
   Gtk.Addendum.Complete(File_Selection => File_Selector,
                          Pattern        => "*.tsp");

For better or worse, I put 'Complete' in a temporary Gtk.Addendum
package rather than modifying Gtk.File_Selection directly, so that you
will not lose it if you upgrade your GtkAda to a more recent version
that still does not have support for 'Complete'.  (As a result I had to
use a Gtk_File_Selection for the first argument rather than a
Gtk_File_Selection_Record, or else it would not compile.)

Would an actual patch be preferable for this sort of thing?  In some
ways it seems that it would be more convenient, but in other ways less.

Please treat the attached files as GPL'd code, since they are derived
directly from the GtkAda sources.

Bobby Bryant
Austin, Texas

-------------- next part --------------
-- gtk-addendum.ads

with Gtk.File_Selection; use Gtk.File_Selection;

package Gtk.Addendum is

   -----------------------------------------------------------------------------
   -- File selection stuff:

   procedure Complete (File_Selection  : in Gtk_File_Selection;
                       Pattern         : in String);
   -- Provide a (possibly wildcarded) file spec for the File_Selection widget
   -- to match against.

end Gtk.Addendum;
-------------- next part --------------
-- gtk-addendum.adb

with
  Ada.Text_IO;

use
  Ada.Text_IO;

package body Gtk.Addendum is

   -----------------------------------------------------------------------------
   -- File selection stuff:

   --------------
   -- Complete --
   --------------

   procedure Complete
      (File_Selection  : in Gtk_File_Selection;
       Pattern         : in     String)
   is
      procedure Internal
        (File_Selection  : in System.Address;
         Pattern         : in String);
      pragma Import (C, Internal, "gtk_file_selection_complete");

   begin
      Internal (Get_Object (File_Selection), Pattern & Ascii.NUL);
   end Complete;


-------------------------------------------------------------------------------
begin

   pragma Debug( Put_Line( "*Elaborating package GTK-addendum..." ) );
   null; -- the pragma is not a statement!

exception
   when others =>
      raise;

end Gtk.Addendum;


More information about the gtkada mailing list