ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/RenegadeMapSelector/RenegadeMapSelector.cpp
Revision: 78
Committed: 2003-03-13T23:29:48-08:00 (22 years, 3 months ago) by douglas
File size: 15775 byte(s)
Log Message:
Put the window centering code back.

File Contents

# User Rev Content
1 douglas 63 // Renegade Map Selector
2     //
3     // Douglas Thrift
4     //
5     // RenegadeMapSelector.cpp
6    
7 douglas 75 #include "RenegadeMapSelector.h"
8     #include "RenegadeConfig.h"
9    
10 douglas 66 #ifdef _WIN32
11     #include <io.h>
12     #include <fcntl.h>
13 douglas 67 #include "resource.h"
14 douglas 75 #else
15     #include "gtk/gtk.h"
16 douglas 66 #endif
17    
18 douglas 63 bool debug = false;
19     string program;
20 douglas 67 RenegadeConfig* config;
21 douglas 63
22 douglas 66 #ifndef _WIN32
23     inline string fix(const string& ansi) { return ansi; }
24 douglas 73 inline void munge(void) { debug = true; }
25 douglas 77
26     void message(const string& text, const string& title, GtkMessageType type);
27 douglas 66 #else
28     inline string fix(const wstring& wide)
29 douglas 63 {
30     char* buffer = new char[wide.length() + 1];
31    
32     WideCharToMultiByte(CP_ACP, 0, wide.c_str(), -1, buffer, wide.length() + 1,
33     NULL, NULL);
34    
35     string ansi = buffer;
36     delete [] buffer;
37    
38     return ansi;
39     }
40    
41 douglas 67 inline void munge(void)
42 douglas 66 {
43 douglas 67 if (debug) return;
44    
45 douglas 66 AllocConsole();
46     SetConsoleTitle("Renegade Map Selector");
47    
48     int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
49     int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
50     int herr = _open_osfhandle(long(GetStdHandle(STD_ERROR_HANDLE)), _O_TEXT);
51    
52     FILE* fin = _fdopen(hin, "r");
53     FILE* fout = _fdopen(hout, "w");
54     FILE* ferr = _fdopen(herr, "w");
55    
56     *stdin = *fin;
57     *stdout = *fout;
58     *stderr = *ferr;
59    
60     setvbuf(stdin, NULL, _IONBF, 0);
61     setvbuf(stdout, NULL, _IONBF, 0);
62     setvbuf(stderr, NULL, _IONBF, 0);
63    
64     cin.sync_with_stdio();
65     cout.sync_with_stdio();
66     cerr.sync_with_stdio();
67 douglas 67
68     debug = true;
69 douglas 66 }
70     #endif
71    
72 douglas 73 #ifdef _WIN32
73 douglas 63 int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
74    
75     int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
76     lpCmdLine, int nShowCmd)
77     {
78     int argc;
79     unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
80 douglas 73 #else
81 douglas 77 void selector(void);
82    
83 douglas 73 int main(int argc, char* argv[])
84     {
85 douglas 75 gtk_init(&argc, &argv);
86 douglas 73 #endif
87 douglas 63
88 douglas 68 string error;
89 douglas 67 string file = "svrcfg_cnc.ini";
90    
91 douglas 66 program = fix(argv[0]);
92 douglas 63
93     for (int index = 1; index < argc; index++)
94     {
95 douglas 66 string arg = fix(argv[index]);
96 douglas 63
97     if (arg == "-D")
98     {
99 douglas 67 munge();
100 douglas 63 }
101 douglas 67 else if (arg == "-file")
102     {
103     if (++index < argc)
104     {
105     file = fix(argv[index]);
106     }
107     else
108     {
109     error = "The argument -file must be followed by a filename.";
110    
111 douglas 73 #ifdef _WIN32
112 douglas 67 MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR);
113 douglas 77 #else
114     message(error, "Bad Arguments", GTK_MESSAGE_ERROR);
115 douglas 73 #endif
116 douglas 67 return 1;
117     }
118     }
119 douglas 63 }
120    
121 douglas 73 #ifdef _WIN32
122 douglas 67 GlobalFree(argv);
123 douglas 73 #endif
124 douglas 63
125 douglas 67 if (debug) cerr << "file = " << file << "\n";
126    
127     config = new RenegadeConfig(file);
128 douglas 68 if (!config->load())
129     {
130     error = "Could not open " + file + ".";
131 douglas 67
132 douglas 73 #ifdef _WIN32
133 douglas 68 MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR);
134 douglas 77 #else
135     message(error, "Bad File", GTK_MESSAGE_ERROR);
136 douglas 73 #endif
137 douglas 68 return 1;
138     }
139    
140 douglas 73 #ifdef _WIN32
141 douglas 63 DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector);
142 douglas 75 #else
143 douglas 77 selector();
144 douglas 73 #endif
145 douglas 63
146 douglas 67 delete config;
147    
148 douglas 73 #ifdef _WIN32
149 douglas 70 if (debug)
150     {
151     cout << "Press enter key to exit . . .";
152     cin.get();
153     }
154 douglas 73 #endif
155 douglas 68
156 douglas 63 return 0;
157     }
158    
159 douglas 73 #ifdef _WIN32
160 douglas 63 int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
161     {
162     switch (uMsg)
163     {
164     case WM_INITDIALOG:
165     {
166 douglas 78 RECT rc, rcDlg, rcDesktop;
167    
168     GetWindowRect(GetDesktopWindow(), &rcDesktop);
169     GetWindowRect(hwndDlg, &rcDlg);
170     CopyRect(&rc, &rcDesktop);
171    
172     OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
173     OffsetRect(&rc, -rc.left, -rc.top);
174     OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
175    
176     SetWindowPos(hwndDlg, HWND_TOP, rcDesktop.left + (rc.right / 2),
177     rcDesktop.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE);
178     }
179     {
180 douglas 63 char* directory = new char[MAX_PATH + 1];
181     GetCurrentDirectory(MAX_PATH + 1, directory);
182 douglas 66 if (debug) cerr << "directory = " << directory << "\n";
183 douglas 63
184     char* data = new char[MAX_PATH + 1];
185     sprintf(data, "%s\\data\\*.mix", directory);
186     delete [] directory;
187 douglas 66 if (debug) cerr << "data = " << data << "\n";
188 douglas 63
189     DlgDirList(hwndDlg, data, IDC_AVAILABLE, 0, DDL_ARCHIVE);
190 douglas 68 SetCurrentDirectory("..");
191 douglas 63
192     delete [] data;
193     }
194 douglas 69 {
195     vector<string> maps = config->getMaps();
196    
197     for (unsigned index = 0; index < maps.size(); index++)
198     {
199     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_ADDSTRING, 0,
200     long(maps[index].c_str()));
201     }
202     }
203 douglas 63 break;
204     case WM_COMMAND:
205     switch (LOWORD(wParam))
206     {
207     case IDOK:
208 douglas 69 if (GetListBoxInfo(GetDlgItem(hwndDlg, IDC_SELECTED)) == 0)
209     {
210     MessageBox(hwndDlg, "You need at least one map.", "No Maps",
211     MB_ICONEXCLAMATION);
212    
213     return false;
214     }
215     else
216     {
217     vector<string> maps;
218    
219     for (unsigned index = 0; index < GetListBoxInfo(GetDlgItem(
220     hwndDlg, IDC_SELECTED)); index++)
221     {
222     char* name = new char[SendMessage(GetDlgItem(hwndDlg,
223     IDC_SELECTED), LB_GETTEXTLEN, index, 0) + 1];
224    
225     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETTEXT,
226     index, long(name));
227     maps.push_back(name);
228    
229     delete [] name;
230     }
231    
232     config->setMaps(maps);
233     }
234 douglas 67 config->save();
235 douglas 63 case IDCANCEL:
236     EndDialog(hwndDlg, wParam);
237     return true;
238 douglas 69 case IDC_ADD_MAP:
239 douglas 70 {
240     unsigned count = SendMessage(GetDlgItem(hwndDlg,
241     IDC_AVAILABLE), LB_GETSELCOUNT, 0, 0);
242     unsigned* additions = new unsigned[count];
243    
244     SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_GETSELITEMS,
245     count, long(additions));
246    
247     if (debug) cerr << "additions = {\n";
248     for (unsigned index = 0; index < count; index++)
249     {
250     if (debug) cerr << " [" << index << "] = " <<
251     additions[index] << "\n";
252    
253     char* name = new char[SendMessage(GetDlgItem(hwndDlg,
254     IDC_AVAILABLE), LB_GETTEXTLEN, additions[index], 0) + 1
255     ];
256    
257     SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_GETTEXT,
258     additions[index], long(name));
259     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
260     LB_ADDSTRING, 0, long(name));
261    
262     delete [] name;
263     }
264     if (debug) cerr << "}\n";
265    
266     delete [] additions;
267    
268     SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_SETSEL,
269     false, -1);
270     EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_MAP), false);
271     }
272 douglas 69 break;
273     case IDC_REMOVE_MAP:
274 douglas 70 {
275     unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
276     LB_GETSELCOUNT, 0, 0);
277     unsigned* removals = new unsigned[count];
278    
279     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS,
280     count, long(removals));
281    
282     if (debug) cerr << "removals = {\n";
283     for (unsigned index = count; index > 0; index--)
284     {
285     if (debug) cerr << " [" << index - 1 << "] = " <<
286     removals[index - 1] << "\n";
287    
288     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
289     LB_DELETESTRING, removals[index - 1], 0);
290     }
291     if (debug) cerr << "}\n";
292    
293     delete [] removals;
294    
295     EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_MAP), false);
296     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false);
297     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false);
298     }
299 douglas 69 break;
300     case IDC_UP_MAP:
301 douglas 74 {
302     unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
303     LB_GETSELCOUNT, 0, 0);
304     unsigned* ups = new unsigned[count];
305    
306     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS,
307     count, long(ups));
308    
309     unsigned insert = ups[0] - 1;
310    
311     if (debug) cerr << "ups = {\n";
312     for (unsigned index = 0; index < count; index++)
313     {
314     if (debug) cerr << " [" << index << "] = " << ups[index]
315     << "\n";
316    
317     char* up = new char[SendMessage(GetDlgItem(hwndDlg,
318     IDC_SELECTED), LB_GETTEXTLEN, ups[index], 0) + 1];
319    
320     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETTEXT,
321     ups[index], long(up));
322     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
323     LB_DELETESTRING, ups[index], 0);
324     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
325     LB_INSERTSTRING, insert, long(up));
326     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_SETSEL,
327     true, insert++);
328     }
329     if (debug) cerr << "}\n";
330    
331     delete [] ups;
332    
333     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
334     LB_GETSEL, 0, 0) == 0)
335     {
336     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), true);
337     }
338     else
339     {
340     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false);
341     }
342    
343     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
344     LB_GETSEL, SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED
345     ), LB_GETCOUNT, 0, 0) - 1, 0) == 0)
346     {
347     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), true);
348     }
349     }
350 douglas 69 break;
351     case IDC_DOWN_MAP:
352 douglas 74 {
353     unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
354     LB_GETSELCOUNT, 0, 0);
355     unsigned* downs = new unsigned[count];
356    
357     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS,
358     count, long(downs));
359    
360     unsigned insert = downs[count - 1] + 1;
361    
362     if (debug) cerr << "downs = {\n";
363     for (unsigned index = count; index > 0; index--)
364     {
365     if (debug) cerr << " [" << index << "] = " << downs[index
366     - 1] << "\n";
367    
368     char* down = new char[SendMessage(GetDlgItem(hwndDlg,
369     IDC_SELECTED), LB_GETTEXTLEN, downs[index - 1], 0) +
370     1];
371    
372     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETTEXT,
373     downs[index - 1], long(down));
374     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
375     LB_DELETESTRING, downs[index - 1], 0);
376     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
377     LB_INSERTSTRING, insert, long(down));
378     SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_SETSEL,
379     true, insert--);
380     }
381     if (debug) cerr << "}\n";
382    
383     delete [] downs;
384    
385     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
386     LB_GETSEL, 0, 0) == 0)
387     {
388     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), true);
389     }
390    
391     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
392     LB_GETSEL, SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED
393     ), LB_GETCOUNT, 0, 0) - 1, 0) == 0)
394     {
395     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), true);
396     }
397     else
398     {
399     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false);
400     }
401     }
402 douglas 69 break;
403     case IDC_AVAILABLE:
404     switch (HIWORD(wParam))
405     {
406     case LBN_SELCHANGE:
407     if (SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE),
408     LB_GETSELCOUNT, 0, 0) > 0)
409     {
410     EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_MAP), true);
411     }
412     else
413     {
414     EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_MAP), false);
415     }
416     break;
417     }
418     break;
419     case IDC_SELECTED:
420     switch (HIWORD(wParam))
421     {
422     case LBN_SELCHANGE:
423     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
424     LB_GETSELCOUNT, 0, 0) > 0)
425     {
426     EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_MAP), true);
427    
428     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
429     LB_GETSEL, 0, 0) == 0)
430     {
431     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), true);
432     }
433     else
434     {
435     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false);
436     }
437    
438     if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
439     LB_GETSEL, SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED
440     ), LB_GETCOUNT, 0, 0) - 1, 0) == 0)
441     {
442     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), true);
443     }
444     else
445     {
446     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false);
447     }
448     }
449     else
450     {
451     EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_MAP), false);
452     EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false);
453     EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false);
454     }
455     break;
456     }
457     break;
458 douglas 63 }
459     break;
460     }
461    
462     return false;
463     }
464 douglas 77 #else
465     static void destruct(GtkWidget* widget, gpointer data)
466     {
467     gtk_main_quit();
468     }
469    
470     static void done(GtkWidget* widget, gpointer data)
471     {
472     if (true)
473     {
474     message("You need at least one map.", "No Maps",
475     GTK_MESSAGE_WARNING);
476     }
477     else
478     {
479     //
480    
481     config->save();
482    
483     gtk_main_quit();
484     }
485     }
486    
487     static void mapAdd(GtkWidget* widget, gpointer data)
488     {
489     cout << "STUB: add\n\a" << flush;
490     }
491    
492     static void mapRemove(GtkWidget* widget, gpointer data)
493     {
494     cout << "STUB: remove\n\a" << flush;
495     }
496    
497     static void mapUp(GtkWidget* widget, gpointer data)
498     {
499     cout << "STUB: up\n\a" << flush;
500     }
501    
502     static void mapDown(GtkWidget* widget, gpointer data)
503     {
504     cout << "STUB: down\n\a" << flush;
505     }
506    
507     void selector(void)
508     {
509     GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
510    
511     gtk_window_set_title(GTK_WINDOW(window), "Renegade Map Selector");
512     gtk_window_set_resizable(GTK_WINDOW(window), false);
513     g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(destruct),
514     NULL);
515    
516     GtkWidget* vertical = gtk_vbox_new(false, 0);
517     GtkWidget* horizontal = gtk_hbox_new(false, 9);
518     GtkWidget* left = gtk_frame_new("Available Maps");
519    
520     gtk_frame_set_label_align(GTK_FRAME(left), 0.5, 0.5);
521     gtk_container_set_border_width(GTK_CONTAINER(left), 6);
522    
523     GtkWidget* center = gtk_vbox_new(true, 0);
524     GtkWidget* top = gtk_vbutton_box_new();
525    
526     gtk_button_box_set_layout(GTK_BUTTON_BOX(top), GTK_BUTTONBOX_START);
527     gtk_box_set_spacing(GTK_BOX(top), 9);
528     gtk_container_set_border_width(GTK_CONTAINER(top), 6);
529    
530     GtkWidget* add = gtk_button_new_with_mnemonic("_Add");
531    
532     g_signal_connect(G_OBJECT(add), "clicked", G_CALLBACK(mapAdd), NULL);
533     gtk_widget_set_sensitive(add, false);
534    
535     GtkWidget* remove = gtk_button_new_with_mnemonic("_Remove");
536    
537     g_signal_connect(G_OBJECT(remove), "clicked", G_CALLBACK(mapRemove), NULL);
538     gtk_widget_set_sensitive(remove, false);
539    
540     GtkWidget* middle = gtk_vbutton_box_new();
541    
542     gtk_button_box_set_layout(GTK_BUTTON_BOX(middle), GTK_BUTTONBOX_END);
543     gtk_box_set_spacing(GTK_BOX(middle), 9);
544     gtk_container_set_border_width(GTK_CONTAINER(middle), 6);
545    
546     GtkWidget* up = gtk_button_new_with_mnemonic("_Up");
547    
548     g_signal_connect(G_OBJECT(up), "clicked", G_CALLBACK(mapUp), NULL);
549     gtk_widget_set_sensitive(up, false);
550    
551     GtkWidget* down = gtk_button_new_with_mnemonic("_Down");
552    
553     g_signal_connect(G_OBJECT(down), "clicked", G_CALLBACK(mapDown), NULL);
554     gtk_widget_set_sensitive(down, false);
555    
556     GtkWidget* right = gtk_frame_new("Selected Maps");
557    
558     gtk_frame_set_label_align(GTK_FRAME(right), 0.5, 0.5);
559     gtk_container_set_border_width(GTK_CONTAINER(right), 6);
560    
561     GtkWidget* separator = gtk_hseparator_new();
562     GtkWidget* bottom = gtk_hbutton_box_new();
563    
564     gtk_button_box_set_layout(GTK_BUTTON_BOX(bottom), GTK_BUTTONBOX_END);
565     gtk_box_set_spacing(GTK_BOX(bottom), 9);
566     gtk_container_set_border_width(GTK_CONTAINER(bottom), 6);
567    
568     GtkWidget* ok = gtk_button_new_from_stock(GTK_STOCK_OK);
569    
570     g_signal_connect(G_OBJECT(ok), "clicked", G_CALLBACK(done), NULL);
571    
572     GtkWidget* cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
573    
574     g_signal_connect(G_OBJECT(cancel), "clicked", G_CALLBACK(destruct), NULL);
575    
576     // pack
577     gtk_container_add(GTK_CONTAINER(vertical), horizontal);
578     gtk_container_add(GTK_CONTAINER(horizontal), left);
579     gtk_container_add(GTK_CONTAINER(horizontal), center);
580     gtk_container_add(GTK_CONTAINER(center), top);
581     gtk_container_add(GTK_CONTAINER(top), add);
582     gtk_container_add(GTK_CONTAINER(top), remove);
583     gtk_container_add(GTK_CONTAINER(center), middle);
584     gtk_container_add(GTK_CONTAINER(middle), up);
585     gtk_container_add(GTK_CONTAINER(middle), down);
586     gtk_container_add(GTK_CONTAINER(horizontal), right);
587     gtk_container_add(GTK_CONTAINER(vertical), separator);
588     gtk_container_add(GTK_CONTAINER(bottom), ok);
589     gtk_container_add(GTK_CONTAINER(bottom), cancel);
590     gtk_container_add(GTK_CONTAINER(vertical), bottom);
591     gtk_container_add(GTK_CONTAINER(window), vertical);
592    
593     // show
594     gtk_widget_show(left);
595     gtk_widget_show(add);
596     gtk_widget_show(remove);
597     gtk_widget_show(top);
598     gtk_widget_show(up);
599     gtk_widget_show(down);
600     gtk_widget_show(middle);
601     gtk_widget_show(center);
602     gtk_widget_show(right);
603     gtk_widget_show(horizontal);
604     gtk_widget_show(separator);
605     gtk_widget_show(ok);
606     gtk_widget_show(cancel);
607     gtk_widget_show(bottom);
608     gtk_widget_show(vertical);
609     gtk_widget_show(window);
610    
611     gtk_main();
612     }
613    
614     void message(const string& text, const string& title, GtkMessageType type)
615     {
616     GtkWidget* box = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type,
617     GTK_BUTTONS_OK, text.c_str());
618    
619     gtk_window_set_title(GTK_WINDOW(box), title.c_str());
620    
621     gtk_dialog_run(GTK_DIALOG(box));
622     gtk_widget_destroy(box);
623     }
624 douglas 73 #endif