diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2013-06-13 16:52:37 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2013-06-13 16:52:37 +0200 |
| commit | c39411fcedd2086c10511a2be8bf81ba6c3c568c (patch) | |
| tree | 052c937e769d66552a2e85a414b8af7f9ace692a /UMain.pas | |
| parent | ed0d989bb49acea5f4e6285a2610e87fdf850cbd (diff) | |
| download | tuxcmd-c39411fcedd2086c10511a2be8bf81ba6c3c568c.tar.xz | |
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.
Diffstat (limited to 'UMain.pas')
| -rw-r--r-- | UMain.pas | 47 |
1 files changed, 26 insertions, 21 deletions
@@ -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; |
