4 ### Report a message to the user
6 ### (c) 2008 Straylight/Edgeware
9 ###----- Licensing notice ---------------------------------------------------
11 ### This file is part of the Edgeware X tools collection.
13 ### X tools is free software; you can redistribute it and/or modify
14 ### it under the terms of the GNU General Public License as published by
15 ### the Free Software Foundation; either version 2 of the License, or
16 ### (at your option) any later version.
18 ### X tools is distributed in the hope that it will be useful,
19 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ### GNU General Public License for more details.
23 ### You should have received a copy of the GNU General Public License
24 ### along with X tools; if not, write to the Free Software Foundation,
25 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ###--------------------------------------------------------------------------
30 ### External dependencies.
33 from sys import stdin, stdout, stderr, exit
40 ###--------------------------------------------------------------------------
45 Parse the command line, returning a triple (PARSER, OPTS, ARGS).
48 op = XT.make_optparse \
50 {'action': 'store_const', 'dest': 'type', 'const': 'error',
51 'help': "Mark the window as reporting an error."}),
52 ('I', 'informational',
53 {'action': 'store_const', 'dest': 'type', 'const': 'info',
54 'help': "Mark the window as providing information."}),
56 {'action': 'store_const', 'dest': 'type', 'const': 'question',
57 'help': "Mark the window as asking a question."}),
59 {'action': 'store_const', 'dest': 'type', 'const': 'warning',
60 'help': "Mark the window as giving a warning."}),
63 'help': "Set the window's headline message."}),
65 {'action': 'store_true', 'dest': 'markupp',
66 'help': "Parse message strings for Pango markup."}),
69 'help': "Set the window's title string."})],
71 usage = '%prog [-EIQWm] [-t TITLE] [-d HEADLINE] '
72 'MESSAGE [BUTTONS...]')
74 op.set_defaults(title = 'xmsg',
79 opts, args = op.parse_args()
82 ###--------------------------------------------------------------------------
86 op, opts, args = parse_args()
88 op.print_usage(stderr)
91 ## Sort out the message.
94 if message.startswith('!'):
97 message = stdin.read()
99 ## Display it and retrieve and answer.
101 msg = XT.Message(title = opts.title,
104 headline = opts.headline,
106 markupp = opts.markupp)
107 except ValueError, err:
116 if __name__ == '__main__':
119 ###----- That's all, folks --------------------------------------------------