diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2025-11-27 19:28:03 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2025-11-27 21:43:01 +0100 |
| commit | 36a656e6188f227956dbdf12bf5fda8be1ea7985 (patch) | |
| tree | e32bf7d43d4ea7d6466db72ba1d6f0d29f75f059 /libgtk_kylix | |
| parent | 90db8b6652f73ddc335922d3a7c593878d83c45e (diff) | |
| download | tuxcmd-36a656e6188f227956dbdf12bf5fda8be1ea7985.tar.xz | |
Fix panel separator resizing
Diffstat (limited to 'libgtk_kylix')
| -rw-r--r-- | libgtk_kylix/GTKControls.pas | 151 | ||||
| -rw-r--r-- | libgtk_kylix/GTKExtCtrls.pas | 77 | ||||
| -rw-r--r-- | libgtk_kylix/GTKForms.pas | 27 | ||||
| -rw-r--r-- | libgtk_kylix/GTKView.pas | 24 |
4 files changed, 194 insertions, 85 deletions
diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas index 502e1b9..79551ff 100644 --- a/libgtk_kylix/GTKControls.pas +++ b/libgtk_kylix/GTKControls.pas @@ -40,19 +40,6 @@ const mrNoToAll = mrAll + 1; mrYesToAll = mrNoToAll + 1; -type -{$IFNDEF CPU64} // 32-bit platform - TComponent64 = class(TComponent); -{$ELSE} // 64-bit platform - TComponent64 = class(TComponent) - private - FTag: QWORD; - published - property Tag: QWORD read FTag write FTag default 0; - end; -{$ENDIF} - - type TGTKShadowType = (stNone, stShadowIn, stShadowOut, stEtchedIn, stEtchedOut); @@ -65,14 +52,16 @@ type TGDKMouseEvent = procedure (Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean) of object; TGDKFocusEvent = procedure (Sender: TObject; var Accept: boolean) of object; TGDKExposeEvent = procedure (Sender: TObject; const Rect: PGdkRectangle; var Accept: boolean) of object; + TGDKSizeAllocateEvent = procedure (Sender: TObject; const Rect: PGdkRectangle) of object; TGTKControlState = (csNormal, csActive, csPrelight, csSelected, csInsensitive, csInconsistent, csFocused, csBackdrop, csDirLTR, cdDirRTL, csLink, csVisited, csChecked, csDropActive); - TGTKControl = class(TComponent64) + TGTKControl = class(TComponent) private FVisible: Boolean; FParent: TGTKControl; FPopupMenu: TGTKControl; FButtonPressSignalHandler, FButtonReleaseSignalHandler, FKeyDownSignalHandler, FKeyUpSignalHandler, - FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler, FMotionNotifyHandler: gulong; + FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler, FMotionNotifyHandler, + FRealizeSignalHandler, FSizeAllocateSignalHandler: gulong; FOnKeyDown: TGDKKeyEvent; FOnKeyUp: TGDKKeyEvent; FOnEnter: TGDKFocusEvent; @@ -82,6 +71,8 @@ type FOnDblClick: TGDKMouseEvent; FOnExpose: TGDKExposeEvent; FOnMouseMove: TGDKMouseEvent; + FOnRealize: TNotifyEvent; + FOnSizeAllocate: TGDKSizeAllocateEvent; FCSSProvider: PGtkCssProvider; function GetWidth: Integer; function GetHeight: Integer; @@ -124,6 +115,8 @@ type procedure SetMarginEnd(Value: Integer); procedure SetMarginTop(Value: Integer); procedure SetMarginBottom(Value: Integer); + procedure SetOnRealize(Value: TNotifyEvent); + procedure SetOnSizeAllocate(Value: TGDKSizeAllocateEvent); protected procedure SetParent(const Value: TGTKControl); virtual; public @@ -161,6 +154,8 @@ type property OnMouseMove: TGDKMouseEvent read FOnMouseMove write SetOnMouseMove; property OnDblClick: TGDKMouseEvent read FOnDblClick write SetOnDblClick; property OnExpose: TGDKExposeEvent read FOnExpose write SetOnExpose; + property OnRealize: TNotifyEvent read FOnRealize write SetOnRealize; + property OnSizeAllocate: TGDKSizeAllocateEvent read FOnSizeAllocate write SetOnSizeAllocate; property ComponentState; property ControlState: TGTKControlState read GetControlState write SetControlState; property HAlign: TGTKAlignment read GetHAlign write SetHAlign; @@ -292,6 +287,8 @@ begin FFocusInSignalHandler := 0; FFocusOutSignalHandler := 0; FExposeSignalHandler := 0; + FRealizeSignalHandler := 0; + FSizeAllocateSignalHandler := 0; FVisible := True; FWidget := nil; FPopupMenu := nil; @@ -303,6 +300,8 @@ begin FOnMouseMove := nil; FOnMouseDown := nil; FOnMouseUp := nil; + FOnRealize := nil; + FOnSizeAllocate := nil; FCSSProvider := nil; end; @@ -427,7 +426,6 @@ begin Result := not Accept; if Accept then if (Event^.button = 3) and Assigned(TGTKControl(user_data).FPopupMenu) then begin -// if Assigned(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup) then TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup(TGTKMenuItem(TGTKControl(user_data).FPopupMenu)); if Assigned(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup) then TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup(TGTKControl(user_data)); gtk_menu_popup(PGtkMenu(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).FMenu), nil, nil, nil, nil, event^.button, event^.time); Result := False; // Allow list views to process their events - select an item beneath the cursor @@ -439,10 +437,8 @@ begin if FPopupMenu <> Value then begin FPopupMenu := Value; if not Assigned(Value) then begin - if not Assigned(FOnMouseDown) then begin - g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); - FButtonPressSignalHandler := 0; - end; + g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); + FButtonPressSignalHandler := 0; end else if FButtonPressSignalHandler = 0 then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) @@ -528,9 +524,13 @@ procedure TGTKControl.SetOnKeyDown(Value: TGDKKeyEvent); begin if @FOnKeyDown <> @Value then begin FOnKeyDown := Value; - if Assigned(Value) - then FKeyDownSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-press-event', TGCallback(@TGTKControl_key_press_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FKeyDownSignalHandler); + if Assigned(Value) then begin + if FKeyDownSignalHandler = 0 then + FKeyDownSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-press-event', TGCallback(@TGTKControl_key_press_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FKeyDownSignalHandler); + FKeyDownSignalHandler := 0; + end; end; end; @@ -538,9 +538,13 @@ procedure TGTKControl.SetOnKeyUp(Value: TGDKKeyEvent); begin if @FOnKeyUp <> @Value then begin FOnKeyUp := Value; - if Assigned(Value) - then FKeyUpSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-release-event', TGCallback(@TGTKControl_key_release_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FKeyUpSignalHandler); + if Assigned(Value) then begin + if FKeyUpSignalHandler = 0 then + FKeyUpSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-release-event', TGCallback(@TGTKControl_key_release_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FKeyUpSignalHandler); + FKeyUpSignalHandler := 0; + end; end; end; @@ -564,9 +568,13 @@ procedure TGTKControl.SetOnEnter(Value: TGDKFocusEvent); begin if @FOnEnter <> @Value then begin FOnEnter := Value; - if Assigned(Value) - then FFocusInSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-in-event', TGCallback(@TGTKControl_focus_in_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FFocusInSignalHandler); + if Assigned(Value) then begin + if FFocusInSignalHandler = 0 then + FFocusInSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-in-event', TGCallback(@TGTKControl_focus_in_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FFocusInSignalHandler); + FFocusInSignalHandler := 0; + end; end; end; @@ -574,9 +582,13 @@ procedure TGTKControl.SetOnExit(Value: TGDKFocusEvent); begin if @FOnExit <> @Value then begin FOnExit := Value; - if Assigned(Value) - then FFocusOutSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-out-event', TGCallback(@TGTKControl_focus_out_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FFocusOutSignalHandler); + if Assigned(Value) then begin + if FFocusOutSignalHandler = 0 then + FFocusOutSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-out-event', TGCallback(@TGTKControl_focus_out_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FFocusOutSignalHandler); + FFocusOutSignalHandler := 0; + end; end; end; @@ -591,7 +603,7 @@ begin end; end else if FButtonPressSignalHandler = 0 - then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT); end; end; @@ -606,7 +618,7 @@ begin end; end else if FButtonPressSignalHandler = 0 - then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT); end; end; @@ -628,8 +640,13 @@ procedure TGTKControl.SetOnMouseUp(Value: TGDKMouseEvent); begin if @FOnMouseUp <> @Value then begin FOnMouseUp := Value; - if Assigned(Value) then FButtonReleaseSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@TGTKControl_button_release_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FButtonReleaseSignalHandler); + if Assigned(Value) then begin + if FButtonReleaseSignalHandler = 0 then + FButtonReleaseSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@TGTKControl_button_release_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FButtonReleaseSignalHandler); + FButtonReleaseSignalHandler := 0; + end; end; end; @@ -658,8 +675,13 @@ procedure TGTKControl.SetOnMouseMove(Value: TGDKMouseEvent); begin if @FOnMouseMove <> @Value then begin FOnMouseMove := Value; - if Assigned(Value) then FMotionNotifyHandler := g_signal_connect_data(PGObject(FWidget), 'motion-notify-event', TGCallback(@TGTKControl_motion_notify_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FMotionNotifyHandler); + if Assigned(Value) then begin + if FMotionNotifyHandler = 0 then + FMotionNotifyHandler := g_signal_connect_data(PGObject(FWidget), 'motion-notify-event', TGCallback(@TGTKControl_motion_notify_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FMotionNotifyHandler); + FMotionNotifyHandler := 0; + end; end; end; @@ -696,9 +718,53 @@ procedure TGTKControl.SetOnExpose(Value: TGDKExposeEvent); begin if @FOnExpose <> @Value then begin FOnExpose := Value; - if Assigned(Value) - then FExposeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'expose-event', TGCallback(@TGTKControl_expose_event), Self, nil, G_CONNECT_DEFAULT) - else g_signal_handler_disconnect(PGObject(FWidget), FExposeSignalHandler); + if Assigned(Value) then begin + if FExposeSignalHandler = 0 then + FExposeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'expose-event', TGCallback(@TGTKControl_expose_event), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FExposeSignalHandler); + FExposeSignalHandler := 0; + end; + end; +end; + +procedure TGTKControl_realize(widget: PGtkWidget; user_data: gpointer); cdecl; +begin + if Assigned(TGTKControl(user_data).FOnRealize) + then TGTKControl(user_data).FOnRealize(TGTKControl(user_data)); +end; + +procedure TGTKControl.SetOnRealize(Value: TNotifyEvent); +begin + if @FOnRealize <> @Value then begin + FOnRealize := Value; + if Assigned(Value) then begin + if FRealizeSignalHandler = 0 then + FRealizeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'realize', TGCallback(@TGTKControl_realize), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FRealizeSignalHandler); + FRealizeSignalHandler := 0; + end; + end; +end; + +procedure TGTKControl_size_allocate(widget : PGtkWidget; allocation : PGtkAllocation; user_data : gpointer); cdecl; +begin + if Assigned(TGTKControl(user_data).FOnSizeAllocate) + then TGTKControl(user_data).FOnSizeAllocate(TGTKControl(user_data), allocation); +end; + +procedure TGTKControl.SetOnSizeAllocate(Value: TGDKSizeAllocateEvent); +begin + if @FOnSizeAllocate <> @Value then begin + FOnSizeAllocate := Value; + if Assigned(Value) then begin + if FSizeAllocateSignalHandler = 0 then + FSizeAllocateSignalHandler := g_signal_connect_data(PGObject(FWidget), 'size-allocate', TGCallback(@TGTKControl_size_allocate), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FSizeAllocateSignalHandler); + FSizeAllocateSignalHandler := 0; + end; end; end; @@ -783,8 +849,7 @@ begin end; procedure TGTKControl.ApplyCustomCSS(Stylesheet: string); -var provider: PGtkCssProvider; - error: PGError; +var error: PGError; begin error := nil; // No stylesheet previously attached and asked to reset, nothing to do diff --git a/libgtk_kylix/GTKExtCtrls.pas b/libgtk_kylix/GTKExtCtrls.pas index 4cb925e..0adfc1a 100644 --- a/libgtk_kylix/GTKExtCtrls.pas +++ b/libgtk_kylix/GTKExtCtrls.pas @@ -23,7 +23,7 @@ unit GTKExtCtrls; interface -uses lazglib2, lazgobject2, lazgtk3, Classes, GTKControls, GTKStdCtrls, GTKMenus; +uses lazglib2, lazgobject2, lazgdk3, lazgtk3, Classes, GTKControls, GTKStdCtrls, GTKMenus; type @@ -74,12 +74,17 @@ type (****************************************** TGTKPANED ***************************************************************************) TGTKPaned = class(TGTKContainer) private + FPositionChangedSignalHandler: gulong; + FButtonPressSignalHandler: gulong; FChild1, FChild2: TGTKControl; - FOnResize: TNotifyEvent; + FOnPositionChanged: TNotifyEvent; + FHandlePopupMenu: TGTKControl; function GetPosition: integer; procedure SetPosition(Value: integer); procedure SetChild1(Value: TGTKControl); procedure SetChild2(Value: TGTKControl); + procedure SetOnPositionChanged(Value: TNotifyEvent); + procedure SetHandlePopupMenu(Value: TGTKControl); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -87,7 +92,8 @@ type property Child1: TGTKControl read FChild1 write SetChild1; property Child2: TGTKControl read FChild2 write SetChild2; property Position: integer read GetPosition write SetPosition; - property OnResize: TNotifyEvent read FOnResize write FOnResize; + property OnPositionChanged: TNotifyEvent read FOnPositionChanged write SetOnPositionChanged; + property HandlePopupMenu: TGTKControl read FHandlePopupMenu write SetHandlePopupMenu; end; (****************************************** TGTKHPANED **************************************************************************) @@ -317,15 +323,13 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) - -procedure TGTKPaned_resize(widget : PGtkWidget; allocation : PGtkAllocation; user_data : gpointer); cdecl; -begin - if Assigned(TGTKPaned(user_data).FOnResize) then TGTKPaned(user_data).FOnResize(TGTKPaned(user_data)); -end; - constructor TGTKPaned.Create(AOwner: TComponent); begin inherited Create(AOwner); + FPositionChangedSignalHandler := 0; + FButtonPressSignalHandler := 0; + FOnPositionChanged := nil; + FHandlePopupMenu := nil; FChild1 := nil; FChild2 := nil; end; @@ -338,7 +342,6 @@ end; procedure TGTKPaned.SetChild1(Value: TGTKControl); begin gtk_paned_pack1(PGtkPaned(FWidget), Value.FWidget, True, False); - g_signal_connect_data(PGObject(Value.FWidget), 'size-allocate', TGCallback(@TGTKPaned_resize), Self, nil, G_CONNECT_DEFAULT); end; procedure TGTKPaned.SetChild2(Value: TGTKControl); @@ -346,14 +349,66 @@ begin gtk_paned_pack2(PGtkPaned(FWidget), Value.FWidget, True, False); end; +// Returns -1 if position has not been changed yet function TGTKPaned.GetPosition: integer; +var position_set: gboolean; begin - Result := gtk_paned_get_position(PGtkPaned(FWidget)); + Result := -1; + position_set := False; + g_object_get(PGObject(FWidget), 'position-set', [@position_set, nil]); + if position_set then + Result := gtk_paned_get_position(PGtkPaned(FWidget)); end; procedure TGTKPaned.SetPosition(Value: integer); begin + if FPositionChangedSignalHandler > 0 then + g_signal_handler_block(FWidget, FPositionChangedSignalHandler); gtk_paned_set_position(PGtkPaned(FWidget), Value); + if FPositionChangedSignalHandler > 0 then + g_signal_handler_unblock(FWidget, FPositionChangedSignalHandler); +end; + +procedure TGTKPaned_resize(widget : PGtkWidget; pspec: PGParamSpec; user_data : gpointer); cdecl; +begin + if Assigned(TGTKPaned(user_data).FOnPositionChanged) then TGTKPaned(user_data).FOnPositionChanged(TGTKPaned(user_data)); +end; + +procedure TGTKPaned.SetOnPositionChanged(Value: TNotifyEvent); +begin + if @FOnPositionChanged <> @Value then begin + FOnPositionChanged := Value; + if Assigned(Value) then begin + if FPositionChangedSignalHandler = 0 then + FPositionChangedSignalHandler := g_signal_connect_data(PGObject(FWidget), 'notify::position', TGCallback(@TGTKPaned_resize), Self, nil, G_CONNECT_DEFAULT); + end else begin + g_signal_handler_disconnect(PGObject(FWidget), FPositionChangedSignalHandler); + FPositionChangedSignalHandler := 0; + end; + end; +end; + +function TGTKPaned_button_press_event(widget: PGtkWidget; event: PGdkEventButton; user_data: gpointer):gboolean; cdecl; +begin + if (event^.button = 3) and Assigned(TGTKPaned(user_data).FHandlePopupMenu) and + (event^.window = gtk_paned_get_handle_window(PGtkPaned(widget))) + then begin + gtk_menu_popup(PGtkMenu(TGTKMenuItem(TGTKPaned(user_data).FHandlePopupMenu).FMenu), nil, nil, nil, nil, event^.button, event^.time); + Result := True; + end; +end; + +procedure TGTKPaned.SetHandlePopupMenu(Value: TGTKControl); +begin + if FHandlePopupMenu <> Value then begin + FHandlePopupMenu := Value; + if not Assigned(Value) then begin + g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); + FButtonPressSignalHandler := 0; + end else + if FButtonPressSignalHandler = 0 + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKPaned_button_press_event), Self, nil, G_CONNECT_DEFAULT) + end; end; (********************************************************************************************************************************) diff --git a/libgtk_kylix/GTKForms.pas b/libgtk_kylix/GTKForms.pas index 0dc1691..3b159de 100644 --- a/libgtk_kylix/GTKForms.pas +++ b/libgtk_kylix/GTKForms.pas @@ -66,13 +66,11 @@ type // Some basic types private FOnClose: TCloseEvent; FOnCloseQuery: TCloseQueryEvent; - FOnResize: TNotifyEvent; FOnShow: TNotifyEvent; FCaption: string; FOnDestroy: TNotifyEvent; - FDeleteEventSignalHandlerID: gulong; - FSizeAllocateSignalHandlerID: gulong; - FShowSignalHandlerID: gulong; + FDeleteEventSignalHandler: gulong; + FShowSignalHandler: gulong; function GetWindowPosition: TWindowPosition; function GetResizeable: boolean; function GetWindowTypeHint: TGDKWindowTypeHint; @@ -97,7 +95,6 @@ type // Some basic types property Visible write SetVisible default False; property OnClose: TCloseEvent read FOnClose write FOnClose; property OnCloseQuery: TCloseQueryEvent read FOnCloseQuery write FOnCloseQuery; - property OnResize: TNotifyEvent read FOnResize write FOnResize; property OnShow: TNotifyEvent read FOnShow write FOnShow; property Caption: string read FCaption write SetCaption; property WindowPosition: TWindowPosition read GetWindowPosition write SetWindowPosition; @@ -277,20 +274,14 @@ begin if Assigned(TCustomGTKForm(user_data).FOnShow) then TCustomGTKForm(user_data).FOnShow(TCustomGTKForm(user_data)); end; -procedure TCustomGTKForm_size_allocate(widget : PGtkWidget; allocation : PGtkAllocation; user_data : gpointer); cdecl; -begin - if Assigned(TCustomGTKForm(user_data).FOnResize) then TCustomGTKForm(user_data).FOnResize(TCustomGTKForm(user_data)); -end; - constructor TCustomGTKForm.Create(AOwner: TComponent); begin inherited Create(AOwner); FOnClose := nil; FOnCloseQuery := nil; FOnDestroy := nil; - FDeleteEventSignalHandlerID := 0; - FSizeAllocateSignalHandlerID := 0; - FShowSignalHandlerID := 0; + FDeleteEventSignalHandler := 0; + FShowSignalHandler := 0; FCaption := ''; FAccelGroup := gtk_accel_group_new; Screen.AddForm(Self); @@ -300,18 +291,16 @@ destructor TCustomGTKForm.Destroy; begin Screen.RemoveForm(Self); if Assigned(FOnDestroy) then FOnDestroy(Self); -// if FDeleteEventSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FWidget), FDeleteEventSignalHandlerID); -// if FSizeAllocateSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FWidget), FSizeAllocateSignalHandlerID); -// if FShowSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FWidget), FShowSignalHandlerID); +// if FDeleteEventSignalHandler > 0 then g_signal_handler_disconnect(PGObject(FWidget), FDeleteEventSignalHandler); +// if FShowSignalHandler > 0 then g_signal_handler_disconnect(PGObject(FWidget), FShowSignalHandler); if not Application.Terminated then gtk_widget_destroy(FWidget); inherited Destroy; end; procedure TCustomGTKForm.ConnectDefaultSignals; begin - FDeleteEventSignalHandlerID := g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); - FSizeAllocateSignalHandlerID := g_signal_connect_data(PGObject(FWidget), 'size-allocate', TGCallback(@TCustomGTKForm_size_allocate), Self, nil, G_CONNECT_DEFAULT); - FShowSignalHandlerID := g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); + FDeleteEventSignalHandler := g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); + FShowSignalHandler := g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); end; procedure TCustomGTKForm.SetVisible(Value: Boolean); diff --git a/libgtk_kylix/GTKView.pas b/libgtk_kylix/GTKView.pas index 1ac742b..bf940df 100644 --- a/libgtk_kylix/GTKView.pas +++ b/libgtk_kylix/GTKView.pas @@ -258,9 +258,9 @@ type FSortable: boolean; FCompareFunc: TGTKTreeViewCompareFunc; FOnColumnsChanged: TNotifyEvent; - FChangedSignalHandlerID: gulong; - FRowActivatedSignalHandlerID: gulong; - FColumnsChangedSignalHandlerID: gulong; + FChangedSignalHandler: gulong; + FRowActivatedSignalHandler: gulong; + FColumnsChangedSignalHandler: gulong; protected FListItems: TGTKListItems; procedure Recreate; @@ -488,9 +488,9 @@ end; constructor TGTKListView.Create(AOwner: TComponent); begin inherited Create(AOwner); - FChangedSignalHandlerID := 0; - FRowActivatedSignalHandlerID := 0; - FColumnsChangedSignalHandlerID := 0; + FChangedSignalHandler := 0; + FRowActivatedSignalHandler := 0; + FColumnsChangedSignalHandler := 0; FListItems := TGTKListItems.Create(Self); FSortable := False; FCompareFunc := nil; @@ -499,9 +499,9 @@ end; destructor TGTKListView.Destroy; begin -// if FChangedSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FSelection), FChangedSignalHandlerID); -// if FRowActivatedSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FWidget), FRowActivatedSignalHandlerID); -// if FColumnsChangedSignalHandlerID > 0 then g_signal_handler_disconnect(PGObject(FWidget), FColumnsChangedSignalHandlerID); +// if FChangedSignalHandler > 0 then g_signal_handler_disconnect(PGObject(FSelection), FChangedSignalHandler); +// if FRowActivatedSignalHandler > 0 then g_signal_handler_disconnect(PGObject(FWidget), FRowActivatedSignalHandler); +// if FColumnsChangedSignalHandler > 0 then g_signal_handler_disconnect(PGObject(FWidget), FColumnsChangedSignalHandler); FListItems.Free; inherited Destroy; end; @@ -540,9 +540,9 @@ begin FWidget := gtk_tree_view_new_with_model(PGtkTreeModel(FTreeModelSort)); end; FSelection := gtk_tree_view_get_selection(PGtkTreeView(FWidget)); - FChangedSignalHandlerID := g_signal_connect_data(PGObject(FSelection), 'changed', TGCallback(@TGTKListView_changed), Self, nil, G_CONNECT_DEFAULT); - FRowActivatedSignalHandlerID := g_signal_connect_data(PGObject(FWidget), 'row-activated', TGCallback(@TGTKListView_row_activated), Self, nil, G_CONNECT_DEFAULT); - FColumnsChangedSignalHandlerID := g_signal_connect_data(PGObject(FWidget), 'columns-changed', TGCallback(@TGTKListView_columns_changed), Self, nil, [G_CONNECT_AFTER]); + FChangedSignalHandler := g_signal_connect_data(PGObject(FSelection), 'changed', TGCallback(@TGTKListView_changed), Self, nil, G_CONNECT_DEFAULT); + FRowActivatedSignalHandler := g_signal_connect_data(PGObject(FWidget), 'row-activated', TGCallback(@TGTKListView_row_activated), Self, nil, G_CONNECT_DEFAULT); + FColumnsChangedSignalHandler := g_signal_connect_data(PGObject(FWidget), 'columns-changed', TGCallback(@TGTKListView_columns_changed), Self, nil, [G_CONNECT_AFTER]); FTreeModel := gtk_tree_view_get_model(PGtkTreeView(FWidget)); Show; end; |
