]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/entityinspector.cpp
Remove <gtk/gtk.h> from most of radiant/*
[xonotic/netradiant.git] / radiant / entityinspector.cpp
index 3c21a47d20620fe0116d5455dbceab8965a34c74..a0a3bdfad9aaf830644938013d7b66116909b82a 100644 (file)
@@ -33,7 +33,6 @@
 #include <map>
 #include <set>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
 #include <uilib/uilib.h>
 
 
@@ -64,9 +63,9 @@
 #include "textureentry.h"
 #include "groupdialog.h"
 
-GtkEntry* numeric_entry_new(){
-       GtkEntry* entry = ui::Entry();
-       gtk_widget_show( GTK_WIDGET( entry ) );
+ui::Entry numeric_entry_new(){
+       auto entry = ui::Entry();
+       entry.show();
        gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
        return entry;
 }
@@ -146,11 +145,11 @@ typedef MemberCaller<BooleanAttribute, &BooleanAttribute::apply> ApplyCaller;
 void update(){
        const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
        if ( !string_empty( value ) ) {
-               toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), atoi( value ) != 0 );
+               toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), atoi( value ) != 0 );
        }
        else
        {
-               toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), false );
+               toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), false );
        }
 }
 typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> UpdateCaller;
@@ -160,14 +159,14 @@ typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> UpdateCaller;
 class StringAttribute : public EntityAttribute
 {
 CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
 NonModalEntry m_nonModal;
 public:
 StringAttribute( const char* key ) :
        m_key( key ),
-       m_entry( 0 ),
+       m_entry( nullptr ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
-       GtkEntry* entry = ui::Entry();
+       auto entry = ui::Entry();
        gtk_widget_show( GTK_WIDGET( entry ) );
        gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
 
@@ -319,14 +318,14 @@ inline double angle_normalised( double angle ){
 class AngleAttribute : public EntityAttribute
 {
 CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
 NonModalEntry m_nonModal;
 public:
 AngleAttribute( const char* key ) :
        m_key( key ),
-       m_entry( 0 ),
+       m_entry( nullptr ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
-       GtkEntry* entry = numeric_entry_new();
+       auto entry = numeric_entry_new();
        m_entry = entry;
        m_nonModal.connect( m_entry );
 }
@@ -367,7 +366,7 @@ const String buttons[] = { "up", "down", "z-axis" };
 class DirectionAttribute : public EntityAttribute
 {
 CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
 NonModalEntry m_nonModal;
 RadioHBox m_radio;
 NonModalRadio m_nonModalRadio;
@@ -375,11 +374,11 @@ GtkHBox* m_hbox;
 public:
 DirectionAttribute( const char* key ) :
        m_key( key ),
-       m_entry( 0 ),
+       m_entry( nullptr ),
        m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
        m_radio( RadioHBox_new( STRING_ARRAY_RANGE( buttons ) ) ),
        m_nonModalRadio( ApplyRadioCaller( *this ) ){
-       GtkEntry* entry = numeric_entry_new();
+       auto entry = numeric_entry_new();
        m_entry = entry;
        m_nonModal.connect( m_entry );
 
@@ -453,10 +452,10 @@ typedef MemberCaller<DirectionAttribute, &DirectionAttribute::applyRadio> ApplyR
 class AnglesEntry
 {
 public:
-GtkEntry* m_roll;
-GtkEntry* m_pitch;
-GtkEntry* m_yaw;
-AnglesEntry() : m_roll( 0 ), m_pitch( 0 ), m_yaw( 0 ){
+ui::Entry m_roll;
+ui::Entry m_pitch;
+ui::Entry m_yaw;
+AnglesEntry() : m_roll( nullptr ), m_pitch( nullptr ), m_yaw( nullptr ){
 }
 };
 
@@ -476,19 +475,19 @@ AnglesAttribute( const char* key ) :
 {
        gtk_widget_show( GTK_WIDGET( m_hbox ) );
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_angles.m_pitch = entry;
                m_nonModal.connect( m_angles.m_pitch );
        }
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_angles.m_yaw = entry;
                m_nonModal.connect( m_angles.m_yaw );
        }
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_angles.m_roll = entry;
                m_nonModal.connect( m_angles.m_roll );
@@ -543,10 +542,10 @@ typedef MemberCaller<AnglesAttribute, &AnglesAttribute::update> UpdateCaller;
 class Vector3Entry
 {
 public:
-GtkEntry* m_x;
-GtkEntry* m_y;
-GtkEntry* m_z;
-Vector3Entry() : m_x( 0 ), m_y( 0 ), m_z( 0 ){
+ui::Entry m_x;
+ui::Entry m_y;
+ui::Entry m_z;
+Vector3Entry() : m_x( nullptr ), m_y( nullptr ), m_z( nullptr ){
 }
 };
 
@@ -563,19 +562,19 @@ Vector3Attribute( const char* key ) :
        m_hbox = ui::HBox( TRUE, 4 );
        gtk_widget_show( GTK_WIDGET( m_hbox ) );
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_vector3.m_x = entry;
                m_nonModal.connect( m_vector3.m_x );
        }
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_vector3.m_y = entry;
                m_nonModal.connect( m_vector3.m_y );
        }
        {
-               GtkEntry* entry = numeric_entry_new();
+               auto entry = numeric_entry_new();
                gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
                m_vector3.m_z = entry;
                m_nonModal.connect( m_vector3.m_z );
@@ -717,8 +716,8 @@ GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS];
 GtkEntry* g_entityKeyEntry;
 GtkEntry* g_entityValueEntry;
 
-GtkListStore* g_entlist_store;
-GtkListStore* g_entprops_store;
+ui::ListStore g_entlist_store{nullptr};
+ui::ListStore g_entprops_store{nullptr};
 const EntityClass* g_current_flags = 0;
 const EntityClass* g_current_comment = 0;
 const EntityClass* g_current_attributes = 0;
@@ -804,9 +803,9 @@ const char* keyvalues_valueforkey( KeyValues& keyvalues, const char* key ){
 
 class EntityClassListStoreAppend : public EntityClassVisitor
 {
-GtkListStore* store;
+ui::ListStore store;
 public:
-EntityClassListStoreAppend( GtkListStore* store_ ) : store( store_ ){
+EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){
 }
 void visit( EntityClass* e ){
        GtkTreeIter iter;
@@ -911,8 +910,8 @@ void EntityClassList_selectEntityClass( EntityClass* eclass ){
 }
 
 void EntityInspector_appendAttribute( const char* name, EntityAttribute& attribute ){
-       GtkTable* row = DialogRow_new( name, attribute.getWidget() );
-       DialogVBox_packRow( g_attributeBox, GTK_WIDGET( row ) );
+       auto row = DialogRow_new( name, attribute.getWidget() );
+       DialogVBox_packRow( ui::VBox(g_attributeBox), row );
 }
 
 
@@ -989,14 +988,14 @@ void EntityInspector_updateSpawnflags(){
                {
                        int v = !!( f & ( 1 << spawn_table[i] ) );
 
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), v );
+                       toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), v );
                }
        }
        {
                // take care of the remaining ones
                for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i )
                {
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), FALSE );
+                       toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), FALSE );
                }
        }
 }
@@ -1034,7 +1033,7 @@ void EntityInspector_updateKeyValues(){
 
        EntityInspector_updateSpawnflags();
 
-       GtkListStore* store = g_entprops_store;
+       ui::ListStore store = g_entprops_store;
 
        // save current key/val pair around filling epair box
        // row_select wipes it and sets to first in list
@@ -1318,7 +1317,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
 
                                {
-                                       GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
+                                       ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
 
                                        GtkTreeView* view = ui::TreeView( ui::TreeModel( GTK_TREE_MODEL( store ) ));
                                        gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
@@ -1402,7 +1401,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
 
                                        {
-                                               GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
+                                               ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
 
                                                ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
                                                gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
@@ -1444,7 +1443,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        gtk_table_set_col_spacings( table, 5 );
 
                                        {
-                                               GtkEntry* entry = ui::Entry();
+                                               auto entry = ui::Entry();
                                                gtk_widget_show( GTK_WIDGET( entry ) );
                                                gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
                                                                                  (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
@@ -1455,7 +1454,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        }
 
                                        {
-                                               GtkEntry* entry = ui::Entry();
+                                               auto entry = ui::Entry();
                                                gtk_widget_show( GTK_WIDGET( entry ) );
                                                gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
                                                                                  (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),