Skip to content
Mick Amadio edited this page Mar 26, 2022 · 5 revisions

chooser widget

Gtk2: A GtkFileChooserWidget that uses GtkFileChooser

Gtk2: A GtkFileChooserWidget that uses GtkFileChooser


Definition

<chooser tag_attr="value"...>
	<default>state</default>
	<variable>varname</variable>
    <height>value</height>
    <width>value</width>
	<sensitive>state</sensitive>
	<input>command</input>
	<input file>filename</input>
	<action signal="type">activity</action>...
	<output file>filename</output>
</chooser>

"..." denotes acceptance of multiples of the same thing.

Tag Attributes

See the GtkCheckButton widget and ancestor class properties.

The following custom tag attributes are available:

Name Description Value Since
block-function-signals Block signal emissions from functions true or false 0.7.21
default-file[1] Initial file selection A file absolute path 0.8.5
fs-filters[2] fileselect function pattern file filters `pattern pattern
fs-filters-mime[2] fileselect function mime-type file filters ... (common types) 0.8.5

Directives

Some of these may have tag attribute equivalents.

Name Description Contents Since
default Initial directory A directory path, empty for the run directory
variable Variable name
variable export="false" Variable name, not exported to shell 0.8.3
height[3] Initial minimum height An integer > 0 or -1 to ignore
width[3] Initial minimum width An integer > 0 or -1 to ignore
input[4] Data input source Shell command
input file[4] Data input source Filename 0.8.1
sensitive Sensitive state true or false
action signal="type" Execute command on signal Shell command
action signal="type" Perform function on signal function:parameter
action signal="type" condition="type" Execute command on signal conditionally Shell command 0.8.3
action signal="type" condition="type" Perform function on signal conditionally function:parameter 0.8.3
output file Data output target Filename 0.8.1

Signals

The default signal is "file-activated" (Gtk2, Gtk3) emitted when the user "activates" a file in the file chooser. This can happen by double-clicking on a file in the file list, or by pressing Enter.

The "selection-changed" signal is emitted when there is a change in the set of selected files in the file list.

The "update-preview" signal is emitted when the preview in a file chooser should be regenerated. For example, this can happen when the currently selected file changes. This signal is still emitted even though the current implementation does not display a preview of the selected file.

The "current-folder-changed" signal is emitted when the current folder in a chooser widget changes.

The "confirm-overwrite" signal is emitted whenever it would be appropriate to present a confirmation dialog when the user has selected a file name that already exists. The current implementation never emits this signal.

The following signals are connected-up for all widgets:

Gtk2: button-press-event, button-release-event, configure-event, enter-notify-event, leave-notify-event, focus-in-event, focus-out-event, hide, show, realize, key-press-event, key-release-event, map-event, unmap-event Gtk3: button-press-event, button-release-event, configure-event, enter-notify-event, leave-notify-event, focus-in-event, focus-out-event, hide, show, realize, key-press-event, key-release-event, map-event, unmap-event

Functions

The following functions can be performed upon this widget by any widget capable of emitting signals:

Type Description Parameter Since
enable Sensitise widget Variable name
disable Desensitise widget Variable name
show Show widget Variable name 0.8.1
hide Hide widget Variable name 0.8.1
grabfocus Grab input focus Variable name 0.8.1
refresh Reload input data Variable name
save Save widget data Variable name 0.8.1
clear Remove all widget data Variable name

The following general functions can be performed by any widget capable of emitting signals:

Type Description Parameter Since
break Break out of actions list None 0.8.3
command Execute command Shell command
exit Exit dialog A value for the EXIT variable
closewindow Close dialog Variable name
launch Launch dialog Variable name 0.8.1
presentwindow Present dialog Variable name 0.8.1

Conditions

The following conditions can be used within the condition attribute of action directives:

Type Description Argument Since
active_is_true(argument) Active state of toggle widget Variable name 0.8.3
active_is_false(argument) Active state of toggle widget Variable name 0.8.3
command_is_true(argument) Output of shell command Shell command 0.8.3
command_is_false(argument) Output of shell command Shell command 0.8.3
file_is_true(argument) Contents of a file Filename 0.8.3
file_is_false(argument) Contents of a file Filename 0.8.3
sensitive_is_true(argument) Sensitive state of widget Variable name 0.8.3
sensitive_is_false(argument) Sensitive state of widget Variable name 0.8.3
visible_is_true(argument) Visible state of widget Variable name 0.8.3
visible_is_false(argument) Visible state of widget Variable name 0.8.3
variable_is_true(argument) Value of widget Variable name 0.8.5
variable_is_false(argument) Value of widget Variable name 0.8.5

true means "true", "yes" or a non-zero value, false means "false", "no" or zero, therefore the shell command is expected to echo one of these values to stdout.

Notes

  1. The default file path takes precedence over the default directory. Versions < 0.8.5 ignore this custom tag. Specify both the default file path and the default directory as a fall-back.
  2. Files that match fs-filters are listed after files that match fs-filters-mine.
  3. This widget has no default dimensions. Use the height and/or width directives.
  4. For input and output directives data is always an absolute file path, as it can be set with the default-file custom tag.