summaryrefslogtreecommitdiff
path: root/UQuickConnect.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UQuickConnect.pas')
-rw-r--r--UQuickConnect.pas117
1 files changed, 59 insertions, 58 deletions
diff --git a/UQuickConnect.pas b/UQuickConnect.pas
index 18725fc..26025ee 100644
--- a/UQuickConnect.pas
+++ b/UQuickConnect.pas
@@ -22,8 +22,8 @@ unit UQuickConnect;
interface
uses
- lazglib2, gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts,
- GTKPixbuf, GTKClasses, GTKMenus,
+ SysUtils, Classes, lazglib2, lazgdk3, lazgtk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls,
+ GTKPixbuf,
UCore, UVFSCore, UEngines, UConnectionManager;
type
@@ -33,12 +33,12 @@ type
TitleEventBox: TGTKEventBox;
TitleIcon: TGTKImage;
TitleHBox: TGTKHBox;
- Table: TGTKTable;
+ Grid: TGTKGrid;
ActionButtonBox: TGTKHButtonBox;
ConnectButton, StopButton, CloseButton: TGTKButton;
Label1, Label2: TGTKLabel;
- URIComboBox: TGTKCombo;
- PluginOptionMenu: TGTKOptionMenu;
+ URIComboBox: TGTKComboBoxEntry;
+ PluginComboBox: TGTKComboBoxText;
procedure FormCreate(Sender: TObject); override;
procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
@@ -68,7 +68,6 @@ uses ULocale, UCoreUtils, UConfig, UConnectionProperties, UGnome, UError;
procedure TFQuickConnect.FormCreate(Sender: TObject);
var i: integer;
- MenuItem: TGTKMenuItem;
begin
SavedData := '';
ConnectedEngine := nil;
@@ -77,13 +76,14 @@ begin
SetDefaultSize(435, 200);
Caption := LANGFQuickConnect_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-close');
+ CloseButton.Caption := 'Close';
+ StopButton := TGTKButton.CreateFromIconName(Self, 'gtk-stop');
+ StopButton.Caption := 'Stop';
StopButton.Visible := False;
StopButton.Enabled := False;
// Default := ConnectButton;
@@ -102,13 +102,15 @@ begin
TitleLabel.Caption := Format('<span size="x-large" weight="ultrabold">%s</span>', [LANGFQuickConnect_TitleLabel_Caption]);
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);
@@ -118,13 +120,16 @@ begin
TitleFrame.AddControl(TitleEventBox);
ClientArea.AddControlEx(TitleFrame, False, True, 0);
- Table := TGTKTable.Create(Self);
- Table.BorderWidth := 25;
- ClientArea.AddControlEx(Table, True, True, 0);
+ Grid := TGTKGrid.Create(Self);
+ Grid.BorderWidth := 25;
+ ClientArea.AddControlEx(Grid, True, True, 0);
- URIComboBox := TGtkCombo.Create(Self);
- URIComboBox.DisableActivate;
- PluginOptionMenu := TGTKOptionMenu.Create(Self);
+ URIComboBox := TGtkComboBoxEntry.Create(Self);
+ URIComboBox.MarginTop := 5;
+ URIComboBox.MarginBottom := 5;
+ PluginComboBox := TGTKComboBoxText.Create(Self);
+ PluginComboBox.MarginTop := 5;
+ PluginComboBox.MarginBottom := 5;
Label1 := TGTKLabel.Create(Self);
Label1.Caption := Format('<span weight="ultrabold">%s</span>', [LANGFQuickConnect_ConnectToURILabel_Caption]);
@@ -132,43 +137,41 @@ begin
Label1.UseMarkup := True;
Label1.UseUnderline := True;
Label1.XAlign := 0;
+ Label1.MarginTop := 2;
+ Label1.MarginBottom := 2;
Label2 := TGTKLabel.Create(Self);
Label2.Caption := LANGConnProp_VFSModule;
- Label2.FocusControl := PluginOptionMenu;
+ Label2.FocusControl := PluginComboBox;
Label2.UseUnderline := True;
Label2.XAlign := 0;
+ Label2.MarginStart := 10;
+ Label2.MarginEnd := 10;
+ Label2.MarginTop := 5;
+ Label2.MarginBottom := 5;
if QuickConnectHistory.Count > 0 then
for i := 0 to QuickConnectHistory.Count - 1 do
- URIComboBox.Items.Append(QuickConnectHistory[i]);
+ URIComboBox.AppendItem(QuickConnectHistory[i]);
URIComboBox.Entry.Text := '';
// Fill the plugins menu
- MenuItem := TGTKMenuItem.CreateTyped(Self, itLabel);
- MenuItem.Caption := LANGConnProp_MenuItemCaption;
- PluginOptionMenu.Items.Add(MenuItem);
+ PluginComboBox.AppendItem(LANGConnProp_MenuItemCaption);
for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).HandlesNetwork then begin
- MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
- MenuItem.Data := PluginList[i];
- MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
- PluginOptionMenu.Items.Add(MenuItem);
- end;
+ if TVFSPlugin(PluginList[i]).HandlesNetwork then
+ PluginComboBox.AppendItemID(TVFSPlugin(PluginList[i]).ModuleID,
+ Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
// Find last used plugin
- if (Length(Trim(ConfQuickConnectPluginID)) > 0) and (PluginOptionMenu.Items.Count > 0) then
- for i := 0 to PluginOptionMenu.Items.Count - 1 do
- if (PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(PluginOptionMenu.Items[i].Data).ModuleID = ConfQuickConnectPluginID) then begin
- PluginOptionMenu.ItemIndex := i;
- Break;
- end;
-
-// Table.AddControlEx(1, 1, 2, 1, TGTKEventBox.Create(Self), [taoExpand, taoFill], [taoShrink], 0, 2);
- Table.AddControlEx(0, 0, 2, 1, Label1, [taoShrink, taoFill], [taoShrink], 0, 2);
- Table.AddControlEx(0, 1, 2, 1, URIComboBox, [taoExpand, taoFill], [taoShrink], 0, 5);
- Table.AddControlEx(0, 2, 1, 1, Label2, [taoShrink, taoFill], [taoShrink], 10, 5);
- Table.AddControlEx(1, 2, 1, 1, PluginOptionMenu, [taoExpand, taoFill], [taoShrink], 0, 5);
+ if (Length(Trim(ConfQuickConnectPluginID)) > 0) and (PluginList.Count > 0)
+ then PluginComboBox.ItemID := ConfQuickConnectPluginID
+ else PluginComboBox.ItemIndex := 0;
+
+// Grid.AddControlEx(1, 1, 2, 1, TGTKEventBox.Create(Self), [taoExpand, taoFill], [taoShrink], 0, 2);
+ Grid.AddControl(0, 0, 2, 1, Label1);
+ Grid.AddControl(0, 1, 2, 1, URIComboBox);
+ Grid.AddControl(0, 2, 1, 1, Label2);
+ Grid.AddControl(1, 2, 1, 1, PluginComboBox);
CloseButton.OnClick := @CloseButtonClick;
ConnectButton.OnClick := @ConnectButtonClick;
@@ -184,13 +187,13 @@ end;
procedure TFQuickConnect.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 ConnectButton.Enabled 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 ConnectButton.Enabled then DoConnect;
+ GDK_KEY_Escape: begin
+ Accept := False;
+ if StopButton.Visible then StopButtonClick(Sender)
+ else ModalResult := mbCancel;
+ end;
end;
end;
@@ -199,13 +202,13 @@ var Orig, s: string;
i: integer;
begin
case Key of
- GDK_UP, GDK_DOWN: if Shift = [] then begin
+ GDK_KEY_Up, GDK_KEY_Down: if Shift = [] then begin
Accept := False;
if QuickConnectHistory.Count > 0 then begin
Orig := Trim(URIComboBox.Entry.Text);
i := QuickConnectHistory.IndexOf(Orig);
- if Key = GDK_DOWN then begin
+ if Key = GDK_KEY_Down then begin
if i < 0 then begin
SavedData := Orig;
i := 0;
@@ -238,9 +241,7 @@ procedure TFQuickConnect.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Length(Trim(URIComboBox.Entry.Text)) > 0 then
SaveItemToHistory(URIComboBox.Entry.Text, QuickConnectHistory);
- if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil)
- then ConfQuickConnectPluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID
- else ConfQuickConnectPluginID := '';
+ ConfQuickConnectPluginID := PluginComboBox.ItemID;
end;
procedure TFQuickConnect.FormResponse(Sender: TObject; const ResponseID: integer);
@@ -285,8 +286,8 @@ begin
// Find VFS module to use for this connection
VFSPlugin := nil;
- if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then begin
- VFSPlugin := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data);
+ if Length(PluginComboBox.ItemID) > 0 then begin
+ VFSPlugin := LookupVFSPlugin(PluginComboBox.ItemID);
ConfQuickConnectPluginID := VFSPlugin.ModuleID;
end else ConfQuickConnectPluginID := '';
if VFSPlugin = nil then begin
@@ -315,7 +316,7 @@ begin
if res <> mbYes then Exit;
end;
- Table.Enabled := False;
+ Grid.Enabled := False;
CloseButton.Enabled := False;
ConnectButton.Enabled := False;
ConnectButton.Visible := False;
@@ -337,7 +338,7 @@ begin
if not AFConnectionManager.DoConnectInternal(URI, Engine, Self, True, @Error) then begin
if not AFConnectionManager.FSilenceError then
ShowError(Self, 'Couldn''t open the URI specified', Error);
- Table.Enabled := True;
+ Grid.Enabled := True;
CloseButton.Enabled := True;
ConnectButton.Enabled := True;
ConnectButton.Visible := True;