diff options
Diffstat (limited to 'UFileTypeSettings.pas')
| -rw-r--r-- | UFileTypeSettings.pas | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/UFileTypeSettings.pas b/UFileTypeSettings.pas index d6d7eca..f868715 100644 --- a/UFileTypeSettings.pas +++ b/UFileTypeSettings.pas @@ -22,8 +22,8 @@ unit UFileTypeSettings; interface uses - gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKUtils, GTKDialogs, - GTKPixbuf, GTKClasses, UGnome; + SysUtils, Classes, lazgdk3, lazgtk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView, GTKDialogs, GTKPixbuf, + UGnome; type TFFileTypeSettings = class(TGTKDialog) @@ -41,11 +41,11 @@ type AssocListHBox, FNameExtHBox, FNameExtHBox2, ActionsHBox, ActionsHBox2, AssocDescriptionHBox, ColorHBox: TGTKHBox; AddFiletypeButton, RemoveFiletypeButton, AddExtButton, RemoveExtButton, AddActionButton, RemoveActionButton, SetDefaultActionButton, BrowseButton, BrowseIconButton: TGTKButton; - ColorButton: TGnomeColorButton; + ColorButton: TGTKColorButton; FNameExtEntry, CommandEntry, DescriptionEntry, AssocDescriptionEntry, IconEntry: TGTKEntry; RunInTerminalCheckBox, AutodetectCheckBox, DefaultColorCheckBox: TGTKCheckButton; Notebook: TGTKNotebook; - Table, Table2: TGTKTable; + Grid, Grid2: TGTKGrid; Icon: TGTKImage; GnomeIconButton: TGnomeIconEntry; procedure FormCreate(Sender: TObject); override; @@ -100,19 +100,20 @@ begin SetDefaultSize(450, 620); Caption := LANGEditFileTypesCaption; Buttons := [mbOK, mbCancel]; - ShowSeparator := False; TitleEventBox := TGTKEventBox.Create(Self); TitleLabel := TGTKLabel.Create(Self); TitleLabel.Caption := LANGTitleLabel_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-copy', isLargeToolbar); + TitleIcon.SetFromIconName('gtk-copy', isLargeToolbar); TitleHBox := TGTKHBox.Create(Self); TitleHBox.Homogeneous := False; TitleHBox.AddControlEx(TGTKEventBox.Create(Self), False, False, 5); @@ -150,8 +151,10 @@ begin AssocListButtonBox := TGTKHButtonBox.Create(Self); AssocListButtonBox.Layout := blEnd; AssocListButtonBox.Spacing := 2; - AddFiletypeButton := TGTKButton.CreateFromStock(Self, 'gtk-add'); - RemoveFiletypeButton := TGTKButton.CreateFromStock(Self, 'gtk-remove'); + AddFiletypeButton := TGTKButton.CreateFromIconName(Self, 'gtk-add'); + AddFiletypeButton.Caption := 'Add'; + RemoveFiletypeButton := TGTKButton.CreateFromIconName(Self, 'gtk-remove'); + RemoveFiletypeButton.Caption := 'Remove'; AssocListButtonBox.AddControlEx(AddFiletypeButton, False, False, 0); AssocListButtonBox.AddControlEx(RemoveFiletypeButton, False, False, 0); AssocListVBox.AddControlEx(AssocListButtonBox, False, False, 5); @@ -194,8 +197,10 @@ begin ActionsButtonBox2.Layout := blStart; ActionsHBox := TGTKHBox.Create(Self); ActionsHBox2 := TGTKHBox.Create(Self); - AddActionButton := TGTKButton.CreateFromStock(Self, 'gtk-add'); - RemoveActionButton := TGTKButton.CreateFromStock(Self, 'gtk-remove'); + AddActionButton := TGTKButton.CreateFromIconName(Self, 'gtk-add'); + AddActionButton.Caption := 'Add'; + RemoveActionButton := TGTKButton.CreateFromIconName(Self, 'gtk-remove'); + RemoveActionButton.Caption := 'Remove'; SetDefaultActionButton := TGTKButton.Create(Self); SetDefaultActionButton.Caption := LANGSetDefaultActionButton_Caption; RunInTerminalCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGRunInTerminalCheckBox_Caption); @@ -223,19 +228,19 @@ begin DescriptionLabel.XAlign := 0; DescriptionLabel.FocusControl := DescriptionEntry; DescriptionLabel.UseUnderline := True; - Table := TGTKTable.Create(Self); - Table.SetRowColCount(4, 2); - Table.Homogeneous := False; - Table.RowSpacing := 1; - Table.AddControl(0, 0, 1, 1, DescriptionLabel, 0, 0); - Table.AddControl(1, 0, 3, 1, DescriptionEntry, 0, 0); - Table.AddControl(0, 1, 1, 1, CommandLabel, 0, 0); - Table.AddControl(1, 1, 3, 1, CommandEntry, 0, 0); + Grid := TGTKGrid.Create(Self); + Grid.RowHomogeneous := False; + Grid.ColHomogeneous := False; + Grid.RowSpacing := 1; + Grid.AddControl(0, 0, 1, 1, DescriptionLabel); + Grid.AddControl(1, 0, 3, 1, DescriptionEntry); + Grid.AddControl(0, 1, 1, 1, CommandLabel); + Grid.AddControl(1, 1, 3, 1, CommandEntry); ActionsHBox2.Homogeneous := False; ActionsHBox2.AddControlEx(AutodetectCheckBox, True, True, 5); ActionsHBox2.AddControlEx(RunInTerminalCheckBox, True, True, 5); ActionsHBox2.AddControlEx(BrowseButton, False, False, 0); - ActionsVBox.AddControlEx(Table, False, False, 1); + ActionsVBox.AddControlEx(Grid, False, False, 1); ActionsVBox.AddControlEx(ActionsHBox2, False, False, 0); l := TGTKLabel.Create(Self); l.SetSizeRequest(0, 4); @@ -267,8 +272,10 @@ begin FNameExtVBox := TGTKVBox.Create(Self); FNameExtLabel := TGTKLabel.Create(Self); FNameExtLabel.Caption := LANGFNameExtLabel_Caption; - AddExtButton := TGTKButton.CreateFromStock(Self, 'gtk-add'); - RemoveExtButton := TGTKButton.CreateFromStock(Self, 'gtk-remove'); + AddExtButton := TGTKButton.CreateFromIconName(Self, 'gtk-add'); + AddExtButton.Caption := 'Add'; + RemoveExtButton := TGTKButton.CreateFromIconName(Self, 'gtk-remove'); + RemoveExtButton.Caption := 'Remove'; FNameExtEntry := TGTKEntry.Create(Self); FNameExtEntry.SetSizeRequest(0, -1); FNameExtLabel.FocusControl := FNameExtEntry; @@ -294,7 +301,7 @@ begin ColorLabel := TGTKLabel.Create(Self); ColorLabel.Caption := LANGColor; ColorLabel.UseUnderline := True; - ColorButton := TGnomeColorButton.Create(Self); + ColorButton := TGTKColorButton.Create(Self); ColorButton.SetSizeRequest(40, -1); ColorButton.OnColorChanged := @ColorButtonColorChanged; ColorLabel.FocusControl := ColorButton; @@ -325,22 +332,27 @@ begin GnomeIconButton.OnIconChanged := @GnomeIconButtonIconChanged; end; - Table2 := TGTKTable.Create(Self); - Table2.SetRowColCount(8, 3); - Table2.AddControl(0, 1, 1, 1, IconLabel, 10, 0); - if FUseGnomeIconEntry then Table2.AddControl(1, 0, 1, 3, GnomeIconButton, 0, 0); - Table2.AddControl(2, 1, 1, 1, IconFrame, 10, 0); - Table2.AddControl(3, 1, 4, 1, IconEntry, 0, 0); - Table2.AddControl(7, 1, 1, 1, BrowseIconButton, 10, 0); + Grid2 := TGTKGrid.Create(Self); + IconLabel.MarginStart := 10; + IconLabel.MarginEnd := 10; + Grid2.AddControl(0, 1, 1, 1, IconLabel); + if FUseGnomeIconEntry then Grid2.AddControl(1, 0, 1, 3, GnomeIconButton); + IconFrame.MarginStart := 10; + IconFrame.MarginEnd := 10; + Grid2.AddControl(2, 1, 1, 1, IconFrame); + Grid2.AddControl(3, 1, 4, 1, IconEntry); + BrowseIconButton.MarginStart := 10; + BrowseIconButton.MarginEnd := 10; + Grid2.AddControl(7, 1, 1, 1, BrowseIconButton); if FUseGnomeIconEntry then begin - Table2.AddControl(2, 0, 6, 1, TGTKLabel.Create(Self), 0, 0); - Table2.AddControl(2, 2, 6, 1, TGTKLabel.Create(Self), 0, 0); + Grid2.AddControl(2, 0, 6, 1, TGTKLabel.Create(Self)); + Grid2.AddControl(2, 2, 6, 1, TGTKLabel.Create(Self)); end; FNameExtVBox3 := TGTKVBox.Create(Self); FNameExtVBox3.BorderWidth := 10; FNameExtVBox3.AddControlEx(AssocDescriptionHBox, False, False, 5); FNameExtVBox3.AddControlEx(TGTKHSeparator.Create(Self), False, False, 3); - FNameExtVBox3.AddControlEx(Table2, False, False, 1); + FNameExtVBox3.AddControlEx(Grid2, False, False, 1); FNameExtVBox3.AddControlEx(TGTKHSeparator.Create(Self), False, False, 3); FNameExtVBox3.AddControlEx(FNameExtHBox, True, True, 5); Notebook.AppendPage(FNameExtVBox3, LANGNotebookPageExtensions); @@ -374,7 +386,7 @@ end; procedure TFFileTypeSettings.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); begin -// if Key = GDK_ESCAPE then ModalResult := mbCancel; +// if Key = GDK_KEY_Escape then ModalResult := mbCancel; end; procedure TFFileTypeSettings.FormDestroy(Sender: TObject); @@ -521,7 +533,6 @@ var b: boolean; Item: TFileAssoc; i: integer; ListItem: TGTKListItem; - Color: TGDKColor; begin b := Assigned(ListView.Selected) and Assigned(ListView.Selected.AsPointer(2)); RemoveFiletypeButton.Enabled := b and (TFileAssoc(ListView.Selected.AsPointer(2)).FileTypeName <> ConstFTAMetaDirectory) and @@ -547,7 +558,6 @@ begin IconEntry.Text := ''; ActionsListView.Items.Clear; ColorButton.SetDefaultColor; - ColorButton.Color := PGdkColorToGDKColor(GetDefaultBackgroundColor(0)); DefaultColorCheckBox.Checked := True; Exit; end; @@ -562,12 +572,9 @@ begin (TFileAssoc(ListView.Selected.AsPointer(2)).FileTypeName = ConstFTAMetaFile) then AssocDescriptionEntry.Text := ListView.Selected.AsString(0) else AssocDescriptionEntry.Text := ListView.Selected.AsString(1); - DefaultColorCheckBox.Checked := not StringToGDKColor(Item.ColorString, Color); + DefaultColorCheckBox.Checked := Length(Item.ColorString) < 1; if DefaultColorCheckBox.Checked then ColorButton.SetDefaultColor - else begin - ColorButton.UnsetDefaultColor; - ColorButton.Color := Color; - end; + else ColorButton.Color := Item.ColorString; // Actions ActionsListView.Items.Clear; if Item.ActionList.Count > 0 then @@ -629,7 +636,7 @@ end; procedure TFFileTypeSettings.FNameExtEntryKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); begin - if (Key = GDK_RETURN) or (Key = GDK_KP_ENTER) then AddExtButtonClick(Sender); + if (Key = GDK_KEY_Return) or (Key = GDK_KEY_KP_Enter) then AddExtButtonClick(Sender); end; procedure TFFileTypeSettings.FNameExtListViewSelectionChanged(Sender: TObject); @@ -655,7 +662,7 @@ begin b := (ActionsListView.Items.Count > 0) and Assigned(ActionsListView.Selected) and Assigned(ActionsListView.Selected.AsPointer(2)); RemoveActionButton.Enabled := b; SetDefaultActionButton.Enabled := b; - Table.Enabled := b; + Grid.Enabled := b; BrowseButton.Enabled := b; RunInTerminalCheckBox.Enabled := b; AutodetectCheckBox.Enabled := b; @@ -759,13 +766,12 @@ begin end; procedure TFFileTypeSettings.BrowseButtonClick(Sender: TObject); -var Dialog: TGTKFileSelectionDialog; +var Dialog: TGTKFileChooserDialog; begin if (ActionsListView.Items.Count = 0) or (not Assigned(ActionsListView.Selected)) or (not Assigned(ListView.Selected)) or (not Assigned(ListView.Selected.AsPointer(2))) then Exit; - Dialog := TGTKFileSelectionDialog.Create(Self); + Dialog := TGTKFileChooserDialog.Create(Self); try - Dialog.ShowFileOpButtons := False; Dialog.FileName := AppPath; if Byte(Dialog.Run) = 251 then CommandEntry.Text := Dialog.FileName; AppPath := IncludeTrailingPathDelimiter(ExtractFilePath(Dialog.FileName)); @@ -802,12 +808,11 @@ begin end; procedure TFFileTypeSettings.BrowseIconButtonClick(Sender: TObject); -var Dialog: TGTKFileSelectionDialog; +var Dialog: TGTKFileChooserDialog; begin if (not Assigned(ListView.Selected)) or (not Assigned(ListView.Selected.AsPointer(2))) then Exit; - Dialog := TGTKFileSelectionDialog.CreateWithTitle(Self, LANGBrowseForIcon); + Dialog := TGTKFileChooserDialog.CreateWithTitle(Self, LANGBrowseForIcon); try - Dialog.ShowFileOpButtons := False; if FileExists(IconEntry.Text) then Dialog.FileName := IconEntry.Text else Dialog.FileName := IconPath; if Byte(Dialog.Run) = 251 then IconEntry.Text := Dialog.FileName; @@ -820,13 +825,12 @@ end; procedure TFFileTypeSettings.ColorButtonColorChanged(Sender: TObject); begin if Assigned(ListView.Selected) and Assigned(ListView.Selected.AsPointer(2)) then - TFileAssoc(ListView.Selected.AsPointer(2)).ColorString := GDKColorToString(ColorButton.Color); + TFileAssoc(ListView.Selected.AsPointer(2)).ColorString := ColorButton.Color; end; procedure TFFileTypeSettings.DefaultColorCheckBoxToggled(Sender: TObject); begin - if DefaultColorCheckBox.Checked then ColorButton.SetDefaultColor - else ColorButton.UnsetDefaultColor; + if DefaultColorCheckBox.Checked then ColorButton.SetDefaultColor; if DefaultColorCheckBox.Checked and Assigned(ListView.Selected) and Assigned(ListView.Selected.AsPointer(2)) then TFileAssoc(ListView.Selected.AsPointer(2)).ColorString := ''; end; @@ -842,11 +846,11 @@ var ColumnID: integer; begin ColumnID := gtk_tree_view_column_get_sort_column_id(tree_column); ImageCol := False; - if ColumnID = 0 then ImageCol := GTK_IS_CELL_RENDERER_PIXBUF(cell); + if ColumnID = 0 then ImageCol := Assigned(cell); if ImageCol then Exit; Data := nil; - gtk_tree_model_get(tree_model, iter, 2, @Data, -1); - gtk_tree_model_get(tree_model, iter, ColumnID, @s, -1); + gtk_tree_model_get(tree_model, iter, [2, @Data, -1]); + gtk_tree_model_get(tree_model, iter, [ColumnID, @s, -1]); if Assigned(Data) and (Data is TFileAssoc) and ((Data.FileTypeName = ConstFTAMetaDirectory) or (Data.FileTypeName = ConstFTAMetaFile)) then @@ -867,13 +871,13 @@ var ColumnID: integer; begin ColumnID := gtk_tree_view_column_get_sort_column_id(tree_column); ImageCol := False; - if ColumnID = 0 then ImageCol := GTK_IS_CELL_RENDERER_PIXBUF(cell); + if ColumnID = 0 then ImageCol := Assigned(cell); if ImageCol then Exit; Item := TFileAssoc(ListView.Selected.AsPointer(2)); if Item = nil then Exit; Data := nil; - gtk_tree_model_get(tree_model, iter, 2, @Data, -1); - gtk_tree_model_get(tree_model, iter, ColumnID, @s, -1); + gtk_tree_model_get(tree_model, iter, [2, @Data, -1]); + gtk_tree_model_get(tree_model, iter, [ColumnID, @s, -1]); if Assigned(Data) and (Data is TAssocAction) and (Item.ActionList.IndexOf(Data) = Item.DefaultAction) then g_object_set(cell, 'markup', [g_strconcat('<span weight="bold">', s, '</span>', nil), nil]) |
