summaryrefslogtreecommitdiff
path: root/UConnectionManager.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UConnectionManager.pas')
-rw-r--r--UConnectionManager.pas124
1 files changed, 63 insertions, 61 deletions
diff --git a/UConnectionManager.pas b/UConnectionManager.pas
index bf9e67f..0be9305 100644
--- a/UConnectionManager.pas
+++ b/UConnectionManager.pas
@@ -22,7 +22,7 @@ unit UConnectionManager;
interface
uses
- lazglib2, gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView,
+ SysUtils, Classes, lazglib2, lazgdk3, lazgtk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView,
GTKPixbuf, GTKMenus,
UCore, UCoreWorkers, UCoreClasses, UVFSCore, UEngines;
@@ -35,9 +35,9 @@ type
TitleHBox: TGTKHBox;
ListView: TGTKListView;
ListViewScrolledWindow: TGTKScrolledWindow;
- ListViewTable: TGTKTable;
- AddConnectionButton, EditButton, RemoveButton, DuplicateButton: TGTKImageButton;
- QuickConnectButton: TGTKImageButton;
+ ListViewGrid: TGTKGrid;
+ AddConnectionButton, EditButton, RemoveButton, DuplicateButton: TGTKButton;
+ QuickConnectButton: TGTKButton;
ButtonBox: TGTKVButtonBox;
ActionButtonBox: TGTKHButtonBox;
ConnectButton, StopButton, CloseButton: TGTKButton;
@@ -78,21 +78,23 @@ uses ULocale, UCoreUtils, UConfig, UConnectionProperties, UGnome, UQuickConnect,
procedure TFConnectionManager.FormCreate(Sender: TObject);
-const row_targets: TGtkTargetEntry = (target: 'GTK_TREE_MODEL_ROW'; flags: GTK_TARGET_SAME_WIDGET; info: 1;);
+const row_targets: TGtkTargetEntry = (target: 'GTK_TREE_MODEL_ROW'; flags: guint(GTK_TARGET_SAME_WIDGET); info: 1;);
var Column: TGTKTreeViewColumn;
+ VBox: TGTKVBox;
begin
Thread := nil;
ConnectedEngine := nil;
SetDefaultSize(650, 500);
Caption := LANGConnMgr_Caption;
Buttons := [];
- ShowSeparator := False;
ConnectButton := TGTKButton.Create(Self);
ConnectButton.Caption := LANGConnMgr_ConnectButton;
// ConnectButton.Default := True;
- CloseButton := TGTKButton.CreateFromStock(Self, GTK_STOCK_CLOSE);
- StopButton := TGTKButton.CreateFromStock(Self, GTK_STOCK_STOP);
+ CloseButton := TGTKButton.CreateFromIconName(Self, GTK_STOCK_CLOSE);
+ CloseButton.Caption := 'Close';
+ StopButton := TGTKButton.CreateFromIconName(Self, GTK_STOCK_STOP);
+ StopButton.Caption := 'Stop';
StopButton.Visible := False;
StopButton.Enabled := False;
// Default := ConnectButton;
@@ -111,13 +113,15 @@ begin
TitleLabel.Caption := Format('<span size="x-large" weight="ultrabold">%s</span>', [LANGConnMgr_OpenConnection]);
TitleLabel.UseMarkup := True;
TitleLabel.XAlign := 0;
- TitleLabel.XPadding := 0;
- TitleLabel.YPadding := 3;
+ TitleLabel.MarginStart := 0;
+ TitleLabel.MarginEnd := 0;
+ TitleLabel.MarginTop := 3;
+ TitleLabel.MarginBottom := 3;
TitleEventBox.ControlState := csPrelight;
TitleFrame := TGTKFrame.CreateWithoutLabel(Self);
TitleFrame.ShadowType := stShadowOut;
TitleIcon := TGTKImage.Create(Self);
- TitleIcon.SetFromStock('gtk-connect', isLargeToolbar);
+ TitleIcon.SetFromIconName('gtk-connect', isLargeToolbar);
TitleHBox := TGTKHBox.Create(Self);
TitleHBox.Homogeneous := False;
TitleHBox.AddControlEx(TGTKEventBox.Create(Self), False, False, 5);
@@ -127,9 +131,9 @@ begin
TitleFrame.AddControl(TitleEventBox);
ClientArea.AddControlEx(TitleFrame, False, True, 0);
- ListViewTable := TGTKTable.Create(Self);
- ListViewTable.BorderWidth := 7;
- ClientArea.AddControlEx(ListViewTable, True, True, 0);
+ ListViewGrid := TGTKGrid.Create(Self);
+ ListViewGrid.BorderWidth := 7;
+ ClientArea.AddControlEx(ListViewGrid, True, True, 0);
ListView := TGTKListView.CreateTyped(Self, True, [lcPointer, lcText, lcText]);
ListView.SelectionMode := smSingle;
@@ -164,28 +168,27 @@ begin
ListViewScrolledWindow.HorizScrollBarPolicy := sbAutomatic;
ListViewScrolledWindow.VertScrollBarPolicy := sbAutomatic;
ListViewScrolledWindow.ShadowType := stShadowIn;
+ ListViewScrolledWindow.MarginTop := 5;
+ ListViewScrolledWindow.MarginBottom := 5;
- AddConnectionButton := TGTKImageButton.Create(Self);
- AddConnectionButton.SetFromStock('gtk-add', isSmallToolbar);
+ AddConnectionButton := TGTKButton.CreateFromIconName(Self, 'gtk-add');
AddConnectionButton.Caption := LANGConnMgr_AddConnectionButtonCaption;
AddConnectionButton.UseUnderline := True;
AddConnectionButton.Tooltip := LANGConnMgr_AddConnectionButtonTooltip;
- EditButton := TGTKImageButton.Create(Self);
+ EditButton := TGTKButton.Create(Self);
EditButton.Caption := LANGConnMgr_EditButtonCaption;
EditButton.UseUnderline := True;
EditButton.Tooltip := LANGConnMgr_EditButtonTooltip;
- RemoveButton := TGTKImageButton.Create(Self);
- RemoveButton.SetFromStock('gtk-remove', isSmallToolbar);
+ RemoveButton := TGTKButton.CreateFromIconName(Self, 'gtk-remove');
RemoveButton.Caption := LANGConnMgr_RemoveButtonCaption;
RemoveButton.UseUnderline := True;
RemoveButton.Tooltip := LANGConnMgr_RemoveButtonTooltip;
- DuplicateButton := TGTKImageButton.Create(Self);
+ DuplicateButton := TGTKButton.Create(Self);
DuplicateButton.Caption := LANGFConnectionManager_DuplicateButton_Caption;
DuplicateButton.UseUnderline := True;
DuplicateButton.Tooltip := LANGFConnectionManager_DuplicateButton_Tooltip;
- QuickConnectButton := TGTKImageButton.Create(Self);
- QuickConnectButton.SetFromStock('gtk-connect', isSmallToolbar);
+ QuickConnectButton := TGTKButton.CreateFromIconName(Self, 'gtk-connect');
QuickConnectButton.Caption := LANGmiQuickConnectCaption;
QuickConnectButton.UseUnderline := True;
@@ -198,34 +201,47 @@ begin
ButtonBox.AddControl(EditButton);
ButtonBox.AddControl(DuplicateButton);
ButtonBox.AddControl(RemoveButton);
+ ButtonBox.MarginStart := 5;
+ ButtonBox.MarginEnd := 5;
+ ButtonBox.MarginTop := 5;
+ ButtonBox.MarginBottom := 5;
DoNotSavePasswordsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGFConnectionManager_DoNotSavePasswordsCheckBox_Label);
DoNotSavePasswordsCheckBox.Tooltip := LANGFConnectionManager_DoNotSavePasswordsCheckBox_Tooltip;
+ DoNotSavePasswordsCheckBox.MarginStart := 10;
+ DoNotSavePasswordsCheckBox.MarginEnd := 10;
DoNotSynchronizeKeyringCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGFConnectionManager_DoNotSynchronizeKeyringCheckBox_Label);
DoNotSynchronizeKeyringCheckBox.Tooltip := LANGFConnectionManager_DoNotSynchronizeKeyringCheckBox_Tooltip;
+ DoNotSynchronizeKeyringCheckBox.MarginStart := 10;
+ DoNotSynchronizeKeyringCheckBox.MarginEnd := 10;
+ DoNotSynchronizeKeyringCheckBox.MarginTop := 2;
+ DoNotSynchronizeKeyringCheckBox.MarginBottom := 2;
+ VBox := TGTKVBox.Create(Self);
+ VBox.MarginTop := 2;
+ VBox.MarginBottom := 2;
- ListViewTable.AddControlEx(0, 1, 3, 5, ListViewScrolledWindow, [taoExpand, taoFill], [taoExpand, taoFill], 0, 5);
- ListViewTable.AddControlEx(0, 6, 3, 1, DoNotSavePasswordsCheckBox, [taoExpand, taoFill], [taoShrink], 10, 0);
- ListViewTable.AddControlEx(0, 7, 3, 1, DoNotSynchronizeKeyringCheckBox, [taoExpand, taoFill], [taoShrink], 10, 2);
- ListViewTable.AddControlEx(3, 2, 1, 3, ButtonBox, [taoShrink, taoFill], [taoShrink], 5, 5);
- ListViewTable.AddControlEx(3, 5, 1, 1, TGTKLabel.Create(Self), [taoShrink, taoFill], [taoExpand, taoFill], 0, 2);
+ ListViewGrid.AddControl(0, 1, 3, 5, ListViewScrolledWindow);
+ ListViewGrid.AddControl(0, 6, 3, 1, DoNotSavePasswordsCheckBox);
+ ListViewGrid.AddControl(0, 7, 3, 1, DoNotSynchronizeKeyringCheckBox);
+ ListViewGrid.AddControl(3, 2, 1, 3, ButtonBox);
+ ListViewGrid.AddControl(3, 5, 1, 1, VBox);
ItemsPopupMenu := TGTKMenuItem.Create(Self);
ConnectMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
ConnectMenuItem.Caption := LANGConnMgr_ConnectButton;
- ConnectMenuItem.StockIcon := 'gtk-connect';
+ ConnectMenuItem.IconName := 'gtk-connect';
ConnectMenuItem.OnClick := @ConnectButtonClick;
AddConnectionMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
AddConnectionMenuItem.Caption := LANGConnMgr_AddConnectionButtonCaption;
- AddConnectionMenuItem.StockIcon := 'gtk-add';
+ AddConnectionMenuItem.IconName := 'gtk-add';
AddConnectionMenuItem.OnClick := @AddConnectionButtonClick;
EditMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
EditMenuItem.Caption := LANGConnMgr_EditButtonCaption;
EditMenuItem.OnClick := @EditButtonClick;
RemoveMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
RemoveMenuItem.Caption := LANGConnMgr_RemoveButtonCaption;
- RemoveMenuItem.StockIcon := 'gtk-remove';
+ RemoveMenuItem.IconName := 'gtk-remove';
RemoveMenuItem.OnClick := @RemoveButtonClick;
DuplicateMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
DuplicateMenuItem.Caption := LANGFConnectionManager_DuplicateMenuItem_Caption;
@@ -277,13 +293,13 @@ end;
procedure TFConnectionManager.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
begin
case Key of
- GDK_RETURN, GDK_KP_ENTER: if StopButton.Visible then StopButtonClick(Sender) else
- if Assigned(ListView.Selected) then DoConnect;
- GDK_ESCAPE: begin
- Accept := False;
- if StopButton.Visible then StopButtonClick(Sender)
- else ModalResult := mbCancel;
- end;
+ GDK_KEY_Return, GDK_KEY_KP_Enter: if StopButton.Visible then StopButtonClick(Sender) else
+ if Assigned(ListView.Selected) then DoConnect;
+ GDK_KEY_Escape: begin
+ Accept := False;
+ if StopButton.Visible then StopButtonClick(Sender)
+ else ModalResult := mbCancel;
+ end;
end;
end;
@@ -296,7 +312,7 @@ end;
procedure TFConnectionManager.ListViewKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
begin
case Key of
- GDK_Delete_Key: RemoveButtonClick(Sender);
+ GDK_KEY_Delete: RemoveButtonClick(Sender);
end;
end;
@@ -334,9 +350,7 @@ begin
ConnMgrItem.Username := UserNameEntry.Text;
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
- ConnMgrItem.PluginID := '';
- if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
- ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
+ ConnMgrItem.PluginID := PluginComboBox.ItemID;
end;
ConnectionMgrList.Add(ConnMgrItem);
Item := ListView.Items.Add;
@@ -365,13 +379,9 @@ begin
FConnectionProperties := TFConnectionProperties.Create(Self);
FConnectionProperties.NameEntry.Text := ConnMgrItem.ConnectionName;
FConnectionProperties.URIEntry.Text := ConstructURI(True, False, ConnMgrItem.ServiceType, ConnMgrItem.Server, ConnMgrItem.Username, ConnMgrItem.Password, ConnMgrItem.TargetDir);
- FConnectionProperties.ServiceTypeOptionMenuChanged(Sender);
+ FConnectionProperties.ServiceTypeComboBoxChanged(Sender);
// Find the plugin by PluginID
- for i := 0 to FConnectionProperties.PluginOptionMenu.Items.Count - 1 do
- if (FConnectionProperties.PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(FConnectionProperties.PluginOptionMenu.Items[i].Data).ModuleID = ConnMgrItem.PluginID) then begin
- FConnectionProperties.PluginOptionMenu.ItemIndex := i;
- Break;
- end;
+ FConnectionProperties.PluginComboBox.ItemID := ConnMgrItem.PluginID;
if FConnectionProperties.Run = mbOK then begin
with FConnectionProperties do begin
@@ -381,9 +391,7 @@ begin
ConnMgrItem.Username := UserNameEntry.Text;
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
- ConnMgrItem.PluginID := '';
- if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
- ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
+ ConnMgrItem.PluginID := PluginComboBox.ItemID;
end;
Item.SetValue(1, ConnMgrItem.ConnectionName);
Item.SetValue(2, FConnectionProperties.MakeURI(True));
@@ -407,13 +415,9 @@ begin
FConnectionProperties := TFConnectionProperties.Create(Self);
FConnectionProperties.NameEntry.Text := '';
FConnectionProperties.URIEntry.Text := ConstructURI(True, False, ConnMgrItem.ServiceType, ConnMgrItem.Server, ConnMgrItem.Username, ConnMgrItem.Password, ConnMgrItem.TargetDir);
- FConnectionProperties.ServiceTypeOptionMenuChanged(Sender);
+ FConnectionProperties.ServiceTypeComboBoxChanged(Sender);
// Find the plugin by PluginID
- for i := 0 to FConnectionProperties.PluginOptionMenu.Items.Count - 1 do
- if (FConnectionProperties.PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(FConnectionProperties.PluginOptionMenu.Items[i].Data).ModuleID = ConnMgrItem.PluginID) then begin
- FConnectionProperties.PluginOptionMenu.ItemIndex := i;
- Break;
- end;
+ FConnectionProperties.PluginComboBox.ItemID := ConnMgrItem.PluginID;
if FConnectionProperties.Run = mbOK then begin
ConnMgrItem := TConnMgrItem.Create;
@@ -424,9 +428,7 @@ begin
ConnMgrItem.Username := UserNameEntry.Text;
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
- ConnMgrItem.PluginID := '';
- if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
- ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
+ ConnMgrItem.PluginID := PluginComboBox.ItemID;
end;
ConnectionMgrList.Add(ConnMgrItem);
Item := ListView.Items.Add;
@@ -581,7 +583,7 @@ begin
if res <> mbYes then Exit;
end;
- ListViewTable.Enabled := False;
+ ListViewGrid.Enabled := False;
CloseButton.Enabled := False;
ConnectButton.Enabled := False;
ConnectButton.Visible := False;
@@ -604,7 +606,7 @@ begin
if not DoConnectInternal(UTF8ToStr(FActiveConnInfo.GetURI(False)), Engine, Self, False, @Error) then begin
if not FSilenceError then
ShowError(Self, 'Couldn''t open the URI specified', Error);
- ListViewTable.Enabled := True;
+ ListViewGrid.Enabled := True;
CloseButton.Enabled := True;
ConnectButton.Enabled := True;
ConnectButton.Visible := True;