filesel.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {
  2. Converted from C to Pascal by Javier Ros <[email protected]>
  3. }
  4. program filesel;
  5. uses
  6. glib,gdk,gtk;
  7. (* Get the selected filename and print it to the console *)
  8. procedure file_ok_sel( w:PGtkWidget;
  9. fs:PGtkFileSelection );cdecl;
  10. begin
  11. writeln ( gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
  12. end;
  13. procedure destroy( widget:PGtkWidget;
  14. data: gpointer);cdecl;
  15. begin
  16. gtk_main_quit ();
  17. end;
  18. var
  19. filew:PGtkWidget ;
  20. begin
  21. gtk_init (@argc, @argv);
  22. (* Create a new file selection widget *)
  23. filew := gtk_file_selection_new ('File selection');
  24. gtk_signal_connect (GTK_OBJECT (filew), 'destroy',
  25. GTK_SIGNAL_FUNC (@destroy), @filew);
  26. (* Connect the ok_button to file_ok_sel function *)
  27. gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)^.ok_button),
  28. 'clicked', GTK_SIGNAL_FUNC (@file_ok_sel), filew );
  29. (* Connect the cancel_button to destroy the widget *)
  30. gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION
  31. (filew)^.cancel_button),
  32. 'clicked', GTK_SIGNAL_FUNC (@gtk_widget_destroy),
  33. GTK_OBJECT (filew));
  34. (* Lets set the filename, as if this were a save dialog, and we are giving
  35. a default filename *)
  36. gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),
  37. 'filesel.pp');
  38. gtk_widget_show(filew);
  39. gtk_main ();
  40. end.