From c39411fcedd2086c10511a2be8bf81ba6c3c568c Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 13 Jun 2013 16:52:37 +0200 Subject: Properly catch list view column resizing Listen to the GtkTreeViewColumn "width" property changes and sync column sizes with the opposite list view. This is a proper feature implementation and the original hack has been removed. --- UMain.pas | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'UMain.pas') diff --git a/UMain.pas b/UMain.pas index 252e557..d7c23a9 100644 --- a/UMain.pas +++ b/UMain.pas @@ -1049,6 +1049,31 @@ begin PathBoxPopupMenu.Add(miPathBoxCopyPath); end; +procedure ListViewColumnResized(gobject: PGObject; pspec: PGParamSpec; user_data: gpointer); cdecl; +var AListView: TGTKListView; + i, FirstColumn, LastColumn: integer; + LeftLV, b: boolean; +begin + AListView := TGTKListView(user_data); + LeftLV := AListView = FMain.LeftListView; + GetFirstLastPanelColumn(FirstColumn, LastColumn); + b := True; + for i := 0 to AListView.Columns.Count - 1 do + if (AListView.Columns[i].Tag <> LastColumn) or (FirstColumn = LastColumn) then + b := b and (ConfColumnSizes[AListView.Columns[i].Tag] = AListView.Columns[i].Width); + if not b then begin + DebugMsg(['*** ListViewColumnResized']); + for i := 0 to AListView.Columns.Count - 1 do + ConfColumnSizes[AListView.Columns[i].Tag] := AListView.Columns[i].Width; + if LeftLV then AListView := FMain.RightListView + else AListView := FMain.LeftListView; + // Change target widths + for i := 0 to AListView.Columns.Count - 1 do + if ConfColumnSizes[AListView.Columns[i].Tag] <> AListView.Columns[i].Width then + AListView.Columns[i].FixedWidth := ConfColumnSizes[AListView.Columns[i].Tag]; + end; +end; + procedure TFMain.ConstructColumns(ListView: TGTKListView); var i, FirstColumn, LastColumn: integer; Column: TGTKTreeViewColumn; @@ -1103,7 +1128,7 @@ begin end; if Application.GTKVersion_2_4_0_Up then Column.SetProperty('single-paragraph-mode', 1); Column.OnClicked := ListViewColumnClicked; - + g_signal_connect(Column.FColumn, 'notify::width', G_CALLBACK(@ListViewColumnResized), ListView); end; // Set the list font @@ -4421,26 +4446,6 @@ var AListView: TGTKListView; begin PanelRightMouseInProgress := False; RightMouseSelectPopupTimer.Enabled := False; - if Button = mbLeft then begin - AListView := Sender as TGTKListView; - LeftLV := AListView = LeftListView; - GetFirstLastPanelColumn(FirstColumn, LastColumn); - b := True; - for i := 0 to AListView.Columns.Count - 1 do - if (AListView.Columns[i].Tag <> LastColumn) or (FirstColumn = LastColumn) then - b := b and (ConfColumnSizes[AListView.Columns[i].Tag] = AListView.Columns[i].Width); - if not b then begin - DebugMsg(['*** ListView Mouse Up -> resizing columns']); - for i := 0 to AListView.Columns.Count - 1 do - ConfColumnSizes[AListView.Columns[i].Tag] := AListView.Columns[i].Width; - if LeftLV then AListView := RightListView - else AListView := LeftListView; - // Change target widths - for i := 0 to AListView.Columns.Count - 1 do - if ConfColumnSizes[AListView.Columns[i].Tag] <> AListView.Columns[i].Width then - AListView.Columns[i].FixedWidth := ConfColumnSizes[AListView.Columns[i].Tag]; - end; - end; if Button = mbRight then Accept := False; end; -- cgit v1.2.3