diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2024-12-23 23:59:45 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2025-11-27 19:36:10 +0100 |
| commit | b9703b29819b619037cc282d719c187e51bacd30 (patch) | |
| tree | bd6d73e5fb6bcb6eb307844103b3dff185f2ac9a /libgtk_kylix/GTKForms.pas | |
| parent | a9634b933f71a9045e61d29c486f2d51d39fd1e2 (diff) | |
| download | tuxcmd-b9703b29819b619037cc282d719c187e51bacd30.tar.xz | |
Port to g-i generated glib2 bindings
Includes switch to FPC -Mobjfpc and related pointer style fixes.
Diffstat (limited to 'libgtk_kylix/GTKForms.pas')
| -rw-r--r-- | libgtk_kylix/GTKForms.pas | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/libgtk_kylix/GTKForms.pas b/libgtk_kylix/GTKForms.pas index 0224825..a3572b6 100644 --- a/libgtk_kylix/GTKForms.pas +++ b/libgtk_kylix/GTKForms.pas @@ -24,8 +24,7 @@ unit GTKForms; interface -uses gtk2, gdk2, glib2, Classes, SysUtils, GTKControls, GTKConsts; - +uses gtk2, gdk2, lazglib2, lazgobject2, Classes, SysUtils, GTKControls, GTKConsts; type // Some basic types PCharArray = array[0..0] of PChar; @@ -118,7 +117,7 @@ type // Some basic types procedure ShowModal; virtual; function CloseQuery: Boolean; virtual; procedure SetDefaultSize(DefaultWidth, DefaultHeight: integer); - procedure SetTransientFor(Parent: TCustomGTKForm); + procedure SetTransientFor(AParent: TCustomGTKForm); procedure Maximize; procedure Unmaximize; procedure Minimize; @@ -225,10 +224,6 @@ function GetParentForm(Control: TGTKControl): TCustomGTKForm; (********************************************************************************************************************************) implementation -uses GTKUtils; - -(********************************************************************************************************************************) -(********************************************************************************************************************************) constructor TGDKScreen.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -249,7 +244,7 @@ end; function TGDKScreen.GetForm(Index: Integer): TCustomGTKForm; begin - Result := FForms[Index]; + Result := TCustomGTKForm(FForms[Index]); end; function TGDKScreen.GetFormCount: Integer; @@ -370,7 +365,7 @@ function TCustomGTKForm.GetWindowPosition: TWindowPosition; var pos: TGtkWindowPosition; begin pos := GTK_WIN_POS_NONE; - g_object_get(FWidget, 'window-position', @pos, nil); + g_object_get(PGObject(FWidget), 'window-position', [@pos, nil]); Result := TWindowPosition(pos); end; @@ -394,10 +389,10 @@ begin gtk_window_set_default_size(PGtkWindow(FWidget), DefaultWidth, DefaultHeight); end; -procedure TCustomGTKForm.SetTransientFor(Parent: TCustomGTKForm); +procedure TCustomGTKForm.SetTransientFor(AParent: TCustomGTKForm); begin - if Assigned(Parent) and Assigned(Parent.FWidget) then - gtk_window_set_transient_for(PGtkWindow(FWidget), PGtkWindow(Parent.FWidget)); + if Assigned(AParent) and Assigned(AParent.FWidget) then + gtk_window_set_transient_for(PGtkWindow(FWidget), PGtkWindow(AParent.FWidget)); end; procedure TCustomGTKForm.ShowModal; @@ -527,9 +522,9 @@ begin FMainForm := nil; FMainFormSet := False; if not Assigned(Classes.ApplicationHandleException) then - Classes.ApplicationHandleException := HandleException; + Classes.ApplicationHandleException := @HandleException; if not Assigned(Classes.ApplicationShowException) then - Classes.ApplicationShowException := ShowException; + Classes.ApplicationShowException := @ShowException; CreateHandle; HookSynchronizeWakeup; FThreadID := 0; @@ -578,10 +573,10 @@ var E: TExceptionEvent; begin UnhookSynchronizeWakeup; - P := HandleException; + P := @HandleException; if @P = @Classes.ApplicationHandleException then Classes.ApplicationHandleException := nil; - E := ShowException; + E := @ShowException; if @E = @Classes.ApplicationShowException then Classes.ApplicationShowException := nil; inherited Destroy; @@ -723,12 +718,12 @@ begin Exit; end; Dialog := gtk_message_dialog_new(ParentWindow, GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, TMessageStyleID[Integer(Style)], - GTK_BUTTONS_NONE, '%s', StringToPgchar(Text)); + GTK_BUTTONS_NONE, '%s', PChar(Text)); for i := 1 to NumMessageButtons do if TMessageButton(i - 1) in Buttons then gtk_dialog_add_button(PGtkDialog(Dialog), MessageButtonID[i], i); - if Escape <> mbNone then g_signal_connect(PGtkObject(Dialog), 'key-press-event', G_CALLBACK(@TGTKApplication_MessageBox_key_press_event), - Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]})); + if Escape <> mbNone then g_signal_connect_data(PGObject(Dialog), 'key-press-event', TGCallback(@TGTKApplication_MessageBox_key_press_event), + Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]}), nil, G_CONNECT_DEFAULT); if Default <> mbNone then gtk_dialog_set_default_response(PGtkDialog(Dialog), Ord(Default)); Result := TMessageButton(gtk_dialog_run(PGtkDialog(Dialog)) - 1); gtk_widget_destroy(Dialog); @@ -764,9 +759,9 @@ begin inherited Create(AOwner); FWidget := gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_add_accel_group(PGtkWindow(FWidget), FAccelGroup); - g_signal_connect(PGtkObject(FWidget), 'delete-event', G_CALLBACK(@TCustomGTKForm_delete_event), Self); - g_signal_connect(PGtkObject(FWidget), 'size-allocate', G_CALLBACK(@TCustomGTKForm_size_allocate), Self); - g_signal_connect(PGtkObject(FWidget), 'show', G_CALLBACK(@TCustomGTKForm_show), Self); + g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'size-allocate', TGCallback(@TCustomGTKForm_size_allocate), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); Visible := False; SetResizeable(True); FormCreate(Self); @@ -797,9 +792,9 @@ begin if Assigned(AOwner) and (AOwner is TCustomGTKForm) then SetTransientFor(AOwner as TCustomGTKForm); FOnResponse := nil; gtk_window_add_accel_group(PGtkWindow(FWidget), FAccelGroup); - g_signal_connect(PGtkObject(FWidget), 'delete-event', G_CALLBACK(@TCustomGTKForm_delete_event), Self); - g_signal_connect(PGtkObject(FWidget), 'show', G_CALLBACK(@TCustomGTKForm_show), Self); - g_signal_connect(PGtkObject(FWidget), 'response', G_CALLBACK(@TGTKDialog_response_event), Self); + g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'response', TGCallback(@TGTKDialog_response_event), Self, nil, G_CONNECT_DEFAULT); ClientArea := TGTKVBox.CreateLinked(Self, PGtkDialog(FWidget)^.vbox); ActionArea := TGTKHBox.CreateLinked(Self, PGtkDialog(FWidget)^.action_area); FButtons := []; @@ -845,7 +840,7 @@ end; procedure TGTKDialog.AddButton(ButtonCaption: string; ButtonID: integer); begin - gtk_dialog_add_button(PGtkDialog(FWidget), StringToPgchar(ButtonCaption), ButtonID); + gtk_dialog_add_button(PGtkDialog(FWidget), PChar(ButtonCaption), ButtonID); end; procedure TGTKDialog.SetResponseSensitive(ButtonID: integer; Sensitive: boolean); |
