From c64f56fa977eaa96861cd5d8bac03c59552838df Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 11 Nov 2008 23:12:42 +0100 Subject: Right mouse button selection mode Patch by Nikola Radovanovic --- UConfig.pas | 8 +- ULocale.pas | 1 + UMain.pas | 60 ++++++++++-- UPreferences.pas | 42 ++++---- libgtk_kylix/GTKControls.pas | 41 +++++++- libgtk_kylix/GTKMenus.pas | 205 ++++++++++++++++++++------------------- translations/UTranslation_EN.pas | 8 +- translations/UTranslation_SR.pas | 7 ++ 8 files changed, 236 insertions(+), 136 deletions(-) diff --git a/UConfig.pas b/UConfig.pas index 980c387..17a1b7d 100644 --- a/UConfig.pas +++ b/UConfig.pas @@ -100,7 +100,7 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems, ConfLinkItemDefaultColors, ConfDotFileItemDefaultColors, ConfLynxLikeMotion, ConfSizeGroupRequestZeroDigits, ConfDisableFileTips, ConfInsMoveDown, ConfSpaceMovesDown, ConfShowFuncButtons, ConfSelectAllDirs, ConfOctalPerm: boolean; ConfMounterUseFSTab, ConfShowTextUIDs, ConfMounterPushDown, ConfSavePanelTabs, ConfDuplicateTabWarning, - ConfOpenConnectionsWarning, ConfSortDirectoriesLikeFiles, ConfQuickRenameSkipExt: boolean; + ConfOpenConnectionsWarning, ConfSortDirectoriesLikeFiles, ConfQuickRenameSkipExt, ConfRightClickSelect: boolean; ConfShowMounterBar: integer; ConfColumnSizes, ConfColumnIDs: array[1..ConstNumPanelColumns] of integer; @@ -253,6 +253,7 @@ begin ConfSortDirectoriesLikeFiles := False; ConfQuickRenameSkipExt := True; ConfConnMgrActiveItem := 0; + ConfRightClickSelect := False; // Setup default values for colors @@ -479,6 +480,9 @@ begin ConfSortDirectoriesLikeFiles := IniFile.ReadBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles); ConfQuickRenameSkipExt := IniFile.ReadBool(ConfProfileName, 'QuickRenameSkipExt', ConfQuickRenameSkipExt); + (********************************************* NEW SINCE 0.6.55 *************************************************) + ConfRightClickSelect := IniFile.ReadBool(ConfProfileName, 'RightClickSelect', ConfRightClickSelect); + SearchForDefaultApps; finally @@ -569,6 +573,8 @@ begin IniFile.WriteBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles); IniFile.WriteBool(ConfProfileName, 'QuickRenameSkipExt', ConfQuickRenameSkipExt); + (********************************************* NEW SINCE 0.6.55 *************************************************) + IniFile.WriteBool(ConfProfileName, 'RightClickSelect', ConfRightClickSelect); except on E: Exception do DebugMsg(['*** Error: Cannot save user settings (', E.ClassName, '): ', E.Message]); diff --git a/ULocale.pas b/ULocale.pas index 0be780e..1586261 100644 --- a/ULocale.pas +++ b/ULocale.pas @@ -222,6 +222,7 @@ var LANGF2Button_Caption, LANGF3Button_Caption, LANGF4Button_Caption, LANGF5Butt LANGPreferences_QuickSearch_Option3, LANGPreferences_QuickSearch_Option4, LANGPreferences_TempPathLabel_Caption, LANGPreferences_VFSTempPathLabel_Caption, LANGPreferences_VFSTempPathEntry_Tooltip: string; + LANGPreferences_RightClickSelectCheckBox, LANGPreferences_RightClickSelectCheckBox_Tooltip: string; diff --git a/UMain.pas b/UMain.pas index a808667..f7cfea6 100644 --- a/UMain.pas +++ b/UMain.pas @@ -103,7 +103,6 @@ type procedure ListViewKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); procedure ListViewEnter(Sender: TObject; var Accept: boolean); procedure PathLabelMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); - procedure PathLabelMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); procedure PathButtonClick(Sender: TObject); function CompareFunc(Sender: TObject; var model: PGtkTreeModel; var a, b: PGtkTreeIter): integer; procedure F5ButtonClick(Sender: TObject); @@ -113,6 +112,7 @@ type procedure ListViewDblClick(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); procedure ListViewMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); procedure ListViewMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); + procedure ListViewMouseMove(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); procedure InplaceEditTimerTimer(Sender: TObject); procedure ListViewEdited(Sender: TObject; Column: TGTKTreeViewColumn; Item: TGTKListItem; var NewText: string; var AllowChange: boolean; var DataColumn: integer); procedure ListViewSelectionChanged(Sender: TObject); @@ -193,6 +193,7 @@ type LeftPathsHighlight, RightPathsHighlight: TStringList; LeftTabEngines, RightTabEngines: TList; LastUsedFilter: string; + PanelRightMouseSelMode, PanelRightMouseInProgress: boolean; procedure ConstructPanels; procedure ConstructMenu; procedure ConstructColumns(ListView: TGTKListView); @@ -276,6 +277,8 @@ begin QuickFind := False; LeftTabPopup := True; LastClick := 0; + PanelRightMouseSelMode := True; + PanelRightMouseInProgress := False; LastUsedFilter := '*.*'; RedrawLeftInactive := False; RedrawRightInactive := False; @@ -397,8 +400,6 @@ begin F7Button.CanFocus := False; F8Button.CanFocus := False; PanelSeparator.OnMouseUp := PanelSeparatorMouseUp; - LeftListView.PopupMenu := FilePopupMenu; - RightListView.PopupMenu := FilePopupMenu; // Events OnResize := FormResize; @@ -412,9 +413,7 @@ begin LeftListView.OnEnter := ListViewEnter; RightListView.OnEnter := ListViewEnter; LeftPathLabelEventBox.OnMouseDown := PathLabelMouseDown; - LeftPathLabelEventBox.OnMouseUp := PathLabelMouseUp; RightPathLabelEventBox.OnMouseDown := PathLabelMouseDown; - RightPathLabelEventBox.OnMouseUp := PathLabelMouseUp; LeftUpButton.OnClick := PathButtonClick; LeftRootButton.OnClick := PathButtonClick; LeftHomeButton.OnClick := PathButtonClick; @@ -439,6 +438,8 @@ begin RightListView.OnDblClick := ListViewDblClick;} LeftListView.OnSelectionChanged := ListViewSelectionChanged; RightListView.OnSelectionChanged := ListViewSelectionChanged; + LeftListView.OnMouseMove := ListViewMouseMove; + RightListView.OnMouseMove := ListViewMouseMove; LeftQuickFindEntry.OnEnter := QuickFindEntryEnter; RightQuickFindEntry.OnEnter := QuickFindEntryEnter; LeftPanelNotebook.OnTabSwitched := TabNotebookSwitchPage; @@ -1299,10 +1300,13 @@ begin end; procedure TFMain.PanelSeparatorMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); +var XLeft, XRight: gint; begin if Button = mbRight then begin Accept := False; - SplitterPopupMenu.PopUp; + gtk_widget_get_pointer(LeftPanelBox.FWidget, @XLeft, nil); + gtk_widget_get_pointer(RightPanelBox.FWidget, @XRight, nil); + if (XLeft > LeftPanelBox.Width) and (XRight < 0) then SplitterPopupMenu.PopUp; end; end; @@ -1642,10 +1646,6 @@ begin if Sender = LeftPathLabelEventBox then LeftListView.SetFocus else if Sender = RightPathLabelEventBox then RightListView.SetFocus; end; -end; - -procedure TFMain.PathLabelMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); -begin if Button = mbRight then begin Accept := False; PathBoxPopupMenu.PopUp; @@ -2733,9 +2733,11 @@ end; procedure TFMain.ListViewMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); var Item: TGTKListItem; Click: TDateTime; + Data: PDataItem; begin try InternalLock; + PanelRightMouseInProgress := False; // DebugMsg(['ListViewMouseDown, X = ', X, ', Y = ', Y]); if Button = mbLeft then begin Click := Now; @@ -2767,6 +2769,21 @@ begin Item.Selected := True; Item.SetCursor(0, False, not Application.GTKVersion_2_2_0_Up, 0.5, 0); end; + + // Show file popup menu or start selection mode, depending on ConfRightClickSelect + if ConfRightClickSelect then begin + if (Item <> nil) and (Item.Data <> nil) then begin + Data := PDataItem(Item.Data); + if not Data^.UpDir then begin + PanelRightMouseSelMode := not Data^.Selected; + Data^.Selected := PanelRightMouseSelMode; + Item.RedrawRow; + UpdatePanelInfoDown(Sender = LeftListView); + PanelRightMouseInProgress := True; + end; + end; + end else FilePopupMenu.PopUp; + Accept := False; end; finally Application.ProcessMessages; @@ -2774,6 +2791,27 @@ begin end; end; +procedure TFMain.ListViewMouseMove(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean); +var Item: TGTKListItem; + Data: PDataItem; +begin + Accept := True; + if not ((Sender is TGTKListView) and ConfRightClickSelect) then Exit; + + if (Button = mbRight) and PanelRightMouseInProgress then begin + Item := (Sender as TGTKListView).GetItemAtPos(X, Y); + if (Item <> nil) and (Item.Data <> nil) and (not Item.Selected) then begin + Data := PDataItem(Item.Data); + if not Data^.UpDir then begin + Data^.Selected := PanelRightMouseSelMode; + Item.Selected := True; + Item.SetCursor(0, False, not Application.GTKVersion_2_2_0_Up, 0.5, 0); + UpdatePanelInfoDown(Sender = LeftListView); + end; + end; + end else PanelRightMouseInProgress := False; +end; + procedure TFMain.InplaceEditTimerTimer(Sender: TObject); var LeftPanel: boolean; ListView: TGTKListView; @@ -4400,6 +4438,7 @@ var AListView: TGTKListView; i, FirstColumn, LastColumn: integer; LeftLV, b: boolean; begin + PanelRightMouseInProgress := False; if Button = mbLeft then begin AListView := Sender as TGTKListView; LeftLV := AListView = LeftListView; @@ -4420,6 +4459,7 @@ begin AListView.Columns[i].FixedWidth := ConfColumnSizes[AListView.Columns[i].Tag]; end; end; + if Button = mbRight then Accept := False; end; procedure TFMain.ListViewColumnClicked(Sender: TObject); diff --git a/UPreferences.pas b/UPreferences.pas index 3d5d17d..c65e3db 100644 --- a/UPreferences.pas +++ b/UPreferences.pas @@ -80,6 +80,7 @@ type TempPathLabel, VFSTempPathLabel: TGTKLabel; VFSTempPathEntry: TGTKEntry; QuickRenameSkipExtCheckBox: TGTKCheckButton; + RightClickSelectCheckBox: TGTKCheckButton; procedure FormCreate(Sender: TObject); override; procedure FormDestroy(Sender: TObject); @@ -336,7 +337,7 @@ begin PanelsPage.AddControlEx(PanelsLabel2, False, False, 5); Table5 := TGTKTable.Create(Self); - Table5.SetRowColCount(18, 2); + Table5.SetRowColCount(19, 2); PanelsPage.AddControlEx(Table5, False, False, 0); DisableMouseRename := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_DisableMouseRenaming); @@ -345,48 +346,51 @@ begin QuickRenameSkipExtCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_QuickRenameSkipExtCheckBox); QuickRenameSkipExtCheckBox.Tooltip := LANGPreferences_QuickRenameSkipExtCheckBox_Tooltip; Table5.AddControl(0, 1, 2, 1, QuickRenameSkipExtCheckBox, 30, 2); + RightClickSelectCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_RightClickSelectCheckBox); + RightClickSelectCheckBox.Tooltip := LANGPreferences_RightClickSelectCheckBox_Tooltip; + Table5.AddControl(0, 2, 2, 1, RightClickSelectCheckBox, 30, 2); DisableFileTipsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableFileTipsCheckBox_Caption); DisableFileTipsCheckBox.Tooltip := LANGPreferencesDisableFileTipsCheckBox_Tooltip; - Table5.AddControl(0, 2, 2, 1, DisableFileTipsCheckBox, 30, 2); + Table5.AddControl(0, 3, 2, 1, DisableFileTipsCheckBox, 30, 2); SortDirectoriesLikeFilesCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_SortDirectoriesLikeFilesCheckBox); SortDirectoriesLikeFilesCheckBox.Tooltip := LANGPreferences_SortDirectoriesLikeFilesCheckBox_Tooltip; - Table5.AddControl(0, 3, 2, 1, SortDirectoriesLikeFilesCheckBox, 30, 2); - Table5.AddControl(0, 4, 2, 1, TGTKVBox.Create(Self), 0, 7); + Table5.AddControl(0, 4, 2, 1, SortDirectoriesLikeFilesCheckBox, 30, 2); + Table5.AddControl(0, 5, 2, 1, TGTKVBox.Create(Self), 0, 7); PanelsLabel3 := TGTKLabel.Create(Self); PanelsLabel3.XAlign := 0; PanelsLabel3.XPadding := 0; PanelsLabel3.Caption := Format('%s', [LANGPreferencesShow]); PanelsLabel3.UseMarkup := True; - Table5.AddControl(0, 5, 2, 1, PanelsLabel3, 10, 2); + Table5.AddControl(0, 6, 2, 1, PanelsLabel3, 10, 2); ShowFiletypeIcons := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_ShowFiletypeIconsInList); - Table5.AddControl(0, 6, 2, 1, ShowFiletypeIcons, 30, 2); + Table5.AddControl(0, 7, 2, 1, ShowFiletypeIcons, 30, 2); DirsInBoldCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDirsInBoldCheckBox_Caption); - Table5.AddControl(0, 7, 2, 1, DirsInBoldCheckBox, 30, 2); + Table5.AddControl(0, 8, 2, 1, DirsInBoldCheckBox, 30, 2); DisableDirectoryBracketsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableDirectoryBracketsCheckBox_Caption); - Table5.AddControl(0, 8, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2); + Table5.AddControl(0, 9, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2); OctalPermissionsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesOctalPermissionsCheckBox_Caption); OctalPermissionsCheckBox.Tooltip := LANGPreferencesOctalPermissionsCheckBox_Tooltip; - Table5.AddControl(0, 9, 2, 1, OctalPermissionsCheckBox, 30, 2); + Table5.AddControl(0, 10, 2, 1, OctalPermissionsCheckBox, 30, 2); ShowTextUIDsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGShowTextUIDsCheckBox_Caption); ShowTextUIDsCheckBox.Tooltip := LANGShowTextUIDsCheckBox_Tooltip; - Table5.AddControl(0, 10, 2, 1, ShowTextUIDsCheckBox, 30, 2); - Table5.AddControl(0, 11, 2, 1, TGTKVBox.Create(Self), 0, 7); + Table5.AddControl(0, 11, 2, 1, ShowTextUIDsCheckBox, 30, 2); + Table5.AddControl(0, 12, 2, 1, TGTKVBox.Create(Self), 0, 7); PanelsLabel4 := TGTKLabel.Create(Self); PanelsLabel4.XAlign := 0; PanelsLabel4.XPadding := 0; PanelsLabel4.Caption := Format('%s', [LANGPreferencesMovement]); PanelsLabel4.UseMarkup := True; - Table5.AddControl(0, 12, 2, 1, PanelsLabel4, 10, 2); + Table5.AddControl(0, 13, 2, 1, PanelsLabel4, 10, 2); LynxLikeMotionCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesLynxLikeMotionCheckBox_Caption); - Table5.AddControl(0, 13, 2, 1, LynxLikeMotionCheckBox, 30, 2); + Table5.AddControl(0, 14, 2, 1, LynxLikeMotionCheckBox, 30, 2); InsertMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesInsertMovesDownCheckBox_Caption); - Table5.AddControl(0, 14, 2, 1, InsertMovesDownCheckBox, 30, 2); + Table5.AddControl(0, 15, 2, 1, InsertMovesDownCheckBox, 30, 2); SpaceMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesSpaceMovesDownCheckBox_Caption); - Table5.AddControl(0, 15, 2, 1, SpaceMovesDownCheckBox, 30, 2); + Table5.AddControl(0, 16, 2, 1, SpaceMovesDownCheckBox, 30, 2); QuickSearchLabel := TGTKLabel.Create(Self); QuickSearchLabel.Caption := LANGPreferences_QuickSearchLabel_Caption; @@ -407,9 +411,9 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itLabel); Item.Caption := LANGPreferences_QuickSearch_Option4; QuickSearchOptionMenu.Items.Add(Item); - Table5.AddControl(0, 16, 2, 1, TGTKVBox.Create(Self), 0, 2); - Table5.AddControlEx(0, 17, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2); - Table5.AddControlEx(1, 17, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2); + Table5.AddControl(0, 17, 2, 1, TGTKVBox.Create(Self), 0, 2); + Table5.AddControlEx(0, 18, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2); + Table5.AddControlEx(1, 18, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2); // ********* PAGE Applications @@ -919,6 +923,7 @@ begin SortDirectoriesLikeFilesCheckBox.Checked := ConfSortDirectoriesLikeFiles; VFSTempPathEntry.Text := StrToUTF8(ConfTempPath); QuickRenameSkipExtCheckBox.Checked := ConfQuickRenameSkipExt; + RightClickSelectCheckBox.Checked := ConfRightClickSelect; DefaultFontCheckBoxToggled(Self); ColorButtonDefaultsToggled(Self); @@ -992,6 +997,7 @@ begin ConfSortDirectoriesLikeFiles := SortDirectoriesLikeFilesCheckBox.Checked; ConfTempPath := UTF8ToStr(VFSTempPathEntry.Text); ConfQuickRenameSkipExt := QuickRenameSkipExtCheckBox.Checked; + ConfRightClickSelect := RightClickSelectCheckBox.Checked; end; (********************************************************************************************************************************) diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas index 8004857..d839a65 100644 --- a/libgtk_kylix/GTKControls.pas +++ b/libgtk_kylix/GTKControls.pas @@ -1,6 +1,6 @@ (* GTK-Kylix Library: GTKControls - Basic objects - Version 0.6.22 (last updated 2007-12-19) + Version 0.6.23 (last updated 2008-11-11) Copyright (C) 2007 Tomas Bzatek This library is free software; you can redistribute it and/or @@ -62,7 +62,7 @@ type TGTKPosition = (poLeft, poRight, poTop, poBottom); (****************************************** TGTKCONTROL *************************************************************************) - TGDKMouseButton = (mbLeft, mbMiddle, mbRight); + TGDKMouseButton = (mbLeft, mbMiddle, mbRight, mbNoButton); TGDKKeyEvent = procedure (Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean) of object; 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; @@ -74,7 +74,7 @@ type FParent: TGTKControl; FPopupMenu: TGTKControl; FButtonPressSignalHandler, FButtonReleaseSignalHandler, FKeyDownSignalHandler, FKeyUpSignalHandler, - FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler: gulong; + FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler, FMotionNotifyHandler: gulong; FOnKeyDown: TGDKKeyEvent; FOnKeyUp: TGDKKeyEvent; FOnEnter: TGDKFocusEvent; @@ -83,6 +83,7 @@ type FOnMouseUp: TGDKMouseEvent; FOnDblClick: TGDKMouseEvent; FOnExpose: TGDKExposeEvent; + FOnMouseMove: TGDKMouseEvent; function GetWidth: Integer; function GetHeight: Integer; function GetLeft: Integer; @@ -111,6 +112,7 @@ type procedure SetCanFocus(Value: boolean); procedure SetOnExpose(Value: TGDKExposeEvent); procedure SetControlState(Value: TGTKControlState); + procedure SetOnMouseMove(Value: TGDKMouseEvent); protected procedure SetParent(const Value: TGTKControl); virtual; public @@ -159,6 +161,7 @@ type property OnExit: TGDKFocusEvent read FOnExit write SetOnExit; property OnMouseDown: TGDKMouseEvent read FOnMouseDown write SetOnMouseDown; property OnMouseUp: TGDKMouseEvent read FOnMouseUp write SetOnMouseUp; + property OnMouseMove: TGDKMouseEvent read FOnMouseMove write SetOnMouseMove; property OnDblClick: TGDKMouseEvent read FOnDblClick write SetOnDblClick; property OnExpose: TGDKExposeEvent read FOnExpose write SetOnExpose; property ComponentState; @@ -313,6 +316,9 @@ begin FOnEnter := nil; FOnExit := nil; FOnExpose := nil; + FOnMouseMove := nil; + FOnMouseDown := nil; + FOnMouseUp := nil; end; destructor TGTKControl.Destroy; @@ -702,6 +708,35 @@ begin end; end; +function TGTKControl_motion_notify_event(widget: PGtkWidget; event: PGdkEventMotion; user_data: gpointer): gboolean; cdecl; +var Shift: TShiftState; + Button: TGDKMouseButton; + Accept: boolean; +begin + Accept := True; + if event^.is_hint <> 0 then Exit; + Shift := []; + if event^.state and GDK_SHIFT_MASK = GDK_SHIFT_MASK then Include(Shift, ssShift); + if event^.state and GDK_CONTROL_MASK = GDK_CONTROL_MASK then Include(Shift, ssCtrl); + if event^.state and GDK_MOD1_MASK = GDK_MOD1_MASK then Include(Shift, ssAlt); + if event^.state and GDK_BUTTON1_MASK = GDK_BUTTON1_MASK then Button := mbLeft else + if event^.state and GDK_BUTTON2_MASK = GDK_BUTTON2_MASK then Button := mbMiddle else + if event^.state and GDK_BUTTON3_MASK = GDK_BUTTON3_MASK then Button := mbRight else + Button := mbNoButton; + if Assigned(TGTKControl(widget).FOnMouseMove) + then TGTKControl(widget).FOnMouseMove(TGTKControl(widget), Button, Shift, Trunc(event^.x), Trunc(event^.y), Accept); + Result := not Accept; +end; + +procedure TGTKControl.SetOnMouseMove(Value: TGDKMouseEvent); +begin + if @FOnMouseMove <> @Value then begin + FOnMouseMove := Value; + if Assigned(Value) then FMotionNotifyHandler := g_signal_connect_swapped(PGtkObject(FWidget), 'motion-notify-event', G_CALLBACK(@TGTKControl_motion_notify_event), Self) + else g_signal_handler_disconnect(PGtkObject(FWidget), FMotionNotifyHandler); + end; +end; + function TGTKControl.GetDefault: boolean; begin Result := False; diff --git a/libgtk_kylix/GTKMenus.pas b/libgtk_kylix/GTKMenus.pas index 2b6e190..2c5a4a3 100644 --- a/libgtk_kylix/GTKMenus.pas +++ b/libgtk_kylix/GTKMenus.pas @@ -1,24 +1,24 @@ (* GTK-Kylix Library: GTKMenus - Menu handling and related routines Version 0.6.13 (last updated 2003-07-10) - Copyright (C) 2003 Tomas Bzatek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307 USA. - -*) + Copyright (C) 2003 Tomas Bzatek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307 USA. + +*) unit GTKMenus; { $WEAKPACKAGEUNIT} @@ -165,9 +165,9 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) procedure TGTKMenuItem_activate(menuitem : PGtkMenuItem; user_data: pgpointer); cdecl; -begin - if Assigned(TGTKMenuItem(user_data).FOnClick) then TGTKMenuItem(user_data).FOnClick(TGTKMenuItem(user_data)); -end; +begin + if Assigned(TGTKMenuItem(user_data).FOnClick) then TGTKMenuItem(user_data).FOnClick(TGTKMenuItem(user_data)); +end; constructor TGTKMenuItem.Create(AOwner: TComponent); begin @@ -310,101 +310,102 @@ end; function TGTKMenuItem.GetCaption: string; begin - Result := ''; - if FItemType in [itSeparator, itTearOff] then Exit; - if Assigned(ChildControl) then Result := PgcharToString(gtk_label_get_text(PGtkLabel(ChildControl))); -end; + Result := ''; + if FItemType in [itSeparator, itTearOff] then Exit; + if Assigned(ChildControl) then Result := PgcharToString(gtk_label_get_text(PGtkLabel(ChildControl))); +end; procedure TGTKMenuItem.SetCaption(Value: string); begin if FItemType in [itSeparator, itTearOff] then Exit; gtk_label_set_markup_with_mnemonic(PGtkLabel(ChildControl), StringToPgchar(Value)); - if FTearOffTitle = '' then SetTearOffTitle(Value); -end; - -procedure TGTKMenuItem.SetCaptionPlain(Value: string); + if FTearOffTitle = '' then SetTearOffTitle(Value); +end; + +procedure TGTKMenuItem.SetCaptionPlain(Value: string); begin if FItemType in [itSeparator, itTearOff] then Exit; gtk_label_set_markup(PGtkLabel(ChildControl), StringToPgchar(Value)); - if FTearOffTitle = '' then SetTearOffTitle(Value); -end; - -procedure TGTKMenuItem.SetTearOffTitle(Value: string); -begin - FTearOffTitle := Value; - if FItemType = itTearOff then begin + if FTearOffTitle = '' then SetTearOffTitle(Value); +end; + +procedure TGTKMenuItem.SetTearOffTitle(Value: string); +begin + FTearOffTitle := Value; + if FItemType = itTearOff then begin if Assigned(FParentMenu) and (FParentMenu is TGTKMenuItem) and Assigned((FParentMenu as TGTKMenuItem).FMenu) - then gtk_menu_set_title(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), StringToPgchar(FTearOffTitle)) - end else if Assigned(FMenu) then gtk_menu_set_title(PGtkMenu(FMenu), StringToPgchar(FTearOffTitle)); - end; - -function TGTKMenuItem.GetRightJustified: boolean; -begin - Result := False; - if FItemType in [itSeparator, itTearOff] then Exit; - Result := gtk_menu_item_get_right_justified(PGtkMenuItem(FWidget)); -end; - + then gtk_menu_set_title(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), StringToPgchar(FTearOffTitle)) + end else if Assigned(FMenu) then gtk_menu_set_title(PGtkMenu(FMenu), StringToPgchar(FTearOffTitle)); +end; + +function TGTKMenuItem.GetRightJustified: boolean; +begin + Result := False; + if FItemType in [itSeparator, itTearOff] then Exit; + Result := gtk_menu_item_get_right_justified(PGtkMenuItem(FWidget)); +end; + procedure TGTKMenuItem.SetRightJustified(Value: boolean); begin if FItemType in [itSeparator, itTearOff] then Exit; gtk_menu_item_set_right_justified(PGtkMenuItem(FWidget), Value); end; - procedure TGTKMenuItem.SetItemType(Value: TGTKMenuItemType); - begin - if Value <> FItemType then begin - FItemType := Value; - Recreate; - end; - end; - - function TGTKMenuItem.GetTornOff: boolean; - begin - if FItemType = itTearOff then Result := Boolean(torn_off(PGTKTearOffMenuItem(FWidget)^)) else - if Assigned(FMenu) and (Count > 0) then Result := Boolean(torn_off(PGTKMenu(FMenu)^)) - else Result := False; - end; - - procedure TGTKMenuItem.SetTornOff(Value: boolean); - begin - if FItemType = itTearOff then begin - if Assigned(FParentMenu) and (FParentMenu is TGTKMenuItem) and Assigned((FParentMenu as TGTKMenuItem).FMenu) - then gtk_menu_set_tearoff_state(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), Value); - end else if Assigned(FMenu) then gtk_menu_set_tearoff_state(PGtkMenu(FMenu), Value); - end; - - procedure TGTKMenuItem.TearOff; - begin - SetTornOff(True); - end; - - procedure TGTKMenuItem.UnTearOff; -begin - SetTornOff(False); - end; - - function TGTKMenuItem.GetChecked: boolean; - begin - Result := False; - if (FItemType = itCheck) or (FItemType = itRadio) then - Result := Boolean(active(PGtkCheckMenuItem(FWidget)^)); - end; - - procedure TGTKMenuItem.SetChecked(Value: boolean); - begin - if (FItemType = itCheck) or (FItemType = itRadio) then - gtk_check_menu_item_set_active(PGtkCheckMenuItem(FWidget), Value); - end; - - procedure TGTKMenuItem.PopUp; - begin - if FItems.Count > 0 then gtk_menu_popup(PGtkMenu(FMenu), nil, nil, nil, nil, 3, 0); -end; - - procedure TGTKMenuItem.PopDown; - begin - if FItems.Count > 0 then gtk_menu_popdown(PGtkMenu(FMenu)); +procedure TGTKMenuItem.SetItemType(Value: TGTKMenuItemType); +begin + if Value <> FItemType then begin + FItemType := Value; + Recreate; + end; +end; + +function TGTKMenuItem.GetTornOff: boolean; +begin + if FItemType = itTearOff then Result := Boolean(torn_off(PGTKTearOffMenuItem(FWidget)^)) else + if Assigned(FMenu) and (Count > 0) then Result := Boolean(torn_off(PGTKMenu(FMenu)^)) + else Result := False; +end; + +procedure TGTKMenuItem.SetTornOff(Value: boolean); +begin + if FItemType = itTearOff then begin + if Assigned(FParentMenu) and (FParentMenu is TGTKMenuItem) and Assigned((FParentMenu as TGTKMenuItem).FMenu) + then gtk_menu_set_tearoff_state(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), Value); + end else if Assigned(FMenu) then gtk_menu_set_tearoff_state(PGtkMenu(FMenu), Value); +end; + +procedure TGTKMenuItem.TearOff; +begin + SetTornOff(True); +end; + +procedure TGTKMenuItem.UnTearOff; +begin + SetTornOff(False); +end; + +function TGTKMenuItem.GetChecked: boolean; +begin + Result := False; + if (FItemType = itCheck) or (FItemType = itRadio) then + Result := Boolean(active(PGtkCheckMenuItem(FWidget)^)); +end; + +procedure TGTKMenuItem.SetChecked(Value: boolean); +begin + if (FItemType = itCheck) or (FItemType = itRadio) then + gtk_check_menu_item_set_active(PGtkCheckMenuItem(FWidget), Value); +end; + +procedure TGTKMenuItem.PopUp; +begin + if Assigned(FOnPopup) then FOnPopup(Self); + if (FItems <> nil) and (FItems.Count > 0) then gtk_menu_popup(PGtkMenu(FMenu), nil, nil, nil, nil, 3, 0); +end; + +procedure TGTKMenuItem.PopDown; +begin + if (FItems <> nil) and (FItems.Count > 0) then gtk_menu_popdown(PGtkMenu(FMenu)); end; procedure TGTKMenuItem.SetStockIcon(Value: string); @@ -428,7 +429,7 @@ begin end; (********************************************************************************************************************************) - (********************************************************************************************************************************) +(********************************************************************************************************************************) constructor TGDKShortCuts.Create(AOwner: TComponent); begin inherited Create(AOwner); diff --git a/translations/UTranslation_EN.pas b/translations/UTranslation_EN.pas index 8d067ae..2b39a19 100644 --- a/translations/UTranslation_EN.pas +++ b/translations/UTranslation_EN.pas @@ -673,8 +673,9 @@ const LANGenF2Button_Caption = 'F2 - Rename'; LANGenPreferences_VFSTempPathLabel_Caption = '_VFS temp files:'; LANGenPreferences_VFSTempPathEntry_Tooltip = 'Location of temporary files used by VFS subsystem, e.g. when opening files directly from archives. All temporary files are cleaned on exit.'; - - + (*************** STRINGS ADDED TO v0.6.55 **********************************************************************************) + LANGenPreferences_RightClickSelectCheckBox = 'Right mouse button selection mode'; + LANGenPreferences_RightClickSelectCheckBox_Tooltip = 'Use right mouse button to select, like mc.'; (********************************************************************************************************************************) procedure SetTranslation; @@ -1306,6 +1307,9 @@ begin LANGPreferences_TempPathLabel_Caption := LANGenPreferences_TempPathLabel_Caption; LANGPreferences_VFSTempPathLabel_Caption := LANGenPreferences_VFSTempPathLabel_Caption; LANGPreferences_VFSTempPathEntry_Tooltip := LANGenPreferences_VFSTempPathEntry_Tooltip; + + LANGPreferences_RightClickSelectCheckBox := LANGenPreferences_RightClickSelectCheckBox; + LANGPreferences_RightClickSelectCheckBox_Tooltip := LANGenPreferences_RightClickSelectCheckBox_Tooltip; end; initialization diff --git a/translations/UTranslation_SR.pas b/translations/UTranslation_SR.pas index 59a8752..6d50238 100644 --- a/translations/UTranslation_SR.pas +++ b/translations/UTranslation_SR.pas @@ -670,6 +670,10 @@ const LANGsrF2Button_Caption = 'F2 - Преименуј'; LANGsrPreferences_VFSTempPathLabel_Caption = '_VFS temp files:'; LANGsrPreferences_VFSTempPathEntry_Tooltip = 'Location of temporary files used by VFS subsystem, e.g. when opening files directly from archives. All temporary files are cleaned on exit.'; + (*************** STRINGS ADDED TO v0.6.55 **********************************************************************************) + LANGsrPreferences_RightClickSelectCheckBox = 'Избор десним тастером миша'; + LANGsrPreferences_RightClickSelectCheckBox_Tooltip = 'Користи десни тастер миша за обележавање, као у mc.'; + (********************************************************************************************************************************) procedure SetTranslation; begin @@ -1300,6 +1304,9 @@ begin LANGPreferences_TempPathLabel_Caption := LANGsrPreferences_TempPathLabel_Caption; LANGPreferences_VFSTempPathLabel_Caption := LANGsrPreferences_VFSTempPathLabel_Caption; LANGPreferences_VFSTempPathEntry_Tooltip := LANGsrPreferences_VFSTempPathEntry_Tooltip; + + LANGPreferences_RightClickSelectCheckBox := LANGsrPreferences_RightClickSelectCheckBox; + LANGPreferences_RightClickSelectCheckBox_Tooltip := LANGsrPreferences_RightClickSelectCheckBox_Tooltip; end; initialization -- cgit v1.2.3