summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com>2008-09-03 15:16:10 +0200
committerTomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com>2008-09-03 15:16:10 +0200
commitc977b8dd20d6f606f692efcd72e916fc020138f3 (patch)
treed641a3fa94035a3e5003fc609899b7ba85e3c6b6
parent7a2696850bf538fff83cc4e208287f96168a7e3c (diff)
downloadtuxcmd-c977b8dd20d6f606f692efcd72e916fc020138f3.tar.xz
Retain list selection in Connection Manager
Read/write connections on demand only
-rw-r--r--UConfig.pas37
-rw-r--r--UConnectionManager.pas7
-rw-r--r--UMain.pas10
3 files changed, 29 insertions, 25 deletions
diff --git a/UConfig.pas b/UConfig.pas
index f95321e..5e13616 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -107,6 +107,7 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems,
ConfUseSmoothScrolling: boolean;
ApplicationShuttingDown: boolean;
+ ConfConnMgrActiveItem: integer;
@@ -246,6 +247,7 @@ begin
ConfQuickSearchActivationKey := 0;
ConfSortDirectoriesLikeFiles := False;
ConfQuickRenameSkipExt := True;
+ ConfConnMgrActiveItem := 0;
// Setup default values for colors
@@ -921,23 +923,22 @@ begin
IniFile.ReadSections(Sections);
if Sections.Count > 0 then
for i := 0 to Sections.Count - 1 do
-{ if Sections[i] = 'General' then begin
- ConfMounterUseFSTab := IniFile.ReadBool('General', 'MounterUseFSTab', ConfMounterUseFSTab);
- ConfMounterPushDown := IniFile.ReadBool('General', 'MounterPushDown', ConfMounterPushDown);
- end else} begin
- Item := TConnMgrItem.Create;
- with Item do begin
- ConnectionName := Sections[i];
- ServiceType := IniFile.ReadString(Sections[i], 'ServiceType', '');
- Server := IniFile.ReadString(Sections[i], 'Server', '');
- Username := IniFile.ReadString(Sections[i], 'Username', '');
- Password := IniFile.ReadString(Sections[i], 'Password', '');
- TargetDir := IniFile.ReadString(Sections[i], 'TargetDir', '');
- PluginID := IniFile.ReadString(Sections[i], 'PluginID', '');
- URI := ConstructURI(False, ServiceType, Server, Username, Password, TargetDir);
+ if Sections[i] = '__General' then begin
+ ConfConnMgrActiveItem := IniFile.ReadInteger('__General', 'ConfConnMgrActiveItem', ConfConnMgrActiveItem);
+ end else begin
+ Item := TConnMgrItem.Create;
+ with Item do begin
+ ConnectionName := Sections[i];
+ ServiceType := IniFile.ReadString(Sections[i], 'ServiceType', '');
+ Server := IniFile.ReadString(Sections[i], 'Server', '');
+ Username := IniFile.ReadString(Sections[i], 'Username', '');
+ Password := IniFile.ReadString(Sections[i], 'Password', '');
+ TargetDir := IniFile.ReadString(Sections[i], 'TargetDir', '');
+ PluginID := IniFile.ReadString(Sections[i], 'PluginID', '');
+ URI := ConstructURI(False, ServiceType, Server, Username, Password, TargetDir);
+ end;
+ ConnectionMgrList.Add(Item);
end;
- ConnectionMgrList.Add(Item);
- end;
Sections.Free;
finally
try IniFile.Free; except end;
@@ -964,7 +965,7 @@ begin
IniFile := TMyIniFile.Create(s, False);
try try
-// IniFile.WriteBool('General', 'MounterUseFSTab', ConfMounterUseFSTab);
+ IniFile.WriteInteger('__General', 'ConnMgrActiveItem', ConfConnMgrActiveItem);
if ConnectionMgrList.Count > 0 then
for i := 0 to ConnectionMgrList.Count - 1 do
with TConnMgrItem(ConnectionMgrList[i]) do begin
@@ -1150,7 +1151,6 @@ initialization
ReadAssoc;
ReadBookmarks;
ReadMounter;
- ReadConnections;
// Apply the settings
LoadIcons;
@@ -1158,7 +1158,6 @@ initialization
finalization
// Save the settings
WriteBookmarks;
-// WriteConnections; -- not needed, saving when Connection Manager closes
WriteMainSettings;
if ConfSavePanelTabs then begin
WriteTabs(True, LeftPanelTabs, LeftTabSortIDs, LeftTabSortTypes);
diff --git a/UConnectionManager.pas b/UConnectionManager.pas
index a730026..0fbb4d1 100644
--- a/UConnectionManager.pas
+++ b/UConnectionManager.pas
@@ -153,7 +153,7 @@ begin
ListView.OnSelectionChanged := ListViewSelectionChanged;
ListView.OnDblClick := ListViewDblClick;
ListView.SetFocus;
- if ListView.Items.Count > 0 then ListView.Items[0].SetCursor(0, False, False, 0, 0);
+ if ListView.Items.Count > 0 then ListView.Items[ConfConnMgrActiveItem].SetCursor(0, False, False, 0, 0);
ListViewSelectionChanged(Self);
AddConnectionButton.OnClick := AddConnectionButtonClick;
EditButton.OnClick := EditButtonClick;
@@ -291,6 +291,8 @@ var i: integer;
Item: TGTKListItem;
ConnMgrItem: TConnMgrItem;
begin
+ ReadConnections;
+
if ConnectionMgrList.Count > 0 then
for i := 0 to ConnectionMgrList.Count - 1 do begin
ConnMgrItem := ConnectionMgrList[i];
@@ -300,7 +302,8 @@ begin
Item.SetValue(2, ConstructURI(True, ConnMgrItem.ServiceType, ConnMgrItem.Server, ConnMgrItem.Username,
ConnMgrItem.Password, ConnMgrItem.TargetDir));
end;
-
+ if (ConfConnMgrActiveItem < 0) or (ConfConnMgrActiveItem > ConnectionMgrList.Count) then
+ ConfConnMgrActiveItem := 0;
end;
diff --git a/UMain.pas b/UMain.pas
index 2696263..f548a6d 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -4601,10 +4601,10 @@ begin
ReadBookmarks;
RefreshBookmarksMenu;
end;
- if ChangedConnMgr then begin
+(* if ChangedConnMgr then begin
DebugMsg(['Connection manager file changed ---> performing refresh']);
ReadConnections;
- end;
+ end; *)
try
InternalLock;
if (ChangedMainGUI or ChangedAssoc or ChangedMounter) and (Application.MessageBox(LANGSomeOtherInstanceChanged,
@@ -5890,8 +5890,10 @@ begin
FConnectionManager := TFConnectionManager.Create(Self);
b := FConnectionManager.Run = mbOK;
- if FConnectionManager.ListView.Selected <> nil
- then ConnInfo := FConnectionManager.ListView.Selected.AsPointer(0);
+ if FConnectionManager.ListView.Selected <> nil then begin
+ ConnInfo := FConnectionManager.ListView.Selected.AsPointer(0);
+ ConfConnMgrActiveItem := FConnectionManager.ListView.Selected.Index;
+ end;
WriteConnections; // Save the list to the file
if b then begin