[gtkada] Gtk_File_Selection Help Needed (pruning the files list)

Warren W. Gay VE3WWG ve3wwg at cogeco.ca
Sun Aug 29 02:11:38 CEST 2004


I am using the Gtk.File_Selection dialog package within a
utility function. This utility function is used to select
existing files with a particular suffix.

I want to add further code, to eliminate all files in
the files "list box", except for those that end in the correct
suffix. This is necessary to make it much easier for
unskilled users to find their saved work, and to avoid
files that should not be tried.

I tried Complete() (see below), but this is only helpful
if one file with the correct suffix exists.

So far I have this much coded:

    --
    -- Help the user to select an existing file
    --
    function Get_Pathname(Pattern, Title : String) return String is
       use Glib.Convert, Gtk.Dialog, Gtk.File_Selection;

       Dialog :    Gtk_File_Selection;
       Response :  Gtk_Response_Type;
    begin

       Gtk_New(Dialog,Locale_To_UTF8(Title));
       Hide_Fileop_Buttons(Dialog);

       declare
          List : Gtk.Widget.Gtk_Widget := Get_File_List(Dialog);
       begin
          -- Complete(Dialog,Locale_To_UTF8(Pattern));
          -- NEED TO PRUNE THE LIST IN "List" WIDGET HERE..
          Response := Run(Dialog);
       end;

       if Response = Gtk_Response_OK then
          declare
             File_Name : String := Locale_From_UTF8(Get_Filename(Dialog));
          begin
             Destroy(Dialog);
             return File_Name;
          end;
       else
          Destroy(Dialog);
          return "";     -- Cancel
       end if;
    end Get_Pathname;

Unless there is a better way, I assume that I need to go through
the List widget and prune it.

Questions:

  1. What type of widget will List be?
  2. If it is the older Gtk.List.Gtk_List widget, then how do I
     determine how many entries are in that list? I didn't see
     a way to get a count in Gtk.List.

I'll likely have more questions, but that will give me a good
start, if someone has any ideas.

Thanks, Warren.
-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg



More information about the gtkada mailing list