summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UMain.pas67
1 files changed, 54 insertions, 13 deletions
diff --git a/UMain.pas b/UMain.pas
index 83ea9a1..f202302 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -228,7 +228,7 @@ type
procedure FillMounterBar;
procedure RebuildListViews(DoRefresh: boolean);
procedure FillPluginMenu;
- procedure NewTab(LeftPanel: boolean);
+ procedure NewTab(LeftPanel, SendSelectedDirToBg: boolean; CustomPath: string = '');
procedure SwitchTab(TabNo: integer; LeftPanel, SetFocus: boolean);
procedure CloseTab(TabNo: integer; LeftPanel: boolean);
procedure AddTabs(LeftPanel: boolean; TabList: TStringList; TabSortIDs, TabSortTypes: TList; SetTabActive: integer);
@@ -236,7 +236,7 @@ type
function CloseVFS(LeftPanel, SuppressRefresh: boolean): string;
procedure ShowBookmarkQuick(LeftPanel: boolean);
procedure SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, Tooltip: string);
- procedure NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer);
+ procedure NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer; SwitchToNewTab: boolean);
procedure CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean);
function HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean;
function ExtractFromArchive(var NewPath: string; Engine: TPanelEngine; const FilePath: string; ExtractAll: boolean): boolean;
@@ -2769,6 +2769,7 @@ procedure TFMain.ListViewMouseDown(Sender: TObject; Button: TGDKMouseButton; Shi
var Item: TGTKListItem;
Click: TDateTime;
Data: PDataItem;
+ AEngine: TPanelEngine;
begin
try
InternalLock;
@@ -2822,6 +2823,24 @@ begin
end else
if (Item <> nil) then FilePopupMenu.PopUp;
Accept := False;
+ end else
+ if Button = mbMiddle then begin
+ if not (Sender as TGTKListView).Focused then (Sender as TGTKListView).SetFocus;
+ Item := (Sender as TGTKListView).GetItemAtPos(X, Y);
+ if Assigned(Item) then begin
+ Item.Selected := True;
+ Item.SetCursor(0, False, not Application.GTKVersion_2_2_0_Up, 0.5, 0);
+ end;
+
+ // Open directory in background tab
+ if (Item <> nil) and (Item.Data <> nil) then begin
+ Data := PDataItem(Item.Data);
+ if Sender = LeftListView then AEngine := LeftPanelEngine
+ else AEngine := RightPanelEngine;
+ if (not Data^.UpDir) and (Data^.IsDir) then NewTab(Sender = LeftListView, True, IncludeTrailingPathDelimiter(AEngine.Path) + Data^.FName);
+ end;
+
+ Accept := False;
end;
finally
Application.ProcessMessages;
@@ -4317,6 +4336,7 @@ begin
Item.Enabled := Engine.FileCanRun(FileName);
FilePopupMenu.Add(Item);
end else begin
+ // Open directory
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
if UpDir then Item.Caption := LANGPopupGoUp
else Item.Caption := Format(LANGPopupOpenS, [QuoteMarkupStr(StrToUTF8(ShortFName), True)]);
@@ -4324,6 +4344,15 @@ begin
Item.Data := Pointer(1);
Item.OnClick := FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
+
+ // Open directory in background tab
+ if not UpDir then begin
+ Item := TGTKMenuItem.CreateTyped(Self, itImageText);
+ Item.Caption := 'Open directory in _background tab';
+ Item.Data := Pointer(3);
+ Item.OnClick := FilePopupMenuItemClick;
+ FilePopupMenu.Add(Item);
+ end;
end;
// Find actions for meta-item
@@ -4477,6 +4506,7 @@ begin
end;
2: if Application.MessageBox(Format(LANGThereIsNoApplicationAssociatedWithS, [ShortFName]), [mbYes, mbNo], mbQuestion, mbNone, mbNo) = mbYes
then miFileTypesClick(Self);
+ 3: NewTab(LeftLastFocused, True, FileName);
else begin
b := True;
s := UTF8ToStr(Trim(TAssocAction((Sender as TGTKMenuItem).Data).ActionCommand));
@@ -5392,7 +5422,7 @@ end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
-procedure TFMain.NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer);
+procedure TFMain.NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer; SwitchToNewTab: boolean);
var AListView: TGTKListView;
AEngine: TPanelEngine;
ANotebook: TEphyNotebook;
@@ -5406,6 +5436,7 @@ var AListView: TGTKListView;
TabSortIDs: TList;
TabSortTypes: TList;
i, InsertPos: integer;
+ ForceReparent: boolean;
begin
if LeftPanel then begin
AListView := LeftListView;
@@ -5460,27 +5491,35 @@ begin
InsertPos := NewTabPosition;
if InsertPos > ATabList.Count then InsertPos := ATabList.Count;
+ ForceReparent := not ANotebook.Visible;
if not ANotebook.Visible then ANotebook.Visible := True;
i := ANotebook.InsertPage(InsertPos, VBox, StrToUTF8(APath));
SetTabLabel(ANotebook, i, StrToUTF8(APath), StrToUTF8(ATabList[InsertPos]));
- ANotebook.PageIndex := i;
+ if SwitchToNewTab then ANotebook.PageIndex := i else
+ if ForceReparent then SwitchTab(0, LeftPanel, True); // We use first page as there were no tabs before
end;
-procedure TFMain.NewTab(LeftPanel: boolean);
+procedure TFMain.NewTab(LeftPanel, SendSelectedDirToBg: boolean; CustomPath: string = '');
var AEngine: TPanelEngine;
ATabList: TStringList;
+ ANotebook: TEphyNotebook;
APath: string;
DontShowAgain: boolean;
+ NewTabPosition: integer;
begin
if LeftPanel then begin
AEngine := LeftPanelEngine;
ATabList := LeftPanelTabs;
+ ANotebook := LeftPanelNotebook;
end else begin
AEngine := RightPanelEngine;
ATabList := RightPanelTabs;
+ ANotebook := RightPanelNotebook;
end;
- APath := AEngine.Path;
+ if Length(Trim(CustomPath)) > 0
+ then APath := CustomPath
+ else APath := AEngine.Path;
if AEngine is TVFSEngine then begin
while AEngine is TVFSEngine do begin
APath := AEngine.SavePath;
@@ -5495,8 +5534,10 @@ begin
end;
end;
end;
-
- NewTabInternal(LeftPanel, AEngine, APath, ATabList.Count + Ord(ATabList.Count = 0));
+
+ NewTabPosition := ATabList.Count + Ord(ATabList.Count = 0); // Append to end by default
+ if SendSelectedDirToBg and ANotebook.Visible then NewTabPosition := ANotebook.PageIndex + 1;
+ NewTabInternal(LeftPanel, AEngine, APath, NewTabPosition, not SendSelectedDirToBg);
end;
procedure TFMain.SwitchTab(TabNo: integer; LeftPanel, SetFocus: boolean);
@@ -5580,10 +5621,10 @@ end;
procedure TFMain.miDuplicateTabClick(Sender: TObject);
begin
if not CommandLineCombo.Entry.Focused then
- if LeftListView.Focused then NewTab(True) else
- if RightListView.Focused then NewTab(False) else
- if (Sender is TGTKMenuItem) and LeftTabPopup then NewTab(True) else
- if (Sender is TGTKMenuItem) and (not LeftTabPopup) then NewTab(False) else
+ if LeftListView.Focused then NewTab(True, False) else
+ if RightListView.Focused then NewTab(False, False) else
+ if (Sender is TGTKMenuItem) and LeftTabPopup then NewTab(True, False) else
+ if (Sender is TGTKMenuItem) and (not LeftTabPopup) then NewTab(False, False) else
DebugMsg(['Couldn''t duplicate tab: No listview focused.']);
end;
@@ -5939,7 +5980,7 @@ begin
dst_no := DestTabNo;
if dst_no < 0 then dst_no := ATargetTabList.Count + Ord(ATargetTabList.Count = 0);
CloseTab(SourceTabNo, LeftPanel);
- NewTabInternal(not LeftPanel, ATargetEngine, APath, dst_no);
+ NewTabInternal(not LeftPanel, ATargetEngine, APath, dst_no, True);
Result := True;
end;