]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/entityinspector.cpp
Merge branch 'smooth' into 'master'
[xonotic/netradiant.git] / radiant / entityinspector.cpp
index cc0c2008c1ee3f7929d49a403bb9cfdde094282f..82c0bb5f96533254b2c9c32480186a1e5876a222 100644 (file)
@@ -22,6 +22,7 @@
 #include "entityinspector.h"
 
 #include "debugging/debugging.h"
+#include <gtk/gtk.h>
 
 #include "ientity.h"
 #include "ifilesystem.h"
@@ -126,7 +127,7 @@ BooleanAttribute( const char* key ) :
 
        m_check = check;
 
-       guint handler = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( toggled ), this );
+       guint handler = check.connect( "toggled", G_CALLBACK( toggled ), this );
        g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler ) );
 
        update();
@@ -164,7 +165,7 @@ NonModalEntry m_nonModal;
 public:
 StringAttribute( const char* key ) :
        m_key( key ),
-       m_entry( nullptr ),
+       m_entry( ui::null ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
        auto entry = ui::Entry();
        entry.show();
@@ -323,7 +324,7 @@ NonModalEntry m_nonModal;
 public:
 AngleAttribute( const char* key ) :
        m_key( key ),
-       m_entry( nullptr ),
+       m_entry( ui::null ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
        auto entry = numeric_entry_new();
        m_entry = entry;
@@ -370,11 +371,11 @@ ui::Entry m_entry;
 NonModalEntry m_nonModal;
 RadioHBox m_radio;
 NonModalRadio m_nonModalRadio;
-ui::HBox m_hbox{nullptr};
+ui::HBox m_hbox{ui::null};
 public:
 DirectionAttribute( const char* key ) :
        m_key( key ),
-       m_entry( nullptr ),
+       m_entry( ui::null ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
        m_radio( RadioHBox_new( STRING_ARRAY_RANGE( buttons ) ) ),
        m_nonModalRadio( ApplyRadioCaller( *this ) ){
@@ -455,7 +456,7 @@ public:
 ui::Entry m_roll;
 ui::Entry m_pitch;
 ui::Entry m_yaw;
-AnglesEntry() : m_roll( nullptr ), m_pitch( nullptr ), m_yaw( nullptr ){
+AnglesEntry() : m_roll( ui::null ), m_pitch( ui::null ), m_yaw( ui::null ){
 }
 };
 
@@ -545,7 +546,7 @@ public:
 ui::Entry m_x;
 ui::Entry m_y;
 ui::Entry m_z;
-Vector3Entry() : m_x( nullptr ), m_y( nullptr ), m_z( nullptr ){
+Vector3Entry() : m_x( ui::null ), m_y( ui::null ), m_z( ui::null ){
 }
 };
 
@@ -554,7 +555,7 @@ class Vector3Attribute : public EntityAttribute
 CopiedString m_key;
 Vector3Entry m_vector3;
 NonModalEntry m_nonModal;
-ui::Box m_hbox{nullptr};
+ui::Box m_hbox{ui::null};
 public:
 Vector3Attribute( const char* key ) :
        m_key( key ),
@@ -639,10 +640,10 @@ static gboolean changed( GtkComboBox *widget, NonModalComboBox* self ){
 public:
 NonModalComboBox( const Callback& changed ) : m_changed( changed ), m_changedHandler( 0 ){
 }
-void connect( GtkComboBox* combo ){
-       m_changedHandler = g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( changed ), this );
+void connect( ui::ComboBox combo ){
+       m_changedHandler = combo.connect( "changed", G_CALLBACK( changed ), this );
 }
-void setActive( GtkComboBox* combo, int value ){
+void setActive( ui::ComboBox combo, int value ){
        g_signal_handler_disconnect( G_OBJECT( combo ), m_changedHandler );
        gtk_combo_box_set_active( combo, value );
        connect( combo );
@@ -652,7 +653,7 @@ void setActive( GtkComboBox* combo, int value ){
 class ListAttribute : public EntityAttribute
 {
 CopiedString m_key;
-GtkComboBox* m_combo;
+ui::ComboBox m_combo;
 NonModalComboBox m_nonModal;
 const ListAttributeType& m_type;
 public:
@@ -716,8 +717,8 @@ GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS];
 GtkEntry* g_entityKeyEntry;
 GtkEntry* g_entityValueEntry;
 
-ui::ListStore g_entlist_store{nullptr};
-ui::ListStore g_entprops_store{nullptr};
+ui::ListStore g_entlist_store{ui::null};
+ui::ListStore g_entprops_store{ui::null};
 const EntityClass* g_current_flags = 0;
 const EntityClass* g_current_comment = 0;
 const EntityClass* g_current_attributes = 0;
@@ -730,7 +731,7 @@ int spawn_table[MAX_FLAGS];
 // the table is a 4x4 in which we need to put the comment box g_entityClassComment and the spawn flags..
 GtkTable* g_spawnflagsTable;
 
-ui::VBox g_attributeBox{nullptr};
+ui::VBox g_attributeBox{ui::null};
 typedef std::vector<EntityAttribute*> EntityAttributes;
 EntityAttributes g_entityAttributes;
 }
@@ -881,7 +882,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){
                        gtk_table_attach( g_spawnflagsTable, widget, i % 4, i % 4 + 1, i / 4, i / 4 + 1,
                                                          (GtkAttachOptions)( GTK_FILL ),
                                                          (GtkAttachOptions)( GTK_FILL ), 0, 0 );
-                       g_object_unref( widget );
+                       widget.unref();
 
                        gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), str.c_str() );
                }
@@ -1194,7 +1195,7 @@ static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *eve
 static gint EntityClassList_keypress( ui::Widget widget, GdkEventKey* event, gpointer data ){
        unsigned int code = gdk_keyval_to_upper( event->keyval );
 
-       if ( event->keyval == GDK_Return ) {
+       if ( event->keyval == GDK_KEY_Return ) {
                EntityClassList_createEntity();
                return TRUE;
        }
@@ -1260,7 +1261,7 @@ static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){
 }
 
 static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer data ){
-       if ( event->keyval == GDK_Return ) {
+       if ( event->keyval == GDK_KEY_Return ) {
                if ( widget == g_entityKeyEntry ) {
                        gtk_entry_set_text( g_entityValueEntry, "" );
                        gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityValueEntry ) );
@@ -1271,7 +1272,7 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer
                }
                return TRUE;
        }
-       if ( event->keyval == GDK_Escape ) {
+       if ( event->keyval == GDK_KEY_Escape ) {
                gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL );
                return TRUE;
        }
@@ -1292,7 +1293,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
        vbox.show();
        gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 );
 
-       g_signal_connect( G_OBJECT( vbox ), "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
+       vbox.connect( "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
 
        {
                ui::Widget split1 = ui::VPaned();
@@ -1322,8 +1323,8 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        auto view = ui::TreeView( ui::TreeModel( GTK_TREE_MODEL( store ) ));
                                        gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
                                        gtk_tree_view_set_headers_visible( view, FALSE );
-                                       g_signal_connect( G_OBJECT( view ), "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
-                                       g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
+                                       view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
+                                       view.connect( "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
 
                                        {
                                                auto renderer = ui::CellRendererText();
@@ -1332,15 +1333,15 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        }
 
                                        {
-                                               GtkTreeSelection* selection = gtk_tree_view_get_selection( view );
-                                               g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
+                                               auto selection = ui::TreeSelection(gtk_tree_view_get_selection( view ));
+                                               selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
                                        }
 
                                        view.show();
 
                                        scr.add(view);
 
-                                       g_object_unref( G_OBJECT( store ) );
+                                       store.unref();
                                        g_entityClassList = view;
                                        g_entlist_store = store;
                                }
@@ -1385,9 +1386,9 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
 
                                        for ( int i = 0; i < MAX_FLAGS; i++ )
                                        {
-                                               GtkCheckButton* check = ui::CheckButton( "" );
+                                               auto check = ui::CheckButton( "" );
                                                g_object_ref( GTK_WIDGET( check ) );
-                                               g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
+                                               g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( check.connect( "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
                                                g_entitySpawnflagsCheck[i] = check;
                                        }
                                }
@@ -1420,15 +1421,15 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                                }
 
                                                {
-                                                       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
-                                                       g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
+                                                       auto selection = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ));
+                                                       selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
                                                }
 
                                                view.show();
 
                                                scr.add(view);
 
-                                               g_object_unref( G_OBJECT( store ) );
+                                               store.unref();
 
                                                g_entprops_store = store;
                                        }
@@ -1449,7 +1450,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                                                                  (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
                                                                                  (GtkAttachOptions)( 0 ), 0, 0 );
                                                gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK );
-                                               g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+                                               entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
                                                g_entityKeyEntry = entry;
                                        }
 
@@ -1460,7 +1461,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                                                                  (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
                                                                                  (GtkAttachOptions)( 0 ), 0, 0 );
                                                gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK );
-                                               g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+                                               entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
                                                g_entityValueEntry = entry;
                                        }
 
@@ -1491,13 +1492,13 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        {
                                                auto button = ui::Button( "Clear All" );
                                                button.show();
-                                               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
+                                               button.connect( "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
                                                gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 );
                                        }
                                        {
                                                auto button = ui::Button( "Delete Key" );
                                                button.show();
-                                               g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
+                                               button.connect( "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
                                                gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 );
                                        }
                                }