1 #include "UMPEditor.h"
2 #include "radiant_i18n.h"
3 #include "imaterial.h"
4 #include "gtkutil/MultiMonitor.h"
5 #include "gtkutil/dialog.h"
6 
7 namespace ui
8 {
UMPEditor(const std::string & umpName)9 	UMPEditor::UMPEditor (const std::string& umpName)
10 	{
11 		_view.setUMPFile(umpName);
12 		_dialog = gtk_dialog_new_with_buttons(_("UMP Definition"), GlobalRadiant().getMainWindow(),
13 				GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK,
14 				GTK_RESPONSE_ACCEPT, NULL);
15 
16 		gtk_dialog_set_default_response(GTK_DIALOG(_dialog), GTK_RESPONSE_ACCEPT);
17 
18 		gtk_container_set_border_width(GTK_CONTAINER(_dialog), 12);
19 
20 		gtk_container_add(GTK_CONTAINER(GTK_DIALOG(_dialog)->vbox), _view.getWidget());
21 
22 		GdkRectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalRadiant().getMainWindow());
23 		gtk_window_set_default_size(GTK_WINDOW(_dialog), gint(rect.width / 2), gint(2 * rect.height / 3));
24 	}
25 
~UMPEditor()26 	UMPEditor::~UMPEditor ()
27 	{
28 	}
29 
show()30 	void UMPEditor::show ()
31 	{
32 		gtk_widget_show_all(_dialog);
33 
34 		// Show and block
35 		gint result = gtk_dialog_run(GTK_DIALOG(_dialog));
36 
37 		gtk_widget_destroy(_dialog);
38 
39 		if (result == GTK_RESPONSE_ACCEPT)
40 			_view.save();
41 	}
42 
43 }
44