frmabout.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. unit frmabout;
  2. {$mode objfpc}
  3. Interface
  4. uses glib,gdk,gtk;
  5. Type
  6. TAboutForm = Record
  7. Window : PGtkDialog;
  8. OkButton : PgtkButton;
  9. InfoLabel : PGtkLabel;
  10. end;
  11. PAboutForm = ^TAboutForm;
  12. Function NewAboutForm : PAboutForm;
  13. Procedure ShowAboutForm(Form : PAboutForm);
  14. Implementation
  15. Const
  16. SInfo : PChar = 'File explorer demo'#10'Florian Klaempfl'#10'Michael Van Canneyt';
  17. SAboutTitle : Pchar = 'About File explorer';
  18. procedure DestroyAbout(Widget : PGtkWidget; About : PAboutForm);cdecl;
  19. begin
  20. Dispose(About);
  21. end;
  22. Function NewAboutForm : PAboutForm;
  23. begin
  24. Result:=New(PAboutForm);
  25. With Result^ do
  26. begin
  27. Window:=PgtkDialog(gtk_dialog_new);
  28. gtk_window_set_modal(PgtkWindow(Window),True);
  29. gtk_window_set_title(PgtkWindow(Window),SAboutTitle);
  30. gtk_widget_set_usize(PGtkWidget(Window),250,150);
  31. gtk_window_set_policy(PgtkWindow(Window),0,0,0);
  32. gtk_window_set_position(PGtkWindow(Window),GTK_WIN_POS_CENTER);
  33. OkButton:=PGtkButton(gtk_button_new_with_label(' Ok '));
  34. gtk_box_pack_start(PgtkBox(Window^.action_area),PGtkWidget(Okbutton),False,False,5);
  35. gtk_window_set_focus(PGtkWindow(Window),PGtkWidget(OkButton));
  36. gtk_widget_show(PGtkWidget(OkButton));
  37. InfoLabel:=PgtkLabel(gtk_label_new(SInfo));
  38. gtk_box_pack_start(PGtkBox(Window^.vbox),PGtkWidget(InfoLabel),True,True,10);
  39. gtk_widget_show(PGtkWidget(InfoLabel));
  40. gtk_signal_connect(PGtkObject(Window),'destroy',
  41. TGTKSignalFunc(@DestroyAbout),Result);
  42. gtk_signal_connect_object(PgtkObject(OKButton),'clicked',
  43. GTK_SIGNAL_FUNC(@gtk_widget_destroy),
  44. PGTKOBJECT(Window));
  45. end;
  46. end;
  47. Procedure ShowAboutForm(Form : PAboutForm);
  48. begin
  49. gtk_window_set_modal(PgtkWindow(Form^.Window),True);
  50. gtk_widget_show(PgtkWidget(Form^.Window));
  51. end;
  52. end.