1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include <stdlib.h>
#include <stdio.h>
#include <gtk--.h>
#include <swmgr.h>
class SimpleFrontEnd : public Gtk_Window {
Gtk_Label l1;
Gtk_Label l2;
Gtk_Label l3;
Gtk_Entry kt;
Gtk_Combo cb;
Gtk_VBox *vb;
Gtk_Text *text;
SWMgr manager;
public:
SimpleFrontEnd() : l1("Module Name:"), l2("KeyText:"), l3(""), kt(), vb(new Gtk_VBox), text(new Gtk_Text) {
add(vb);
vb->pack_start(&l1);
vb->pack_start(&cb);
vb->pack_start(&l2);
vb->pack_start(&kt);
vb->pack_start(&l3);
vb->pack_start(text);
vb->show();
l1.show();
l2.show();
l3.show();
kt.show();
cb.show();
text->set_word_wrap(TRUE);
text->show();
connect_to_method(kt.changed,this,&keypress);
// use SWMgr to traverse installed modules and insert into QComboBox
ModMap::iterator modIterator;
G_List cbItems;
for (modIterator = manager.Modules.begin(); modIterator != manager.Modules.end(); modIterator++)
cbItems.append((void *)modIterator->first.c_str());
cb.set_popdown_strings(cbItems);
}
gint delete_event_impl(GdkEventAny*) {
Gtk_Main::instance()->quit(); return 0;
}
void keypress() {
string keyText;
string modName;
ModMap::iterator it;
gint position=0;
keyText = kt.get_text();
modName = cb.entry.get_text();
it = manager.Modules.find(modName.c_str());
if (it != manager.Modules.end()) {
it->second->SetKey(keyText.c_str());
text->delete_text(0, text->get_length());
text->insert_text((const char *)*it->second, strlen(*it->second), &position);
l3.set(it->second->KeyText());
}
}
};
int main(int argc, char *argv[]) {
Gtk_Main m(&argc,&argv);
SimpleFrontEnd *t=new SimpleFrontEnd;
t->show();
m.run();
printf("After run!\n");
return(EXIT_SUCCESS);
}
|