# MateDialog Manual

## Introduction

MateDialog enables you to create the following types of simple dialogue:

- Calendar

- File selection

- List

- Notification icon

- Message

  - Error

  - Information

  - Question

  - Warning

- Progress

- Text entry

- Text information

## Usage

When you write scripts, you can use MateDialog to create simple dialogues that interact graphically with the user, as follows:

- You can create a dialogue to obtain information from the user. For example, you can prompt the user to select a date from a calendar dialogue, or to select a file from a file selection dialogue.

- You can create a dialogue to provide the user with information. For example, you can use a progress dialogue to indicate the current status of an operation, or use a warning message dialogue to alert the user.

When the user closes the dialog, MateDialog prints the text produced by the dialog to standard output.

When you write MateDialog commands, ensure that you place quotation marks around each argument.

For example, use:

    matedialog --calendar --title="Holiday Planner"

Do not use:

    matedialog --calendar --title=Holiday Planner

If you do not use quotation marks, you might get unexpected results.

### Access Keys

An access key is a key that enables you to perform an action from the keyboard rather than use the mouse to choose a command from a menu or dialogue. Each access key is identified by an underlined letter on a menu or dialogue option.

Some MateDialog dialogues support the use of access keys. To specify the character to use as the access key, place an underscore before that character in the text of the dialogue. The following example shows how to specify the letter 'C' as the access key:

    "_Choose a name".

### Exit Codes

MateDialog returns the following exit codes:

Exit Code | Description
`0` | The user has pressed either OK or Close.
`1` | The user has either pressed Cancel, or used the window functions to close the dialogue.
`-1` | An unexpected error has occurred.
`5` | The dialogue has been closed because the timeout has been reached.

### General Options

All MateDialog dialogues support the following general options:

`--title`=`title`

- Specifies the title of a dialogue.

`--window-icon`=`icon_path`

- Specifies the icon that is displayed in the window frame of the dialogue. There are 4 stock icons also available by providing the following keywords - 'info', 'warning', 'question' and 'error'.

`--width`=`width`

- Specifies the width of the dialogue.

`--height`=`height`

- Specifies the height of the dialogue.

`--timeout`=`timeout`

- Specifies the timeout in seconds after which the dialogue is closed.

### Help Options

MateDialog provides the following help options:

`--help`

- Displays shortened help text.

`--help-all`

- Displays full help text for all dialogues.

`--help-general`

- Displays help text for general dialogue options.

`--help-calendar`

- Displays help text for calendar dialogue options.

`--help-entry`

- Displays help text for text entry dialogue options.

`--help-error`

- Displays help text for error dialogue options.

`--help-info`

- Displays help text for information dialogue options.

`--help-file-selection`

- Displays help text for file selection dialogue options.

`--help-list`

- Displays help text for list dialogue options.

`--help-notification`

- Displays help text for notification icon options.

`--help-progress`

- Displays help text for progress dialogue options.

`--help-question`

- Displays help text for question dialogue options.

`--help-warning`

- Displays help text for warning dialogue options.

`--help-text-info`

- Displays help for text information dialogue options.

`--help-misc`

- Displays help for miscellaneous options.

`--help-gtk`

- Displays help for GTK+ options.

### Miscellaneous Options

MateDialog also provides the following miscellaneous options:

`--about`

- Displays the About MateDialog dialogue, which contains MateDialog version information, copyright information and developer information.

`--version`

- Displays the version number of MateDialog.

### GTK+ Options

MateDialog supports the standard GTK+ options. For more information about the GTK+ options, execute the `matedialog -?` command.

### Environment Variables

Normally, MateDialog detects the terminal window from which it was launched and keeps itself above that window. This behavior can be disabled by unsetting the `WINDOWID` environment variable.

## Calendar Dialogue

Use the `--calendar` option to create a calendar dialog. MateDialog returns the selected date to standard output. If no date is specified on the command line, the dialog uses the current date.

The calendar dialogue supports the following options:

`--text`=`text`

- Specifies the text that is displayed in the calendar dialogue.

`--day`=`day`

- Specifies the day that is selected in the calendar dialogue. `day` must be a number between 1 and 31 inclusive.

`--month`=`month`

- Specifies the month that is selected in the calendar dialogue. `month` must be a number between 1 and 12 inclusive.

`--year`=`year`

- Specifies the year that is selected in the calendar dialogue.

`--date-format`=`format`

- Specifies the format that is returned from the calendar dialogue after date selection. The default format depends on your locale. `format` must be a format that is acceptable to the `strftime` function, for example `%A %d/%m/%y`.

The following example script shows how to create a calendar dialog:

            #!/bin/sh

            if matedialog --calendar \
            --title="Select a Date" \
            --text="Click on a date to select that date." \
            --day=10 --month=8 --year=2004
              then echo $?
              else echo "No date selected"
            fi

### Calendar Dialogue Example

MateDialog calendar dialog example

## File Selection Dialogue

Use the `--file-selection` option to create a file selection dialog. MateDialog returns the selected files or directories to standard output. The default mode of the file selection dialog is open.

The file selection dialogue supports the following options:

`--filename`=`filename`

- Specifies the file or directory that is selected in the file selection dialogue when the dialogue is first shown.

`--multiple`

- Allows the selection of multiple filenames in the file selection dialogue.

`--directory`

- Allows only selection of directories in the file selection dialogue.

`--save`

- Set the file selection dialogue into save mode.

`--separator`=`separator`

- Specifies the string that is used to divide the returned list of filenames.

The following example script shows how to create a file selection dialog:

            #!/bin/sh

            FILE=`matedialog --file-selection --title="Select a File"`

            case $? in
                     0)
                            echo "\"$FILE\" selected.";;
                     1)
                            echo "No file selected.";;
                    -1)
                            echo "No file selected.";;
            esac

### File Selection Dialogue Example

MateDialog file selection dialog example

## Notification Icon

`--text`=`text`

- Specifies the text that is displayed in the notification area.

The following example script shows how to create a notification icon:

            #!/bin/sh

            matedialog --notification\
              --window-icon="info" \
              --text="There are system updates necessary!"

### Notification Icon Example

MateDialog notification icon example

## List Dialogue

Use the `--list` option to create a list dialog. MateDialog returns the entries in the first column of text of selected rows to standard output.

Data for the dialogue must specified column by column, row by row. Data can be provided to the dialogue through standard input. Each entry must be separated by a newline character.

If you use the `--checklist` or `--radiolist` options, each row must start with either 'TRUE' or 'FALSE'.

The list dialogue supports the following options:

`--column`=`column`

- Specifies the column headers that are displayed in the list dialogue. You must specify a `--column` option for each column that you want to display in the dialogue.

`--checklist`

- Specifies that the first column in the list dialogue contains check boxes.

`--radiolist`

- Specifies that the first column in the list dialogue contains radio boxes.

`--editable`

- Allows the displayed items to be edited.

`--separator`=`separator`

- Specifies what string is used when the list dialogue returns the selected entries.

`--print-column`=`column`

- Specifies what column should be printed out upon selection. The default column is '1'. 'ALL' can be used to print out all columns in the list.

The following example script shows how to create a list dialog:

            #!/bin/sh

            matedialog --list \
              --title="Choose the Bugs You Wish to View" \
              --column="Bug Number" --column="Severity" --column="Description" \
                992383 Normal "GtkTreeView crashes on multiple selections" \
                293823 High "MATE Dictionary does not handle proxy" \
                393823 Critical "Menu editing does not work in MATE 2.0"

### List Dialogue Example

MateDialog list dialog example

## Message Dialogues

MateDialog can create four types of message dialogue:

- Error

- Information

- Question

- Warning

For each type, use the `--text` option to specify the text that is displayed in the dialogue.

### Error Dialogue

Use the `--error` option to create an error dialogue.

The following example script shows how to create an error dialog:

              #!/bin/bash

              matedialog --error \
              --text="Could not find /var/log/syslog."

#### Error Dialogue Example

MateDialog error dialog example

### Information Dialogue

Use the `--info` option to create an information dialogue.

The following example script shows how to create an information dialog:

              #!/bin/bash

              matedialog --info \
              --text="Merge complete. Updated 3 of 10 files."

#### Information Dialogue Example

MateDialog information dialog example

### Question Dialogue

Use the `--question` option to create a question dialogue.

The following example script shows how to create a question dialog:

              #!/bin/bash

              matedialog --question \
              --text="Are you sure you wish to proceed?"

#### Question Dialogue Example

MateDialog question dialog example

### Warning Dialogue

Use the `--warning` option to create a warning dialogue.

The following example script shows how to create a warning dialog:

              #!/bin/bash

              matedialog --warning \
              --text="Disconnect the power cable to avoid electrical shock."

#### Warning Dialogue Example

MateDialog warning dialog example

## Progress Dialogue

Use the `--progress` option to create a progress dialogue.

MateDialog reads data from standard input line by line. If a line is prefixed with #, the text is updated with the text on that line. If a line contains only a number, the percentage is updated with that number.

The progress dialogue supports the following options:

`--text`=`text`

- Specifies the text that is displayed in the progress dialogue.

`--percentage`=`percentage`

- Specifies the initial percentage that is set in the progress dialogue.

`--auto-close`

- Closes the progress dialogue when 100% has been reached.

`--pulsate`

- Specifies that the progress bar pulsates until an EOF character is read from standard input.

The following example script shows how to create a progress dialog:

            #!/bin/sh
            (
            echo "10" ; sleep 1
            echo "# Updating mail logs" ; sleep 1
            echo "20" ; sleep 1
            echo "# Resetting cron jobs" ; sleep 1
            echo "50" ; sleep 1
            echo "This line will just be ignored" ; sleep 1
            echo "75" ; sleep 1
            echo "# Rebooting system" ; sleep 1
            echo "100" ; sleep 1
            ) |
            matedialog --progress \
              --title="Update System Logs" \
              --text="Scanning mail logs..." \
              --percentage=0

            if [ "$?" = -1 ] ; then
                    matedialog --error \
                      --text="Update canceled."
            fi

### Progress Dialogue Example

MateDialog progress dialog example

## Text Entry Dialogue

Use the `--entry` option to create a text entry dialog. MateDialog returns the contents of the text entry to standard output.

The text entry dialogue supports the following options:

`--text`=`text`

- Specifies the text that is displayed in the text entry dialogue.

`--entry-text`=`text`

- Specifies the text that is displayed in the entry field of the text entry dialogue.

`--hide-text`

- Hides the text in the entry field of the text entry dialogue.

The following example script shows how to create a text entry dialog:

            #!/bin/sh

            if matedialog --entry \
            --title="Add an Entry" \
            --text="Enter your _password:" \
            --entry-text "password" \
            --hide-text
              then echo $?
              else echo "No password entered"
            fi

### Text Entry Dialogue Example

MateDialog text entry dialog example

## Text Information Dialogue

Use the `--text-info` option to create a text information dialogue.

The text information dialogue supports the following options:

`--filename`=`filename`

- Specifies a file that is loaded in the text information dialogue.

`--editable`

- Allows the displayed text to be edited. The edited text is returned to standard output when the dialog is closed.

The following example script shows how to create a text information dialog:

            #!/bin/sh

            FILE=`matedialog --file-selection \
              --title="Select a File"`

            case $? in
                     0)
                            matedialog --text-info \
                              --title=$FILE \
                              --filename=$FILE \
                              --editable 2>/tmp/tmp.txt;;
                     1)
                            echo "No file selected.";;
                    -1)
                            echo "No file selected.";;
            esac

### Text Information Dialogue Example

MateDialog text information dialog example