1.1 --- a/desktop/dialog.py Sat Dec 15 18:52:23 2007 +0000
1.2 +++ b/desktop/dialog.py Mon Dec 17 20:15:37 2007 +0000
1.3 @@ -29,7 +29,7 @@
1.4 class:
1.5
1.6 question = desktop.dialog.Question("Are you sure?")
1.7 -question.open()
1.8 +result = question.open()
1.9
1.10 To override the detected desktop, specify the desktop parameter to the open
1.11 function as follows:
1.12 @@ -41,6 +41,9 @@
1.13
1.14 Available dialogue box classes are listed in the desktop.dialog.available
1.15 attribute.
1.16 +
1.17 +Supported desktop environments are listed in the desktop.dialog.supported
1.18 +attribute.
1.19 """
1.20
1.21 from desktop import use_desktop, _run, _readfrom, _status
1.22 @@ -239,6 +242,7 @@
1.23 commands = {
1.24 "KDE" : "kdialog",
1.25 "GNOME" : "zenity",
1.26 + "XFCE" : "zenity", # NOTE: Based on observations with Xubuntu.
1.27 "X11" : "Xdialog"
1.28 }
1.29
1.30 @@ -248,17 +252,18 @@
1.31 Open a dialogue box (dialog) using a program appropriate to the desktop
1.32 environment in use.
1.33
1.34 - If the optional 'desktop' parameter is specified then attempt to use that
1.35 - particular desktop environment's mechanisms to open the dialog instead of
1.36 - guessing or detecting which environment is being used.
1.37 + If the optional 'desktop' parameter is specified then attempt to use
1.38 + that particular desktop environment's mechanisms to open the dialog
1.39 + instead of guessing or detecting which environment is being used.
1.40
1.41 - Suggested values for 'desktop' are "standard", "KDE", "GNOME", "Mac OS X",
1.42 - "Windows".
1.43 + Suggested values for 'desktop' are "standard", "KDE", "GNOME",
1.44 + "Mac OS X", "Windows".
1.45
1.46 The result of the dialogue interaction may be a string indicating user
1.47 - input (for input, password, menu, radiolist, pulldown), a list of strings
1.48 - indicating selections of one or more items (for checklist), or a value
1.49 - indicating true or false (for question).
1.50 + input (for Input, Password, Menu, Pulldown), a list of strings
1.51 + indicating selections of one or more items (for RadioList, CheckList),
1.52 + or a value indicating true or false (for Question, Warning, Message,
1.53 + Error).
1.54 """
1.55
1.56 # Decide on the desktop environment in use.
1.57 @@ -272,6 +277,9 @@
1.58 except KeyError:
1.59 raise OSError, "Desktop '%s' not supported (no known dialogue box command could be suggested)" % desktop_in_use
1.60
1.61 + # The handler is one of the functions communicating with the subprocess.
1.62 + # Some handlers return boolean values, others strings.
1.63 +
1.64 handler, options = self.info[program]
1.65
1.66 cmd = [program]
1.67 @@ -295,6 +303,8 @@
1.68 """
1.69 A dialogue asking a question and showing response buttons.
1.70 Options: text, width (in characters), height (in characters)
1.71 + Response: a boolean value indicating an affirmative response (true) or a
1.72 + negative response
1.73 """
1.74
1.75 name = "question"
1.76 @@ -309,6 +319,8 @@
1.77 """
1.78 A dialogue asking a question and showing response buttons.
1.79 Options: text, width (in characters), height (in characters)
1.80 + Response: a boolean value indicating an affirmative response (true) or a
1.81 + negative response
1.82 """
1.83
1.84 name = "warning"
1.85 @@ -323,6 +335,8 @@
1.86 """
1.87 A message dialogue.
1.88 Options: text, width (in characters), height (in characters)
1.89 + Response: a boolean value indicating an affirmative response (true) or a
1.90 + negative response
1.91 """
1.92
1.93 name = "message"
1.94 @@ -337,6 +351,8 @@
1.95 """
1.96 An error dialogue.
1.97 Options: text, width (in characters), height (in characters)
1.98 + Response: a boolean value indicating an affirmative response (true) or a
1.99 + negative response
1.100 """
1.101
1.102 name = "error"
1.103 @@ -351,7 +367,8 @@
1.104 """
1.105 A menu of options, one of which being selectable.
1.106 Options: text, width (in characters), height (in characters),
1.107 - list_height (in items), items (MenuItem objects)
1.108 + list_height (in items), items (MenuItem objects)
1.109 + Response: a value corresponding to the chosen item
1.110 """
1.111
1.112 name = "menu"
1.113 @@ -393,7 +410,10 @@
1.114 """
1.115 A list of radio buttons, one of which being selectable.
1.116 Options: text, width (in characters), height (in characters),
1.117 - list_height (in items), items (MenuItem objects), titles
1.118 + list_height (in items), items (MenuItem objects), titles
1.119 + Response: a list of values corresponding to chosen items (since some
1.120 + programs, eg. zenity, appear to support multiple default
1.121 + selections)
1.122 """
1.123
1.124 name = "radiolist"
1.125 @@ -414,7 +434,8 @@
1.126 """
1.127 A list of checkboxes, many being selectable.
1.128 Options: text, width (in characters), height (in characters),
1.129 - list_height (in items), items (MenuItem objects), titles
1.130 + list_height (in items), items (MenuItem objects), titles
1.131 + Response: a list of values corresponding to chosen items
1.132 """
1.133
1.134 name = "checklist"
1.135 @@ -435,7 +456,8 @@
1.136 """
1.137 A pull-down menu of options, one of which being selectable.
1.138 Options: text, width (in characters), height (in characters),
1.139 - entries (list of values)
1.140 + items (list of values)
1.141 + Response: a value corresponding to the chosen item
1.142 """
1.143
1.144 name = "pulldown"
1.145 @@ -456,6 +478,7 @@
1.146 """
1.147 An input dialogue, consisting of an input field.
1.148 Options: text, input, width (in characters), height (in characters)
1.149 + Response: the text entered into the dialogue by the user
1.150 """
1.151
1.152 name = "input"
1.153 @@ -477,6 +500,7 @@
1.154 """
1.155 A password dialogue, consisting of a password entry field.
1.156 Options: text, width (in characters), height (in characters)
1.157 + Response: the text entered into the dialogue by the user
1.158 """
1.159
1.160 name = "password"
1.161 @@ -494,6 +518,7 @@
1.162 """
1.163 A text file input box.
1.164 Options: filename, text, width (in characters), height (in characters)
1.165 + Response: any text returned by the dialogue program
1.166 """
1.167
1.168 name = "textfile"
1.169 @@ -513,4 +538,8 @@
1.170
1.171 available = [Question, Warning, Message, Error, Menu, CheckList, RadioList, Input, Password, Pulldown, TextFile]
1.172
1.173 +# Supported desktop environments.
1.174 +
1.175 +supported = Dialogue.commands.keys()
1.176 +
1.177 # vim: tabstop=4 expandtab shiftwidth=4