6 #include "debugging/debugging.h"
10 // stuff from interface.cpp
16 void OnDestroy( GtkWidget* w, gpointer data ){
20 void OnExportClicked( GtkButton* button, gpointer user_data ){
21 GtkWidget* window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" );
22 ASSERT_NOTNULL( 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( GTK_WIDGET( button ), "t_materialist" ) );
34 GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) );
37 gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter );
41 gtk_tree_model_get( GTK_TREE_MODEL( list ), &iter, 0, &data, -1 );
42 globalOutputStream() << data << "\n";
43 ignore.insert( std::string( data ) );
45 valid = gtk_tree_model_iter_next( GTK_TREE_MODEL( 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( GTK_WIDGET( button ), "r_collapse" );
55 ASSERT_NOTNULL( radio );
57 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
62 radio = lookup_widget( GTK_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( GTK_WIDGET( button ), "r_nocollapse" );
70 ASSERT_NOTNULL( radio );
71 ASSERT_NOTNULL( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) );
77 GtkWidget* toggle = lookup_widget( GTK_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( GTK_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( GTK_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( GtkButton* button, gpointer user_data ){
111 GtkEntry* edit = GTK_ENTRY( lookup_widget( GTK_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 GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) );
118 gtk_list_store_append( list, &iter );
119 gtk_list_store_set( list, &iter, 0, name, -1 );
120 gtk_entry_set_text( edit, "" );
124 void OnRemoveMaterial( GtkButton* button, gpointer user_data ){
125 GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) );
126 GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) );
127 GtkTreeSelection* sel = gtk_tree_view_get_selection( view );
130 if ( gtk_tree_selection_get_selected( sel, 0, &iter ) ) {
131 gtk_list_store_remove( list, &iter );
135 void OnExportMatClicked( GtkButton* button, gpointer user_data ){
136 GtkWidget* toggleLimit = lookup_widget( GTK_WIDGET( button ), "t_limitmatnames" );
137 GtkWidget* toggleObject = lookup_widget( GTK_WIDGET( button ), "t_objects" );
139 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) ) ) {
140 gtk_widget_set_sensitive( GTK_WIDGET( toggleLimit ), TRUE );
141 gtk_widget_set_sensitive( GTK_WIDGET( toggleObject ), TRUE );
144 gtk_widget_set_sensitive( GTK_WIDGET( toggleLimit ), FALSE );
145 gtk_widget_set_sensitive( GTK_WIDGET( toggleObject ), FALSE );