1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
-- Copyright (C) 2006, AdaCore --
6
-- This library is free software; you can redistribute it and/or --
7
-- modify it under the terms of the GNU General Public --
8
-- License as published by the Free Software Foundation; either --
9
-- version 2 of the License, or (at your option) any later version. --
11
-- This library is distributed in the hope that it will be useful, --
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
14
-- General Public License for more details. --
16
-- You should have received a copy of the GNU General Public --
17
-- License along with this library; if not, write to the --
18
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
19
-- Boston, MA 02111-1307, USA. --
21
-----------------------------------------------------------------------
23
with Gtk.File_Filter; use Gtk.File_Filter;
24
with Interfaces.C.Strings; use Interfaces.C.Strings;
26
package body Gtk.File_Chooser is
33
(Chooser : Gtk_File_Chooser;
34
Filter : access Gtk.File_Filter.Gtk_File_Filter_Record'Class)
37
(Chooser : Gtk_File_Chooser;
38
Filter : System.Address);
39
pragma Import (C, Internal, "gtk_file_chooser_add_filter");
41
Internal (Chooser, Get_Object (Filter));
44
-------------------------
45
-- Add_Shortcut_Folder --
46
-------------------------
48
function Add_Shortcut_Folder
49
(Chooser : Gtk_File_Chooser;
50
Folder : String) return Glib.Error.GError
53
(Chooser : Gtk_File_Chooser;
55
Error : access Glib.Error.GError)
57
pragma Import (C, Internal, "gtk_file_chooser_add_shortcut_folder");
58
Err : aliased Glib.Error.GError;
60
if Internal (Chooser, Folder & ASCII.NUL, Err'Unchecked_Access) = 0 then
65
end Add_Shortcut_Folder;
67
-----------------------------
68
-- Add_Shortcut_Folder_Uri --
69
-----------------------------
71
function Add_Shortcut_Folder_Uri
72
(Chooser : Gtk_File_Chooser;
73
Uri : String) return Glib.Error.GError
76
(Chooser : Gtk_File_Chooser;
78
Error : access Glib.Error.GError)
80
pragma Import (C, Internal, "gtk_file_chooser_add_shortcut_folder_uri");
81
Err : aliased Glib.Error.GError;
83
if Internal (Chooser, Uri & ASCII.NUL, Err'Unchecked_Access) = 0 then
88
end Add_Shortcut_Folder_Uri;
90
-----------------------------------
91
-- Get_Do_Overwrite_Confirmation --
92
-----------------------------------
94
function Get_Do_Overwrite_Confirmation
95
(Chooser : Gtk_File_Chooser) return Boolean
97
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
99
(C, Internal, "gtk_file_chooser_get_do_overwrite_confirmation");
101
return Boolean'Val (Internal (Chooser));
102
end Get_Do_Overwrite_Confirmation;
108
function Get_Filename (Chooser : Gtk_File_Chooser) return String is
110
(Chooser : Gtk_File_Chooser) return Interfaces.C.Strings.chars_ptr;
111
pragma Import (C, Internal, "gtk_file_chooser_get_filename");
113
Result : chars_ptr := Internal (Chooser);
115
if Result = Null_Ptr then
119
File : constant String := Value (Result);
131
function Get_Filenames
132
(Chooser : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist
134
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
135
pragma Import (C, Internal, "gtk_file_chooser_get_filenames");
136
L : Gtk.Enums.String_SList.GSlist;
138
Gtk.Enums.String_SList.Set_Object (L, Internal (Chooser));
142
------------------------
143
-- Get_Current_Folder --
144
------------------------
146
function Get_Current_Folder (Chooser : Gtk_File_Chooser) return String is
147
function Internal (Chooser : Gtk_File_Chooser) return chars_ptr;
148
pragma Import (C, Internal, "gtk_file_chooser_get_current_folder");
150
Result : chars_ptr := Internal (Chooser);
152
if Result = Null_Ptr then
156
File : constant String := Value (Result);
162
end Get_Current_Folder;
164
----------------------------
165
-- Get_Current_Folder_Uri --
166
----------------------------
168
function Get_Current_Folder_Uri
169
(Chooser : Gtk_File_Chooser) return String
171
function Internal (Chooser : Gtk_File_Chooser) return chars_ptr;
172
pragma Import (C, Internal, "gtk_file_chooser_get_current_folder_uri");
174
Result : chars_ptr := Internal (Chooser);
176
if Result = Null_Ptr then
180
Uri : constant String := Value (Result);
186
end Get_Current_Folder_Uri;
188
----------------------
189
-- Get_Extra_Widget --
190
----------------------
192
function Get_Extra_Widget (Chooser : Gtk_File_Chooser)
193
return Gtk.Widget.Gtk_Widget
195
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
196
pragma Import (C, Internal, "gtk_file_chooser_get_extra_widget");
197
Stub : Gtk.Widget.Gtk_Widget_Record;
199
return Gtk.Widget.Gtk_Widget (Get_User_Data (Internal (Chooser), Stub));
200
end Get_Extra_Widget;
207
(Chooser : Gtk_File_Chooser)
208
return Gtk_File_Filter
210
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
211
pragma Import (C, Internal, "gtk_file_chooser_get_filter");
212
Stub : Gtk_File_Filter_Record;
214
return Gtk_File_Filter (Get_User_Data (Internal (Chooser), Stub));
221
function Get_Local_Only (Chooser : Gtk_File_Chooser) return Boolean is
222
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
223
pragma Import (C, Internal, "gtk_file_chooser_get_local_only");
225
return Boolean'Val (Internal (Chooser));
228
--------------------------
229
-- Get_Preview_Filename --
230
--------------------------
232
function Get_Preview_Filename (Chooser : Gtk_File_Chooser) return String
234
function Internal (Chooser : Gtk_File_Chooser) return chars_ptr;
235
pragma Import (C, Internal, "gtk_file_chooser_get_preview_filename");
237
Result : chars_ptr := Internal (Chooser);
239
if Result = Null_Ptr then
243
File : constant String := Value (Result);
249
end Get_Preview_Filename;
251
---------------------
252
-- Get_Preview_Uri --
253
---------------------
255
function Get_Preview_Uri (Chooser : Gtk_File_Chooser) return String is
256
function Internal (Chooser : Gtk_File_Chooser) return chars_ptr;
257
pragma Import (C, Internal, "gtk_file_chooser_get_preview_uri");
259
Result : chars_ptr := Internal (Chooser);
261
if Result = Null_Ptr then
265
Uri : constant String := Value (Result);
273
------------------------
274
-- Get_Preview_Widget --
275
------------------------
277
function Get_Preview_Widget
278
(Chooser : Gtk_File_Chooser) return Gtk.Widget.Gtk_Widget
280
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
281
pragma Import (C, Internal, "gtk_file_chooser_get_preview_widget");
282
Stub : Gtk.Widget.Gtk_Widget_Record;
284
return Gtk.Widget.Gtk_Widget (Get_User_Data (Internal (Chooser), Stub));
285
end Get_Preview_Widget;
287
-------------------------------
288
-- Get_Preview_Widget_Active --
289
-------------------------------
291
function Get_Preview_Widget_Active
292
(Chooser : Gtk_File_Chooser) return Boolean
294
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
296
(C, Internal, "gtk_file_chooser_get_preview_widget_active");
298
return Boolean'Val (Internal (Chooser));
299
end Get_Preview_Widget_Active;
301
-------------------------
302
-- Get_Select_Multiple --
303
-------------------------
305
function Get_Select_Multiple (Chooser : Gtk_File_Chooser) return Boolean is
306
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
307
pragma Import (C, Internal, "gtk_file_chooser_get_select_multiple");
309
return Boolean'Val (Internal (Chooser));
310
end Get_Select_Multiple;
312
---------------------
313
-- Get_Show_Hidden --
314
---------------------
316
function Get_Show_Hidden (Chooser : Gtk_File_Chooser) return Boolean is
317
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
318
pragma Import (C, Internal, "gtk_file_chooser_get_show_hidden");
320
return Boolean'Val (Internal (Chooser));
327
function Get_Uri (Chooser : Gtk_File_Chooser) return String
329
function Internal (Chooser : Gtk_File_Chooser) return chars_ptr;
330
pragma Import (C, Internal, "gtk_file_chooser_get_uri");
332
Result : chars_ptr := Internal (Chooser);
334
if Result = Null_Ptr then
338
Uri : constant String := Value (Result);
351
(Chooser : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist
353
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
354
pragma Import (C, Internal, "gtk_file_chooser_get_uris");
355
L : Gtk.Enums.String_SList.GSlist;
357
Gtk.Enums.String_SList.Set_Object (L, Internal (Chooser));
361
---------------------------
362
-- Get_Use_Preview_Label --
363
---------------------------
365
function Get_Use_Preview_Label
366
(Chooser : Gtk_File_Chooser) return Boolean
368
function Internal (Chooser : Gtk_File_Chooser) return Gboolean;
369
pragma Import (C, Internal, "gtk_file_chooser_get_use_preview_label");
371
return Boolean'Val (Internal (Chooser));
372
end Get_Use_Preview_Label;
378
function List_Filters
379
(Chooser : Gtk_File_Chooser)
380
return Gtk.Object.Object_SList.GSlist
382
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
383
pragma Import (C, Internal, "gtk_file_chooser_list_filters");
384
L : Gtk.Object.Object_SList.GSlist;
386
Gtk.Object.Object_SList.Set_Object (L, Internal (Chooser));
390
---------------------------
391
-- List_Shortcut_Folders --
392
---------------------------
394
function List_Shortcut_Folders
395
(Chooser : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist
397
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
398
pragma Import (C, Internal, "gtk_file_chooser_list_shortcut_folders");
399
L : Gtk.Enums.String_SList.GSlist;
401
Gtk.Enums.String_SList.Set_Object (L, Internal (Chooser));
403
end List_Shortcut_Folders;
405
-------------------------------
406
-- List_Shortcut_Folder_Uris --
407
-------------------------------
409
function List_Shortcut_Folder_Uris
410
(Chooser : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist
412
function Internal (Chooser : Gtk_File_Chooser) return System.Address;
414
(C, Internal, "gtk_file_chooser_list_shortcut_folder_uris");
415
L : Gtk.Enums.String_SList.GSlist;
417
Gtk.Enums.String_SList.Set_Object (L, Internal (Chooser));
419
end List_Shortcut_Folder_Uris;
425
procedure Remove_Filter
426
(Chooser : Gtk_File_Chooser;
427
Filter : access Gtk_File_Filter_Record'Class)
430
(Chooser : Gtk_File_Chooser;
431
Filter : System.Address);
432
pragma Import (C, Internal, "gtk_file_chooser_remove_filter");
434
Internal (Chooser, Get_Object (Filter));
437
----------------------------
438
-- Remove_Shortcut_Folder --
439
----------------------------
441
function Remove_Shortcut_Folder
442
(Chooser : Gtk_File_Chooser;
444
return Glib.Error.GError
447
(Chooser : Gtk_File_Chooser;
449
Error : access Glib.Error.GError)
451
pragma Import (C, Internal, "gtk_file_chooser_remove_shortcut_folder");
453
Err : aliased Glib.Error.GError;
455
if Internal (Chooser, Folder & ASCII.NUL, Err'Unchecked_Access) = 0 then
460
end Remove_Shortcut_Folder;
462
--------------------------------
463
-- Remove_Shortcut_Folder_Uri --
464
--------------------------------
466
function Remove_Shortcut_Folder_Uri
467
(Chooser : Gtk_File_Chooser;
469
return Glib.Error.GError
472
(Chooser : Gtk_File_Chooser;
474
Error : access Glib.Error.GError)
477
(C, Internal, "gtk_file_chooser_remove_shortcut_folder_uri");
479
Err : aliased Glib.Error.GError;
481
if Internal (Chooser, Uri & ASCII.NUL, Err'Unchecked_Access) = 0 then
486
end Remove_Shortcut_Folder_Uri;
488
---------------------
489
-- Select_Filename --
490
---------------------
492
function Select_Filename
493
(Chooser : Gtk_File_Chooser; Filename : String) return Boolean
496
(Chooser : Gtk_File_Chooser; Filename : String) return Gboolean;
497
pragma Import (C, Internal, "gtk_file_chooser_select_filename");
499
return Boolean'Val (Internal (Chooser, Filename & ASCII.NUL));
507
(Chooser : Gtk_File_Chooser; Uri : String) return Boolean
510
(Chooser : Gtk_File_Chooser; Uri : String) return Gboolean;
511
pragma Import (C, Internal, "gtk_file_chooser_select_uri");
513
return Boolean'Val (Internal (Chooser, Uri & ASCII.NUL));
516
------------------------
517
-- Set_Current_Folder --
518
------------------------
520
function Set_Current_Folder
521
(Chooser : Gtk_File_Chooser; Filename : String) return Boolean
524
(Chooser : Gtk_File_Chooser; Filename : String) return Gboolean;
525
pragma Import (C, Internal, "gtk_file_chooser_set_current_folder");
527
return Boolean'Val (Internal (Chooser, Filename & ASCII.NUL));
528
end Set_Current_Folder;
530
----------------------------
531
-- Set_Current_Folder_Uri --
532
----------------------------
534
function Set_Current_Folder_Uri
535
(Chooser : Gtk_File_Chooser; Uri : String) return Boolean
538
(Chooser : Gtk_File_Chooser; Uri : String) return Gboolean;
539
pragma Import (C, Internal, "gtk_file_chooser_set_current_folder_uri");
541
return Boolean'Val (Internal (Chooser, Uri & ASCII.NUL));
542
end Set_Current_Folder_Uri;
544
----------------------
545
-- Set_Current_Name --
546
----------------------
548
procedure Set_Current_Name (Chooser : Gtk_File_Chooser; Name : String) is
549
procedure Internal (Chooser : Gtk_File_Chooser; Name : String);
550
pragma Import (C, Internal, "gtk_file_chooser_set_current_name");
552
Internal (Chooser, Name & ASCII.NUL);
553
end Set_Current_Name;
555
-----------------------------------
556
-- Set_Do_Overwrite_Confirmation --
557
-----------------------------------
559
procedure Set_Do_Overwrite_Confirmation
560
(Chooser : Gtk_File_Chooser;
561
Do_Overwrite_Confirmation : Boolean)
564
(Chooser : Gtk_File_Chooser;
565
Do_Overwrite_Confirmation : Gboolean);
567
(C, Internal, "gtk_file_chooser_set_do_overwrite_confirmation");
569
Internal (Chooser, Boolean'Pos (Do_Overwrite_Confirmation));
570
end Set_Do_Overwrite_Confirmation;
572
----------------------
573
-- Set_Extra_Widget --
574
----------------------
576
procedure Set_Extra_Widget
577
(Chooser : Gtk_File_Chooser;
578
Extra_Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
581
(Chooser : Gtk_File_Chooser;
582
Extra_Widget : System.Address);
583
pragma Import (C, Internal, "gtk_file_chooser_set_extra_widget");
585
Internal (Chooser, Get_Object (Extra_Widget));
586
end Set_Extra_Widget;
592
function Set_Filename
593
(Chooser : Gtk_File_Chooser; Filename : String) return Boolean
596
(Chooser : Gtk_File_Chooser; Filename : String) return Gboolean;
597
pragma Import (C, Internal, "gtk_file_chooser_set_filename");
599
return Boolean'Val (Internal (Chooser, Filename & ASCII.NUL));
607
(Chooser : Gtk_File_Chooser;
608
Filter : access Gtk_File_Filter_Record'Class)
611
(Chooser : Gtk_File_Chooser;
612
Filter : System.Address);
613
pragma Import (C, Internal, "gtk_file_chooser_set_filter");
615
Internal (Chooser, Get_Object (Filter));
622
procedure Set_Local_Only
623
(Chooser : Gtk_File_Chooser; Local_Only : Boolean := True)
625
procedure Internal (Chooser : Gtk_File_Chooser; Local_Only : Gboolean);
626
pragma Import (C, Internal, "gtk_file_chooser_set_local_only");
628
Internal (Chooser, Boolean'Pos (Local_Only));
631
------------------------
632
-- Set_Preview_Widget --
633
------------------------
635
procedure Set_Preview_Widget
636
(Chooser : Gtk_File_Chooser;
637
Preview_Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
640
(Chooser : Gtk_File_Chooser;
641
Preview_Widget : System.Address);
642
pragma Import (C, Internal, "gtk_file_chooser_set_preview_widget");
644
Internal (Chooser, Get_Object (Preview_Widget));
645
end Set_Preview_Widget;
647
-------------------------------
648
-- Set_Preview_Widget_Active --
649
-------------------------------
651
procedure Set_Preview_Widget_Active
652
(Chooser : Gtk_File_Chooser; Active : Boolean)
654
procedure Internal (Chooser : Gtk_File_Chooser; Active : Gboolean);
656
(C, Internal, "gtk_file_chooser_set_preview_widget_active");
658
Internal (Chooser, Boolean'Pos (Active));
659
end Set_Preview_Widget_Active;
661
-------------------------
662
-- Set_Select_Multiple --
663
-------------------------
665
procedure Set_Select_Multiple
666
(Chooser : Gtk_File_Chooser; Select_Multiple : Boolean)
668
procedure Internal (Chooser : Gtk_File_Chooser; Multiple : Gboolean);
669
pragma Import (C, Internal, "gtk_file_chooser_set_select_multiple");
671
Internal (Chooser, Boolean'Pos (Select_Multiple));
672
end Set_Select_Multiple;
674
---------------------
675
-- Set_Show_Hidden --
676
---------------------
678
procedure Set_Show_Hidden
679
(Chooser : Gtk_File_Chooser;
680
Show_Hidden : Boolean)
682
procedure Internal (Chooser : Gtk_File_Chooser; Show_Hidden : Gboolean);
683
pragma Import (C, Internal, "gtk_file_chooser_set_show_hidden");
685
Internal (Chooser, Boolean'Pos (Show_Hidden));
693
(Chooser : Gtk_File_Chooser; Uri : String) return Boolean
695
function Internal (C : Gtk_File_Chooser; U : String) return Gboolean;
696
pragma Import (C, Internal, "gtk_file_chooser_set_uri");
698
return Boolean'Val (Internal (Chooser, Uri & ASCII.NUL));
701
---------------------------
702
-- Set_Use_Preview_Label --
703
---------------------------
705
procedure Set_Use_Preview_Label
706
(Chooser : Gtk_File_Chooser;
709
procedure Internal (Chooser : Gtk_File_Chooser; Use_Label : Gboolean);
710
pragma Import (C, Internal, "gtk_file_chooser_set_use_preview_label");
712
Internal (Chooser, Boolean'Pos (Use_Label));
713
end Set_Use_Preview_Label;
715
-----------------------
716
-- Unselect_Filename --
717
-----------------------
719
procedure Unselect_Filename
720
(Chooser : Gtk_File_Chooser; Filename : String)
722
procedure Internal (Chooser : Gtk_File_Chooser; Filename : String);
723
pragma Import (C, Internal, "gtk_file_chooser_unselect_filename");
725
Internal (Chooser, Filename & ASCII.NUL);
726
end Unselect_Filename;
732
procedure Unselect_Uri (Chooser : Gtk_File_Chooser; Uri : String) is
733
procedure Internal (Chooser : Gtk_File_Chooser; Uri : String);
734
pragma Import (C, Internal, "gtk_file_chooser_unselect_uri");
736
Internal (Chooser, Uri & ASCII.NUL);
739
end Gtk.File_Chooser;