source: tags/ms_r16q3/AWT/AWT_misc.cxx

Last change on this file was 15269, checked in by westram, 8 years ago
  • cleanup shell/system interface for GUI
    • add wrappers w/o AW_window*-dummy
    • inline GB_xterm in AWT_console
    • replace NT_primer_cb by AWT_system_in_console_cb
    • use AWT_system_cb where suitable
File size: 3.3 KB
Line 
1// ============================================================ //
2//                                                              //
3//   File      : AWT_misc.cxx                                   //
4//   Purpose   :                                                //
5//                                                              //
6//   Coded by Ralf Westram (coder@reallysoft.de) in July 2015   //
7//   http://www.arb-home.de/                                    //
8//                                                              //
9// ============================================================ //
10
11#include "awt_misc.hxx"
12
13#include <arb_strarray.h>
14
15#include <aw_root.hxx>
16#include <aw_window.hxx>
17#include <aw_awar.hxx>
18#include <aw_advice.hxx>
19#include <aw_msg.hxx>
20
21AW_window *AWT_create_IUPAC_info_window(AW_root *aw_root) {
22    // Open window showing IUPAC tables
23    static AW_window_simple *aws = NULL;
24    if (!aws) {
25        aws = new AW_window_simple;
26
27        aws->init(aw_root, "SHOW_IUPAC", "IUPAC info");
28        aws->load_xfig("iupac.fig");
29
30        aws->button_length(7);
31
32        aws->at("ok");
33        aws->callback(AW_POPDOWN);
34        aws->create_button("CLOSE", "CLOSE", "O");
35    }
36    return aws;
37}
38
39void AWT_insert_DBsaveType_selector(AW_window *aww, const char *awar_name) {
40    aww->get_root()->awar_string(awar_name, "b"); // default=save binary database
41
42    aww->label("Type ");
43    aww->create_option_menu(awar_name, true);
44    aww->insert_default_option("Binary",          "B", "b");
45    aww->insert_option        ("Bin (+FastLoad)", "F", "bm");
46    aww->insert_option        ("Ascii",           "A", "a");
47    aww->update_option_menu();
48}
49
50static void warn_compression_type(AW_root*, AW_awar *awar_compression) {
51    if (awar_compression->read_char_pntr()[0]) { // not empty
52        AW_advice("Using extra compression is not compatible with older\n"
53                  "arb-versions (prior to arb 6.1)!\n"
54                  "\n"
55                  "Databases will fail to load there..",
56                  AW_ADVICE_TOGGLE,
57                  "Extra database compression warning",
58                  NULL);
59    }
60}
61
62void AWT_insert_DBcompression_selector(AW_window *aww, const char *awar_name) {
63    AW_awar *awar_compression = aww->get_root()->awar_string(awar_name, ""); // default = do not use extra compression
64
65    aww->label("Compression ");
66
67    ConstStrArray compressor;
68    GBT_split_string(compressor, GB_get_supported_compression_flags(true), "=, ", true);
69    arb_assert((compressor.size()%2) == 0); // should contain alternating flag/name entries
70
71    aww->create_option_menu(awar_name, true);
72    aww->insert_default_option("none", "N", "");
73    for (int c = 0; compressor[c]; c += 2) {
74        const char *flag = compressor[c];
75        const char *name = compressor[c+1];
76        arb_assert(strlen(flag) == 1);
77        aww->insert_option(name, NULL, flag);
78    }
79    aww->update_option_menu();
80
81    awar_compression->add_callback(makeRootCallback(warn_compression_type, awar_compression));
82}
83
84void AWT_system_cb(AW_window *, const char *command) {
85    aw_message_if(GBK_system(command));
86}
87void AWT_console(AW_window*) {
88    AWT_system_cb(GBS_global_string("%s &", GB_getenvARB_XTERM()));
89}
90void AWT_system_in_console_cb(AW_window*, const char *command, XCMD_TYPE exectype) {
91    aw_message_if(GB_xcmd(command, exectype));
92}
93
Note: See TracBrowser for help on using the repository browser.