]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/surfacedialog.cpp
GTK: wrap gtk_box_pack_start
[xonotic/netradiant.git] / radiant / surfacedialog.cpp
index ab0fc4fc75ea6b3d803536686ad4343b9c5daaeb..ad0f735928d33c14ad7591354ddb0dd902a0f60d 100644 (file)
@@ -122,7 +122,7 @@ float& m_f;
 public:
 GtkSpinButton* m_spin;
 ui::Entry m_entry;
-Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( nullptr ){
+Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( ui::null ){
 }
 void cancel(){
        entry_set_float( m_entry, m_f );
@@ -159,7 +159,7 @@ GtkCheckButton* m_surfaceFlags[32];
 GtkCheckButton* m_contentFlags[32];
 
 NonModalEntry m_valueEntry;
-ui::Entry m_valueEntryWidget{nullptr};
+ui::Entry m_valueEntryWidget{ui::null};
 public:
 WindowPositionTracker m_positionTracker;
 WindowPositionTrackerImportStringCaller m_importPosition;
@@ -174,7 +174,7 @@ Increment m_vshiftIncrement;
 Increment m_hscaleIncrement;
 Increment m_vscaleIncrement;
 Increment m_rotateIncrement;
-GtkEntry* m_texture;
+ui::Entry m_texture{ui::null};
 
 SurfaceInspector() :
        m_textureEntry( ApplyShaderCaller( *this ), UpdateCaller( *this ) ),
@@ -210,8 +210,8 @@ void constructWindow( ui::Window main_window ){
 void destroyWindow(){
        Destroy();
 }
-bool visible() const {
-       return gtk_widget_get_visible( GetWidget() );
+bool visible() {
+       return GetWidget().visible();
 }
 void queueDraw(){
        if ( visible() ) {
@@ -593,25 +593,25 @@ ui::Window SurfaceInspector::BuildDialog(){
 
        {
                // replaced by only the vbox:
-               ui::Widget vbox = ui::VBox( FALSE, 5 );
+               auto vbox = ui::VBox( FALSE, 5 );
                vbox.show();
                window.add(vbox);
                gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
 
                {
-                       ui::Widget hbox2 = ui::HBox( FALSE, 5 );
+                       auto hbox2 = ui::HBox( FALSE, 5 );
                        hbox2.show();
-                       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
+                       vbox.pack_start( hbox2, FALSE, FALSE, 0 );
 
                        {
                                ui::Widget label = ui::Label( "Texture" );
                                label.show();
-                               gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 );
+                               hbox2.pack_start( label, FALSE, TRUE, 0 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
-                               gtk_box_pack_start( GTK_BOX( hbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+                               hbox2.pack_start( entry, TRUE, TRUE, 0 );
                                m_texture = entry;
                                m_textureEntry.connect( entry );
                                GlobalTextureEntryCompletion::instance().connect( entry );
@@ -622,7 +622,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                {
                        ui::Widget table = ui::Table( 6, 4, FALSE );
                        table.show();
-                       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 );
+                       vbox.pack_start( table, FALSE, FALSE, 0 );
                        gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
                        gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
                        {
@@ -652,7 +652,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
                                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1,
                                                                  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
@@ -688,7 +688,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
                                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 1, 2,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -724,7 +724,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                                  (GtkAttachOptions) ( 0 ), 2, 3 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
                                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 2, 3,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -760,7 +760,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
                                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 3, 4,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -797,7 +797,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
                        }
                        {
-                               auto entry = ui::Entry();
+                               auto entry = ui::Entry(ui::New);
                                entry.show();
                                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 4, 5,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -813,14 +813,14 @@ ui::Window SurfaceInspector::BuildDialog(){
                                gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6,
                                                                  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
-                               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 );
+                               button.connect( "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 );
                        }
                }
 
                {
                        auto frame = ui::Frame( "Texturing" );
                        frame.show();
-                       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+                       vbox.pack_start( frame, FALSE, FALSE, 0 );
                        {
                                ui::Widget table = ui::Table( 4, 4, FALSE );
                                table.show();
@@ -862,7 +862,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnAxial ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -872,7 +872,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnFaceFit ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -882,7 +882,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchdetails ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -892,7 +892,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchreset ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -902,7 +902,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchnatural ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -912,7 +912,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                       button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchFit ), 0 );
                                        gtk_widget_set_size_request( button, 60, -1 );
                                }
@@ -940,7 +940,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                        {
                                auto frame = ui::Frame( "Surface Flags" );
                                frame.show();
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+                               vbox.pack_start( frame, TRUE, TRUE, 0 );
                                {
                                        auto vbox3 = ui::VBox( FALSE, 4 );
                                        //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4);
@@ -949,7 +949,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        {
                                                auto table = ui::Table( 8, 4, FALSE );
                                                table.show();
-                                               gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+                                               vbox3.pack_start( table, TRUE, TRUE, 0 );
                                                gtk_table_set_row_spacings( table, 0 );
                                                gtk_table_set_col_spacings( table, 0 );
 
@@ -975,7 +975,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                        {
                                auto frame = ui::Frame( "Content Flags" );
                                frame.show();
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+                               vbox.pack_start( frame, TRUE, TRUE, 0 );
                                {
                                        auto vbox3 = ui::VBox( FALSE, 4 );
                                        //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4);
@@ -985,7 +985,7 @@ ui::Window SurfaceInspector::BuildDialog(){
 
                                                auto table = ui::Table( 8, 4, FALSE );
                                                table.show();
-                                               gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+                                               vbox3.pack_start( table, TRUE, TRUE, 0 );
                                                gtk_table_set_row_spacings( table, 0 );
                                                gtk_table_set_col_spacings( table, 0 );
 
@@ -1014,7 +1014,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                        {
                                auto frame = ui::Frame( "Value" );
                                frame.show();
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+                               vbox.pack_start( frame, TRUE, TRUE, 0 );
                                {
                                        auto vbox3 = ui::VBox( FALSE, 4 );
                                        gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 );
@@ -1022,9 +1022,9 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        frame.add(vbox3);
 
                                        {
-                                               auto entry = ui::Entry();
+                                               auto entry = ui::Entry(ui::New);
                                                entry.show();
-                                               gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+                                               vbox3.pack_start( entry, TRUE, TRUE, 0 );
                                                m_valueEntryWidget = entry;
                                                m_valueEntry.connect( entry );
                                        }
@@ -1037,7 +1037,7 @@ ui::Window SurfaceInspector::BuildDialog(){
 // Shamus: Textool goodies...
                        ui::Widget frame = ui::Frame( "Textool" );
                        frame.show();
-                       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+                       vbox.pack_start( GTK_WIDGET( frame ), FALSE, FALSE, 0 );
                        {
                                //Prolly should make this a member or global var, so the SI can draw on it...
                                TexTool::g_textoolWin = glwidget_new( FALSE );
@@ -1050,34 +1050,34 @@ ui::Window SurfaceInspector::BuildDialog(){
                                gtk_widget_set_size_request( TexTool::g_textoolWin, -1, 240 ); //Yeah!
                                frame.add(TexTool::g_textoolWin);
 
-                               g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL );
-                               g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "expose_event", G_CALLBACK( TexTool::expose ), NULL );
-                               g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_press_event", G_CALLBACK( TexTool::button_press ), NULL );
-                               g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_release_event", G_CALLBACK( TexTool::button_release ), NULL );
-                               g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL );
+                               TexTool::g_textoolWin.connect( "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL );
+                               TexTool::g_textoolWin.connect( "expose_event", G_CALLBACK( TexTool::expose ), NULL );
+                               TexTool::g_textoolWin.connect( "button_press_event", G_CALLBACK( TexTool::button_press ), NULL );
+                               TexTool::g_textoolWin.connect( "button_release_event", G_CALLBACK( TexTool::button_release ), NULL );
+                               TexTool::g_textoolWin.connect( "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL );
                        }
                        {
                                ui::Widget hbox = ui::HBox( FALSE, 5 );
                                hbox.show();
-                               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
+                               vbox.pack_start( GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
                                // Checkboxes go here... (Flip X/Y)
                                ui::Widget flipX = ui::CheckButton( "Flip X axis" );
                                ui::Widget flipY = ui::CheckButton( "Flip Y axis" );
                                flipX.show();
                                flipY.show();
-                               gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 );
-                               gtk_box_pack_start( GTK_BOX( hbox ), flipY, FALSE, FALSE, 0 );
+                               hbox.pack_start( flipX, FALSE, FALSE, 0 );
+                               hbox.pack_start( flipY, FALSE, FALSE, 0 );
 
 //Instead of this, we probably need to create a vbox to put into the frame, then the
 //window, then the hbox. !!! FIX !!!
 //        frame.add(hbox);
 
 //Hmm. Do we really need g_object_set_data? Mebbe not... And we don't! :-)
-//        g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipX), "toggled", G_CALLBACK(TexTool::flipX), 0)));
-//        g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipY), "toggled", G_CALLBACK(TexTool::flipY), 0)));
+//        g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(flipX.connect("toggled", G_CALLBACK(TexTool::flipX), 0)));
+//        g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(flipY.connect("toggled", G_CALLBACK(TexTool::flipY), 0)));
 //Instead, just do:
-                               g_signal_connect( G_OBJECT( flipX ), "toggled", G_CALLBACK( TexTool::flipX ), NULL );
-                               g_signal_connect( G_OBJECT( flipY ), "toggled", G_CALLBACK( TexTool::flipY ), NULL );
+                               flipX.connect( "toggled", G_CALLBACK( TexTool::flipX ), NULL );
+                               flipY.connect( "toggled", G_CALLBACK( TexTool::flipY ), NULL );
                        }
                }
 #endif
@@ -1112,11 +1112,11 @@ void SurfaceInspector::Update(){
        const char * name = SurfaceInspector_GetSelectedShader();
 
        if ( shader_is_texture( name ) ) {
-               gtk_entry_set_text( m_texture, shader_get_textureName( name ) );
+               m_texture.text(shader_get_textureName(name));
        }
        else
        {
-               gtk_entry_set_text( m_texture, "" );
+               m_texture.text("");
        }
 
        texdef_t shiftScaleRotate;