]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/sunplug/sunplug.cpp
Wrap g_signal_connect
[xonotic/netradiant.git] / contrib / sunplug / sunplug.cpp
index 9caa98fbba6be68808828836aaeb04bf20120022..6895bf22f38ff6a38d674619dd008f97984ef4e0 100644 (file)
@@ -184,7 +184,7 @@ SunPlugPluginDependencies() :
 //  *************************
 namespace SunPlug
 {
-ui::Window main_window;
+ui::Window main_window{ui::null};
 char MenuList[100] = "";
 
 const char* init( void* hApp, void* pMainWidget ){
@@ -253,19 +253,19 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
 
 // About dialog
 void about_plugin_window(){
-       GtkWidget *window, *vbox, *label, *button;
+       GtkWidget *label, *button;
 
-       window = ui::Window( ui::window_type::TOP ); // create a window
+       auto window = ui::Window( ui::window_type::TOP ); // create a window
        gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
-       g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
-       g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
+       window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
+       window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
        gtk_window_set_title( GTK_WINDOW( window ), "About SunPlug" ); // set the title of the window for the window
        gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
        gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
 
-       vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
-       gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window
+       auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
+       window.add(vbox);
 
        label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label
        gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left
@@ -314,23 +314,23 @@ void GetOptimalCoordinates( AABB *levelBoundingBox ){
 
 // MapCoordinator dialog window
 void MapCoordinator(){
-       GtkWidget *window, *vbox, *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button;
+       GtkWidget *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY;
        Entity *theWorldspawn = NULL;
        const char *buffer;
        char line[20];
 
        // in any case we need a window to show the user what to do
-       window = ui::Window( ui::window_type::TOP ); // create the window
+       auto window = ui::Window( ui::window_type::TOP ); // create the window
        gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
-       g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
-       g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
+       window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
+       window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
        gtk_window_set_title( GTK_WINDOW( window ), "ET-MapCoordinator" ); // set the title of the window for the window
        gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
        gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
 
-       vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
-       gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window
+       auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
+       window.add(vbox);
 
        scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph
        scene::Instance* instance = GlobalSceneGraph().find( path ); // find the instance to the given path
@@ -370,8 +370,8 @@ void MapCoordinator(){
                auto spinner_adj_MaxX = ui::Adjustment( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value
                auto spinner_adj_MaxY = ui::Adjustment( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value
 
-               button = ui::Button( "Get optimal mapcoords" ); // create button with text
-               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
+               auto button = ui::Button( "Get optimal mapcoords" ); // create button with text
+               button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
                gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert button into vbox
 
                gtk_box_pack_start( GTK_BOX( vbox ), gtk_hseparator_new(), FALSE, FALSE, 2 ); // insert separator into vbox
@@ -417,11 +417,11 @@ void MapCoordinator(){
                msp.worldspawn = theWorldspawn;
 
                button = ui::Button( "Set" ); // create button with text
-               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function
+               button.connect( "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function
                gtk_table_attach_defaults( GTK_TABLE( table ), button, 1, 2, 3, 4 ); // insert button into table
 
                button = ui::Button( "Cancel" ); // create button with text
-               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function
+               button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function
                gtk_table_attach_defaults( GTK_TABLE( table ), button, 2, 3, 3, 4 ); // insert button into table
        }
        else {
@@ -431,8 +431,8 @@ void MapCoordinator(){
                gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left
                gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box
 
-               button = ui::Button( "OK" ); // create a button with text
-               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window
+               auto button = ui::Button( "OK" ); // create a button with text
+               button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window
                gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box
        }