]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/build.cpp
GTK: wrap GTK_WIDGET
[xonotic/netradiant.git] / radiant / build.cpp
index 6820981bf091230d73686fcc3b271f91b3b184fb..d4285bf457cff5d061868254bbc9424be9adc876 100644 (file)
@@ -56,6 +56,7 @@ const char* build_get_variable( const char* name ){
 class Evaluatable
 {
 public:
+virtual ~Evaluatable() = default;
 virtual void evaluate( StringBuffer& output ) = 0;
 virtual void exportXML( XMLImporter& importer ) = 0;
 };
@@ -172,6 +173,7 @@ void exportXML( XMLImporter& importer ){
 class XMLElementParser : public TextOutputStream
 {
 public:
+virtual ~XMLElementParser() = default;
 virtual XMLElementParser& pushElement( const XMLElement& element ) = 0;
 virtual void popElement( const char* name ) = 0;
 };
@@ -294,7 +296,7 @@ void popElement( const char* name ){
 };
 
 typedef std::pair<CopiedString, Build> BuildPair;
-#define SEPARATOR_STRING "-"
+const char *SEPARATOR_STRING = "-";
 static bool is_separator( const BuildPair &p ){
        if ( !string_equal( p.first.c_str(), SEPARATOR_STRING ) ) {
                return false;
@@ -648,15 +650,10 @@ void BSPCommandList_Construct( ui::ListStore store, Project& project ){
 
        for ( Project::iterator i = project.begin(); i != project.end(); ++i )
        {
-               const char* buildName = ( *i ).first.c_str();
-
-               GtkTreeIter buildIter;
-               gtk_list_store_append( store, &buildIter );
-               gtk_list_store_set( store, &buildIter, 0, const_cast<char*>( buildName ), -1 );
+               store.append(0, (*i).first.c_str());
        }
 
-       GtkTreeIter lastIter;
-       gtk_list_store_append( store, &lastIter );
+       store.append();
 }
 
 class ProjectList
@@ -697,8 +694,7 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch
                project.push_back( Project::value_type( new_text, Build() ) );
 
                gtk_list_store_set( projectList->m_store, &iter, 0, new_text, -1 );
-               GtkTreeIter lastIter;
-               gtk_list_store_append( projectList->m_store, &lastIter );
+               projectList->m_store.append();
        }
 
        gtk_tree_path_free( path );
@@ -738,7 +734,7 @@ Build* g_current_build = 0;
 gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore store ){
        Project& project = g_build_project;
 
-       gtk_list_store_clear( store );
+       store.clear();
 
        GtkTreeIter iter;
        GtkTreeModel* model;
@@ -753,12 +749,9 @@ gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore s
 
                        for ( Build::iterator i = build.begin(); i != build.end(); ++i )
                        {
-                               GtkTreeIter commandIter;
-                               gtk_list_store_append( store, &commandIter );
-                               gtk_list_store_set( store, &commandIter, 0, const_cast<char*>( ( *i ).c_str() ), -1 );
+                               store.append(0, (*i).c_str());
                        }
-                       GtkTreeIter lastIter;
-                       gtk_list_store_append( store, &lastIter );
+                       store.append();
                }
                else
                {
@@ -799,8 +792,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc
 
                gtk_list_store_set( store, &iter, 0, new_text, -1 );
 
-               GtkTreeIter lastIter;
-               gtk_list_store_append( store, &lastIter );
+               store.append();
        }
 
        gtk_tree_path_free( path );
@@ -846,22 +838,22 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                auto table1 = create_dialog_table( 2, 2, 4, 4, 4 );
                window.add(table1);
                {
-                       GtkVBox* vbox = create_dialog_vbox( 4 );
-                       gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1,
+                       auto vbox = create_dialog_vbox( 4 );
+                       gtk_table_attach( table1, vbox , 1, 2, 0, 1,
                                                          (GtkAttachOptions) ( GTK_FILL ),
                                                          (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
                        {
-                               GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+                               auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
+                               vbox.pack_start( button, FALSE, FALSE, 0 );
                        }
                        {
-                               GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+                               auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
+                               vbox.pack_start( button, FALSE, FALSE, 0 );
                        }
                }
                {
                        auto frame = create_dialog_frame( "Build menu" );
-                       gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1,
+                       gtk_table_attach( table1, frame , 0, 1, 0, 1,
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
                        {
@@ -898,7 +890,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                }
                {
                        auto frame = create_dialog_frame( "Commandline" );
-                       gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 1, 2,
+                       gtk_table_attach( table1, frame , 0, 1, 1, 2,
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
                        {
@@ -965,7 +957,7 @@ void DoBuildMenu(){
                g_build_changed = true;
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 }
 
 
@@ -1011,9 +1003,9 @@ void Build_constructMenu( ui::Menu menu ){
 
 
 void Build_refreshMenu( ui::Menu menu ){
-       for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
+       for (auto i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
        {
-               gtk_container_remove( menu, GTK_WIDGET( ( *i ).m_item ) );
+               menu.remove(ui::MenuItem(i->m_item));
        }
 
        g_BuildMenuItems.clear();