6 #include "debugging/debugging.h"
10 // stuff from interface.cpp
16 void OnDestroy( ui::Widget w, gpointer data ){
20 void OnExportClicked( ui::Button button, gpointer user_data ){
21 auto window = ui::Window::from(lookup_widget( button , "w_plugplug2" ));
22 ASSERT_TRUE( window );
23 const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true );
28 std::string path( cpath );
30 // get ignore list from ui
31 std::set<std::string> ignore;
33 GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) );
34 ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model( view ));
37 gboolean valid = gtk_tree_model_get_iter_first(list, &iter );
41 gtk_tree_model_get(list, &iter, 0, &data, -1 );
42 globalOutputStream() << data << "\n";
43 ignore.insert( std::string( data ) );
45 valid = gtk_tree_model_iter_next(list, &iter );
48 for ( std::set<std::string>::iterator it( ignore.begin() ); it != ignore.end(); ++it )
49 globalOutputStream() << it->c_str() << "\n";
52 collapsemode mode = COLLAPSE_NONE;
54 GtkWidget* radio = lookup_widget( button , "r_collapse" );
55 ASSERT_NOTNULL( radio );
57 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
62 radio = lookup_widget( button , "r_collapsebymaterial" );
63 ASSERT_NOTNULL( radio );
64 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
65 mode = COLLAPSE_BY_MATERIAL;
69 radio = lookup_widget( button , "r_nocollapse" );
70 ASSERT_NOTNULL( radio );
71 ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) );
77 GtkWidget* toggle = lookup_widget( button , "t_exportmaterials" );
78 ASSERT_NOTNULL( toggle );
80 bool exportmat = FALSE;
82 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggle ) ) ) {
86 // limit material names?
87 toggle = lookup_widget( button , "t_limitmatnames" );
88 ASSERT_NOTNULL( toggle );
90 bool limitMatNames = FALSE;
92 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggle ) ) && exportmat ) {
96 // create objects instead of groups?
97 toggle = lookup_widget( button , "t_objects" );
98 ASSERT_NOTNULL( toggle );
100 bool objects = FALSE;
102 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggle ) ) && exportmat ) {
107 ExportSelection( ignore, mode, exportmat, path, limitMatNames, objects );
110 void OnAddMaterial( ui::Button button, gpointer user_data ){
111 GtkEntry* edit = GTK_ENTRY( lookup_widget( button , "ed_materialname" ) );
112 ASSERT_NOTNULL( edit );
114 const gchar* name = gtk_entry_get_text( edit );
115 if ( g_utf8_strlen( name, -1 ) > 0 ) {
116 ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ) ) );
117 list.append(0, name);
118 gtk_entry_set_text( edit, "" );
122 void OnRemoveMaterial( ui::Button button, gpointer user_data ){
123 GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) );
124 ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) );
125 GtkTreeSelection* sel = gtk_tree_view_get_selection( view );
128 if ( gtk_tree_selection_get_selected( sel, 0, &iter ) ) {
129 gtk_list_store_remove( list, &iter );
133 void OnExportMatClicked( ui::Button button, gpointer user_data ){
134 GtkWidget* toggleLimit = lookup_widget( button , "t_limitmatnames" );
135 GtkWidget* toggleObject = lookup_widget( button , "t_objects" );
137 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) ) ) {
138 gtk_widget_set_sensitive( toggleLimit , TRUE );
139 gtk_widget_set_sensitive( toggleObject , TRUE );
142 gtk_widget_set_sensitive( toggleLimit , FALSE );
143 gtk_widget_set_sensitive( toggleObject , FALSE );