ARB
Main Page
Namespaces
Classes
Files
File List
File Members
WETC
WETC_main.cxx
Go to the documentation of this file.
1
// ================================================================ //
2
// //
3
// File : WETC_main.cxx //
4
// Purpose : provide minor windowed tasks for CLI //
5
// //
6
// Institute of Microbiology (Technical University Munich) //
7
// http://www.arb-home.de/ //
8
// //
9
// ================================================================ //
10
11
#include <
arbdb.h
>
12
#include <
awt.hxx
>
13
#include <
aw_window.hxx
>
14
#include <
aw_root.hxx
>
15
#include <
aw_question.hxx
>
16
17
AW_HEADER_MAIN
18
19
20
int
ARB_main
(
int
argc,
char
*argv[]) {
21
GB_shell
shell;
22
AW_root
*aw_root =
AWT_create_root
(
"ntree.arb"
,
"ARB_WETC"
,
new
NullTracker
);
// no macro recording here
23
24
GB_ERROR
error
=
NULp
;
25
26
if
(argc < 3) {
27
error =
"Missing arguments"
;
28
}
29
else
{
30
const
char
*cmd = argv[1];
31
const
char
*param = argv[2];
32
const
char
*option =
NULp
;
33
const
char
*optparam =
NULp
;
34
35
enum
{
UNKNOWN
, FILEEDIT, NOTIFY } mode =
UNKNOWN
;
36
37
if
(strcmp(cmd,
"-fileedit"
) == 0) mode = FILEEDIT;
38
else
if
(strcmp(cmd,
"-notify"
) == 0) {
39
mode = NOTIFY;
40
if
(argc != 3) {
41
if
(argc == 5) {
42
option = argv[3];
43
optparam = argv[4];
44
45
if
(strcmp(option,
"-button"
) != 0) {
46
error =
GBS_global_string
(
"unknown option '%s'"
, option);
47
}
48
}
49
else
{
50
error =
"invalid number of arguments"
;
51
}
52
}
53
}
54
55
if
(!error) {
56
if
(mode ==
UNKNOWN
) {
57
error =
GBS_global_string
(
"Unexpected parameter '%s'"
, cmd);
58
}
59
else
{
60
switch
(mode) {
61
case
FILEEDIT:
62
AWT_show_file
(aw_root, param);
63
break
;
64
65
case
NOTIFY: {
66
aw_question
(
NULp
, param, option ? optparam :
"Ok"
,
true
,
NULp
);
67
break
;
68
}
69
70
case
UNKNOWN
:
71
arb_assert
(0);
// should not be reached!
72
break
;
73
}
74
75
aw_root->
window_hide
(
NULp
);
76
AWT_install_cb_guards
();
77
aw_root->
main_loop
();
78
}
79
}
80
}
81
82
if
(error) {
83
fprintf(stderr,
84
"arb_wetc -- ARB Window Environment To CLI -- start GUI tasks from CLI\n"
85
"\n"
86
"Syntax: arb_wetc -fileedit filename\n"
87
" edit a file before sending it to printer.\n"
88
"\n"
89
"Syntax: arb_wetc -notify message [-button buttontext]\n"
90
" display a message. Allow user to press OK button.\n"
91
"\n"
92
"Error: %s\n"
,
93
error);
94
return
EXIT_FAILURE
;
95
}
96
97
return
EXIT_SUCCESS
;
98
}
99
arb_assert
#define arb_assert(cond)
Definition:
arb_assert.h:245
GB_ERROR
const char * GB_ERROR
Definition:
arb_core.h:25
aw_question.hxx
UNKNOWN
Definition:
fun.h:25
GBS_global_string
const char * GBS_global_string(const char *templat,...)
Definition:
arb_msg.cxx:203
arbdb.h
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition:
arb_a2ps.c:154
error
static void error(const char *msg)
Definition:
mkptypes.cxx:96
aw_root.hxx
EXIT_FAILURE
#define EXIT_FAILURE
Definition:
arb_a2ps.c:157
NullTracker
Definition:
aw_root.hxx:76
AW_HEADER_MAIN
#define AW_HEADER_MAIN
Definition:
aw_window.hxx:36
aw_window.hxx
awt.hxx
GB_shell
Definition:
arbdb.h:171
AW_root::main_loop
void main_loop()
Definition:
AW_root.cxx:625
AWT_create_root
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker)
Definition:
AWT_db_browser.cxx:1293
aw_question
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
Definition:
AW_question.cxx:26
AW_root
Definition:
aw_root.hxx:86
NULp
#define NULp
Definition:
cxxforward.h:116
AWT_install_cb_guards
void AWT_install_cb_guards()
Definition:
AWT_db_browser.cxx:1362
ARB_main
AW_HEADER_MAIN int ARB_main(int argc, char *argv[])
Definition:
WETC_main.cxx:20
AW_root::window_hide
void window_hide(AW_window *aww)
Definition:
AW_root.cxx:477
AWT_show_file
void AWT_show_file(AW_root *awr, const char *filename)
Definition:
AWT_asciiprint.cxx:484
Generated by
1.8.8