From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!weretis.net!feeder2.news.weretis.net!newsfeed01.sul.t-online.de!t-online.de!213.75.85.109.MISMATCH!pfeed09.wxs.nl!newsfeed.kpn.net!pfeed14.wxs.nl!pfeed15.wxs.nl!not-for-mail From: "ldries46" Newsgroups: comp.lang.ada References: <4a04575c$0$1646$703f8584@textnews.kpn.nl> <3il2h6knjn6e$.1d81alwet09tw$.dlg@40tude.net> <4a049979$0$6677$703f8584@textnews.kpn.nl> <11bbcsfmckzik$.1kok2zp59s132$.dlg@40tude.net> Subject: Re: Documentation or examples wanted for the File_Chooser_Dialog Date: Sun, 10 May 2009 16:27:41 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Original Message-ID: <4a06e454$0$1649$703f8584@textnews.kpn.nl> NNTP-Posting-Host: 86.88.17.1 X-Trace: 1241965652 textnews.kpn.nl 1649 86.88.17.1:57707 X-Complaints-To: abuse@direct-adsl.nl Xref: g2news2.google.com comp.lang.ada:5750 Date: 2009-05-10T16:27:41+02:00 List-Id: First Thanks for the hint. I now have a working routine. I now want to present this as an example for anyone who wants to use the FilechooserDialog routine. In this routine I set a default directory and saves the directory where the file was eventually was found. procedure On_Open_C_Activate (Object : access Gtk_Image_Menu_Item_Record'Class) is Default_ext : Integer; Filename : Unbounded_String; Base_Dir : Unbounded_String := To_Unbounded_String("." & DS); Default_Dir : Unbounded_String; In_String : Unbounded_String; C_File : File_Type; soort : file_soort; ok : boolean := false; empty : boolean := false; File_Dialog : Gtk_File_Chooser_Dialog; All_Files : Gtk_File_Filter; Header : Gtk_File_Filter; C_Body : Gtk_File_Filter; CPP_Body : Gtk_File_Filter; Final_Filter : Gtk_File_Filter; Button_Open : Gtk.Widget.Gtk_Widget; Button_Cancel : Gtk.Widget.Gtk_Widget; begin Default_Dir := To_Unbounded_String(Get_Value(n_ini, "Directory", "Default_Open", To_String(Base_Dir))); Default_Ext := Get_Value(n_ini, "File", "Type", 1); Gtk_New(File_Dialog,"Open C, C++ or Header File", CtoADAWindow, Action_Open); if Base_Dir /= Default_Dir then empty := Set_Current_Folder(+File_Dialog, To_String(Default_Dir)); end if; Gtk_New(All_Files); Set_Name(All_Files, "All files"); Add_Pattern(All_Files, "*.*"); Add_Filter(+File_Dialog, All_Files); Gtk_New(Header); Set_Name(Header, "C/C++ header files"); Add_Pattern(Header, "*.h"); Add_Filter(+File_Dialog, Header); Gtk_New(C_Body); Set_Name(C_Body, "C body files"); Add_Pattern(C_Body, "*.c"); Add_Filter(+File_Dialog, C_Body); Gtk_New(CPP_Body); Set_Name(CPP_Body, "C++ body files"); Add_Pattern(CPP_Body, "*.cpp"); Add_Filter(+File_Dialog, CPP_Body); case Default_Ext is when 1 => Set_Filter(+File_Dialog, All_Files); when 2 => Set_Filter(+File_Dialog, Header); when 3 => Set_Filter(+File_Dialog, C_Body); when 4 => Set_Filter(+File_Dialog, CPP_Body); when others => Set_Filter(+File_Dialog, Header); end case; Button_Open := Add_Button(File_Dialog, "Open", gtk_response_accept); Button_Cancel := Add_Button(File_Dialog, "Cancel", gtk_response_cancel); Final_Filter := Get_Filter(+File_Dialog); if Run(File_Dialog) = gtk_response_accept then FileName := To_Unbounded_String(Get_FileName(+File_Dialog)); Default_Dir := To_Unbounded_String(Get_Current_Folder(+File_Dialog)); Set_Value(n_ini, "Directory", "Default_Open", To_String(Default_Dir)); Open(C_File, In_File, To_String(Filename)); while not End_Of_File(C_File) loop In_String := To_Unbounded_String(Get_Line(C_File)); Insert_at_Cursor (Get_Buffer (CtoADAWindow.C_View), To_String(In_String) & ASCII.CR & ASCII.LF); end loop; Close(C_File); Soort_File ( FileName ); soort := C2ADA(CtoADAWindow.C_View, CtoADAWindow.ADA_View); end if; Hide(File_Dialog); Destroy(File_Dialog); if Final_Filter = All_Files then Default_Ext := 1; elsif Final_Filter = Header then Default_Ext := 2; elsif Final_Filter = C_Body then Default_Ext := 3; elsif Final_Filter = CPP_Body then Default_Ext := 4; else Default_Ext := 1; end if; Set_Value(n_ini, "File", "Type", Default_Ext); end On_Open_C_Activate; > > The documentation is actually not bad, IMO. (But learning GTK is always an > act of masochism. (:-)) > >> I hope that there is documentation or examples >> that are more clear for leople who do want to learn something. > > You could start Gtk_Dialog: > > http://www.adacore.com/wp-content/files/auto_update/gtkada-docs/gtkada_rm/gtkada_rm/gtk-dialog.html > > Gtk_Dialog_Record is the parent of Gtk_File_Chooser_Dialog_Record.. The > testgtk application is contains an example for Gtk_Dialog_Record. You > could > try to replace Gtk_Dialog with Gtk_File_Chooser_Dialog_Record there. > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de