summaryrefslogtreecommitdiff
path: root/UTestPlugin.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-12-24 12:41:48 +0100
committerTomas Bzatek <tbzatek@redhat.com>2025-11-27 19:39:51 +0100
commit1b2b4bb4f3ecc034a6e9364d8768e50b167a9680 (patch)
tree065ddde53b64f7957a30b7dc9d83a748f309868c /UTestPlugin.pas
parentb9703b29819b619037cc282d719c187e51bacd30 (diff)
downloadtuxcmd-1b2b4bb4f3ecc034a6e9364d8768e50b167a9680.tar.xz
Rough GTK3 port
Diffstat (limited to 'UTestPlugin.pas')
-rw-r--r--UTestPlugin.pas127
1 files changed, 87 insertions, 40 deletions
diff --git a/UTestPlugin.pas b/UTestPlugin.pas
index 1673103..5e90de4 100644
--- a/UTestPlugin.pas
+++ b/UTestPlugin.pas
@@ -22,8 +22,7 @@ unit UTestPlugin;
interface
uses
- SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts,
- GTKPixbuf, GTKMenus;
+ SysUtils, Classes, lazgdk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKPixbuf;
type
TFTestPlugin = class(TGTKDialog)
@@ -32,9 +31,9 @@ type
TitleEventBox: TGTKEventBox;
TitleIcon: TGTKImage;
TitleHBox: TGTKHBox;
- Table: TGTKTable;
+ Grid: TGTKGrid;
Label1, Label2, Label3, Label4: TGTKLabel;
- PluginOptionMenu: TGTKOptionMenu;
+ PluginComboBox: TGTKComboBoxText;
CommandEntry, UserEntry, PasswordEntry: TGTKEntry;
ExperimentalWarningLabel: TGTKLabel;
ExperimentalWarningIcon: TGTKImage;
@@ -56,25 +55,26 @@ uses UVFSCore, ULocale;
procedure TFTestPlugin.FormCreate(Sender: TObject);
var i: integer;
- MenuItem: TGTKMenuItem;
+ VBox: TGTKVBox;
begin
SetDefaultSize(400, 200);
Caption := LANGTestPlugin_Caption;
Buttons := [mbOK, mbCancel];
DefaultButton := mbOK;
- ShowSeparator := False;
TitleEventBox := TGTKEventBox.Create(Self);
TitleLabel := TGTKLabel.Create(Self);
TitleLabel.Caption := Format('<span size="x-large" weight="ultrabold">%s</span>', [LANGTestPlugin_Title]);
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-justify-center', isLargeToolbar);
+ TitleIcon.SetFromIconName('gtk-justify-center', isLargeToolbar);
TitleHBox := TGTKHBox.Create(Self);
TitleHBox.Homogeneous := False;
TitleHBox.AddControlEx(TGTKEventBox.Create(Self), False, False, 5);
@@ -86,74 +86,121 @@ begin
HBox4 := TGTKHBox.Create(Self);
HBox4.Homogeneous := False;
+ HBox4.MarginStart := 5;
+ HBox4.MarginEnd := 5;
+ HBox4.MarginTop := 2;
+ HBox4.MarginBottom := 2;
ExperimentalWarningLabel := TGTKLabel.Create(Self);
ExperimentalWarningLabel.Caption := LANGTestPlugin_ExperimentalWarningLabelCaption;
ExperimentalWarningLabel.UseMarkup := True;
ExperimentalWarningLabel.LineWrap := True;
ExperimentalWarningLabel.SetSizeRequest(300, -1);
ExperimentalWarningIcon := TGTKImage.Create(Self);
- ExperimentalWarningIcon.SetFromStock('gtk-dialog-warning', isDialog);
+ ExperimentalWarningIcon.SetFromIconName('gtk-dialog-warning', isDialog);
HBox4.AddControlEx(TGTKEventBox.Create(Self), False, False, 5);
HBox4.AddControlEx(ExperimentalWarningIcon, False, False, 7);
HBox4.AddControlEx(ExperimentalWarningLabel, True, True, 7);
HBox4.AddControlEx(TGTKEventBox.Create(Self), False, False, 8);
- Table := TGTKTable.Create(Self);
- Table.BorderWidth := 20;
- ClientArea.AddControlEx(Table, True, True, 0);
- Table.AddControlEx(0, 0, 2, 1, HBox4, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
- Table.AddControlEx(0, 1, 2, 1, TGTKEventBox.Create(Self), [taoShrink, taoFill], [taoShrink], 5, 10);
+ Grid := TGTKGrid.Create(Self);
+ Grid.BorderWidth := 20;
+ ClientArea.AddControlEx(Grid, True, True, 0);
+ Grid.AddControl(0, 0, 2, 1, HBox4);
+ VBox := TGTKVBox.Create(Self);
+ VBox.MarginStart := 5;
+ VBox.MarginEnd := 5;
+ VBox.MarginTop := 10;
+ VBox.MarginBottom := 10;
+ Grid.AddControl(0, 1, 2, 1, VBox);
Label1 := TGTKLabel.Create(Self);
- Label1.XAlign := 0;
Label1.Caption := LANGTestPlugin_Plugin;
+ Label1.XAlign := 0;
+ Label1.MarginStart := 5;
+ Label1.MarginEnd := 5;
+ Label1.MarginTop := 2;
+ Label1.MarginBottom := 2;
Label2 := TGTKLabel.Create(Self);
- Label2.XAlign := 0;
Label2.Caption := LANGTestPlugin_Command;
- PluginOptionMenu := TGTKOptionMenu.Create(Self);
- Label1.FocusControl := PluginOptionMenu;
+ Label2.XAlign := 0;
+ Label2.MarginStart := 5;
+ Label2.MarginEnd := 5;
+ Label2.MarginTop := 2;
+ Label2.MarginBottom := 2;
+ PluginComboBox := TGTKComboBoxText.Create(Self);
+ PluginComboBox.MarginStart := 5;
+ PluginComboBox.MarginEnd := 5;
+ PluginComboBox.MarginTop := 2;
+ PluginComboBox.MarginBottom := 2;
+ Label1.FocusControl := PluginComboBox;
Label1.UseUnderline := True;
CommandEntry := TGTKEntry.Create(Self);
+ CommandEntry.MarginStart := 5;
+ CommandEntry.MarginEnd := 5;
+ CommandEntry.MarginTop := 2;
+ CommandEntry.MarginBottom := 2;
Label2.FocusControl := CommandEntry;
Label2.UseUnderline := True;
- Table.AddControlEx(0, 2, 1, 1, Label1, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
- Table.AddControlEx(0, 3, 1, 1, Label2, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
- Table.AddControlEx(1, 2, 1, 1, PluginOptionMenu, [taoExpand, taoFill], [taoShrink], 5, 2);
- Table.AddControlEx(1, 3, 1, 1, CommandEntry, [taoExpand, taoFill], [taoShrink], 5, 2);
+ Grid.AddControl(0, 2, 1, 1, Label1);
+ Grid.AddControl(0, 3, 1, 1, Label2);
+ Grid.AddControl(1, 2, 1, 1, PluginComboBox);
+ Grid.AddControl(1, 3, 1, 1, CommandEntry);
Label3 := TGTKLabel.Create(Self);
- Label3.XAlign := 0;
Label3.Caption := LANGTestPlugin_Username;
UserEntry := TGTKEntry.Create(Self);
+ UserEntry.MarginStart := 5;
+ UserEntry.MarginEnd := 5;
+ UserEntry.MarginTop := 2;
+ UserEntry.MarginBottom := 2;
Label3.FocusControl := UserEntry;
Label3.UseUnderline := True;
+ Label3.XAlign := 0;
+ Label3.MarginStart := 5;
+ Label3.MarginEnd := 5;
+ Label3.MarginTop := 2;
+ Label3.MarginBottom := 2;
Label4 := TGTKLabel.Create(Self);
Label4.XAlign := 0;
Label4.Caption := LANGTestPlugin_Password;
+ Label4.MarginStart := 5;
+ Label4.MarginEnd := 5;
+ Label4.MarginTop := 2;
+ Label4.MarginBottom := 2;
PasswordEntry := TGTKEntry.Create(Self);
+ PasswordEntry.MarginStart := 5;
+ PasswordEntry.MarginEnd := 5;
+ PasswordEntry.MarginTop := 2;
+ PasswordEntry.MarginBottom := 2;
Label4.FocusControl := PasswordEntry;
Label4.UseUnderline := True;
AnonymousCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGTestPlugin_AnonymousCheckButton);
AnonymousCheckButton.OnToggled := @AnonymousCheckButtonToggled;
AnonymousCheckButton.Checked := True;
- Table.AddControlEx(0, 4, 2, 1, TGTKEventBox.Create(Self), [taoShrink, taoFill], [taoExpand, taoFill], 5, 4);
- Table.AddControlEx(0, 5, 1, 1, Label3, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
- Table.AddControlEx(1, 5, 1, 1, UserEntry, [taoExpand, taoFill], [taoShrink], 5, 2);
- Table.AddControlEx(0, 6, 1, 1, Label4, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2);
- Table.AddControlEx(1, 6, 1, 1, PasswordEntry, [taoExpand, taoFill], [taoShrink], 5, 2);
- Table.AddControlEx(0, 7, 2, 1, AnonymousCheckButton, [taoExpand, taoFill], [taoShrink], 20, 2);
+ AnonymousCheckButton.MarginStart := 20;
+ AnonymousCheckButton.MarginEnd := 20;
+ AnonymousCheckButton.MarginTop := 2;
+ AnonymousCheckButton.MarginBottom := 2;
+ VBox := TGTKVBox.Create(Self);
+ VBox.MarginStart := 5;
+ VBox.MarginEnd := 5;
+ VBox.MarginTop := 4;
+ VBox.MarginBottom := 4;
+ Grid.AddControl(0, 4, 2, 1, VBox);
+ Grid.AddControl(0, 5, 1, 1, Label3);
+ Grid.AddControl(1, 5, 1, 1, UserEntry);
+ Grid.AddControl(0, 6, 1, 1, Label4);
+ Grid.AddControl(1, 6, 1, 1, PasswordEntry);
+ Grid.AddControl(0, 7, 2, 1, AnonymousCheckButton);
if PluginList.Count = 0 then begin
- MenuItem := TGTKMenuItem.CreateTyped(Self, itLabel);
- MenuItem.Caption := LANGTestPlugin_NoPluginsFound;
- MenuItem.Enabled := False;
- PluginOptionMenu.Items.Add(MenuItem);
+ PluginComboBox.AppendItem(LANGTestPlugin_NoPluginsFound);
+ PluginComboBox.Enabled := False;
end else
for i := 0 to PluginList.Count - 1 do begin
- MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
- MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
- PluginOptionMenu.Items.Add(MenuItem);
+ PluginComboBox.AppendItemID(TVFSPlugin(PluginList[i]).ModuleID,
+ Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
end;
OnKeyDown := @FormKeyDown;
@@ -162,8 +209,8 @@ end;
procedure TFTestPlugin.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
begin
case Key of
- GDK_RETURN, GDK_KP_ENTER: ModalResult := mbOK;
- GDK_ESCAPE: ModalResult := mbCancel;
+ GDK_KEY_Return, GDK_KEY_KP_Enter: ModalResult := mbOK;
+ GDK_KEY_Escape: ModalResult := mbCancel;
end;
end;