source: trunk/WETC/WETC_main.cxx

Last change on this file was 19613, checked in by westram, 8 days ago
  • reintegrates 'lib' into 'trunk'
    • replace dynamic library AWT by several static libraries: APP, ARB_SPEC, MASKS, CANVAS, MAPKEY, GUI_TK
    • now also check wrong library dependencies for untested units (only4me)
  • adds: log:branches/lib@19578:19612
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
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 <app.hxx>
12
13#include <asciiprint.hxx>
14
15#include <aw_window.hxx>
16#include <aw_root.hxx>
17#include <aw_question.hxx>
18
19#include <arbdb.h>
20
21AW_HEADER_MAIN
22
23
24int ARB_main(int argc, char *argv[]) {
25    GB_ERROR error = NULp;
26
27    if (argc < 3) {
28        error = "Missing arguments";
29    }
30    else {
31        const char *cmd      = argv[1];
32        const char *param    = argv[2];
33        const char *option   = NULp;
34        const char *optparam = NULp;
35
36        enum { UNKNOWN, FILEEDIT, NOTIFY } mode = UNKNOWN;
37
38        if      (strcmp(cmd, "-fileedit") == 0) mode = FILEEDIT;
39        else if (strcmp(cmd, "-notify")   == 0) {
40            mode = NOTIFY;
41            if (argc != 3) {
42                if (argc == 5) {
43                    option   = argv[3];
44                    optparam = argv[4];
45
46                    if (strcmp(option, "-button") != 0) {
47                        error = GBS_global_string("unknown option '%s'", option);
48                    }
49                }
50                else {
51                    error = "invalid number of arguments";
52                }
53            }
54        }
55
56        if (!error) {
57            if (mode == UNKNOWN) {
58                error = GBS_global_string("Unexpected parameter '%s'", cmd);
59            }
60            else {
61                GB_shell shell;
62                AW_root *aw_root = AWT_create_root("ntree.arb", "ARB_WETC", new NullTracker); // no macro recording here
63
64                switch (mode) {
65                    case FILEEDIT:
66                        AWT_show_file(aw_root, param);
67                        break;
68
69                    case NOTIFY: {
70                        aw_question(NULp, param, option ? optparam : "Ok", true, NULp);
71                        break;
72                    }
73
74                    case UNKNOWN:
75                        arb_assert(0); // should not be reached!
76                        break;
77                }
78
79                aw_root->window_hide(NULp);
80                AWT_install_cb_guards();
81                aw_root->main_loop();
82            }
83        }
84    }
85
86    if (error) {
87        fprintf(stderr,
88                "arb_wetc -- ARB Window Environment To CLI -- start GUI tasks from CLI\n"
89                "\n"
90                "Syntax: arb_wetc -fileedit filename\n"
91                "        edit a file before sending it to printer.\n"
92                "\n"
93                "Syntax: arb_wetc -notify message [-button buttontext]\n"
94                "        display a message. Allow user to press OK button.\n"
95                "\n"
96                "Error: %s\n",
97                error);
98        return EXIT_FAILURE;
99    }
100
101    return EXIT_SUCCESS;
102}
103
Note: See TracBrowser for help on using the repository browser.