Skip to content

Commit

Permalink
Add support for handle tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Mar 15, 2024
1 parent 33ae353 commit 4b725dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions filechooser/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const openFileCallName = fileChooserCallName + ".OpenFile"

// OpenFileOptions contains the options for how files are to be selected.
type OpenFileOptions struct {
HandleToken string // A string that will be used as the last element of the handle. Must be a valid object path element.
AcceptLabel string // Label for the accept button. Mnemonic underlines are allowed.
NotModal bool // Whether the dialog should not be modal.
Multiple bool // Whether multiple files can be selected or not.
Expand All @@ -31,6 +32,10 @@ func OpenFile(parentWindow, title string, options *OpenFileOptions) ([]string, e
"directory": dbus.MakeVariant(options.Directory),
}

if options.HandleToken != "" {
data["handle_token"] = dbus.MakeVariant(options.HandleToken)
}

if options.AcceptLabel != "" {
data["accept_label"] = dbus.MakeVariant(options.AcceptLabel)
}
Expand Down
10 changes: 10 additions & 0 deletions filechooser/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (

// SaveFileOptions contains the options for how a file is saved.
type SaveFileOptions struct {
HandleToken string // A string that will be used as the last element of the handle. Must be a valid object path element.
AcceptLabel string // Label for the accept button. Mnemonic underlines are allowed.
NotModal bool // Whether the dialog should not be modal.
CurrentName string // Suggested name of the file.
Expand All @@ -31,6 +32,10 @@ func SaveFile(parentWindow, title string, options *SaveFileOptions) ([]string, e
"modal": dbus.MakeVariant(!options.NotModal),
}

if options.HandleToken != "" {
data["handle_token"] = dbus.MakeVariant(options.HandleToken)
}

if options.AcceptLabel != "" {
data["accept_label"] = dbus.MakeVariant(options.AcceptLabel)
}
Expand All @@ -54,6 +59,7 @@ func SaveFile(parentWindow, title string, options *SaveFileOptions) ([]string, e

// SaveFilesOptions contains the options for how files are saved.
type SaveFilesOptions struct {
HandleToken string // A string that will be used as the last element of the handle. Must be a valid object path element.
AcceptLabel string // Label for the accept button. Mnemonic underlines are allowed.
NotModal bool // Whether the dialog should be modal.
CurrentFolder string // Suggested folder in which the file should be saved.
Expand All @@ -71,6 +77,10 @@ func SaveFiles(parentWindow, title string, options *SaveFilesOptions) ([]string,
"modal": dbus.MakeVariant(!options.NotModal),
}

if options.HandleToken != "" {
data["handle_token"] = dbus.MakeVariant(options.HandleToken)
}

if options.AcceptLabel != "" {
data["accept_label"] = dbus.MakeVariant(options.AcceptLabel)
}
Expand Down

0 comments on commit 4b725dd

Please sign in to comment.