X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchdialog.cpp;h=da5e2283023c4c24e6a0ee742783ba56a03141d7;hb=0110e3a8f3ab54c17a1785e17c7246adf8e13a46;hp=b37854969cb969695a809dc62223be194a5810b1;hpb=4ebf4de56410776f8aa2b1e47ff71d40c57af629;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index b3785496..da5e2283 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -27,6 +27,8 @@ #include "patchdialog.h" +#include + #include "itexdef.h" #include "debugging/debugging.h" @@ -158,7 +160,7 @@ public: ui::CheckButton m_enabled; ui::Entry m_horizontal; ui::Entry m_vertical; -Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( nullptr ), m_vertical( nullptr ){ +Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( ui::null ), m_vertical( ui::null ){ } void update(){ PatchFixedSubdivisions subdivisions; @@ -174,8 +176,8 @@ void update(){ } else { - gtk_entry_set_text( m_horizontal, "" ); - gtk_entry_set_text( m_vertical, "" ); + m_horizontal.text(""); + m_vertical.text(""); gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE ); } @@ -224,8 +226,8 @@ float m_fZ; float m_fVShift; */ int m_nCol; int m_nRow; -ui::ComboBoxText m_pRowCombo{nullptr}; -ui::ComboBoxText m_pColCombo{nullptr}; +ui::ComboBoxText m_pRowCombo{ui::null}; +ui::ComboBoxText m_pColCombo{ui::null}; std::size_t m_countRows; std::size_t m_countCols; @@ -254,7 +256,7 @@ PatchInspector() : } bool visible(){ - return gtk_widget_get_visible( GetWidget() ); + return GetWidget().visible(); } // void UpdateInfo(); @@ -537,11 +539,11 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){ - if ( event->keyval == GDK_Return ) { + if ( event->keyval == GDK_KEY_Return ) { OnApply( ui::root, 0 ); return TRUE; } - else if ( event->keyval == GDK_Escape ) { + else if ( event->keyval == GDK_KEY_Escape ) { g_PatchInspector.GetPatchInfo(); return TRUE; } @@ -565,7 +567,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); vbox.show(); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + window.add(vbox); { auto hbox = ui::HBox( FALSE, 5 ); hbox.show(); @@ -583,7 +585,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 2, 2, FALSE ); table.show(); @@ -605,8 +607,8 @@ ui::Window PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); } { - auto combo = ui::ComboBoxText(); - g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); + auto combo = ui::ComboBoxText(ui::New); + combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); AddDialogData( *GTK_COMBO_BOX(combo), m_nRow ); combo.show(); @@ -618,8 +620,8 @@ ui::Window PatchInspector::BuildDialog(){ } { - auto combo = ui::ComboBoxText(); - g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); + auto combo = ui::ComboBoxText(ui::New); + combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); AddDialogData( *GTK_COMBO_BOX(combo), m_nCol ); combo.show(); @@ -671,54 +673,54 @@ ui::Window PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); AddDialogData( *GTK_ENTRY(entry), m_fX ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); AddDialogData( *GTK_ENTRY(entry), m_fY ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); AddDialogData( *GTK_ENTRY(entry), m_fZ ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); AddDialogData( *GTK_ENTRY(entry), m_fS ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); AddDialogData( *GTK_ENTRY(entry), m_fT ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } } } @@ -730,7 +732,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 3, 2, FALSE ); table.show(); @@ -751,7 +753,7 @@ ui::Window PatchInspector::BuildDialog(){ (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); m_subdivisions.m_enabled = check; - guint handler_id = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions ); + guint handler_id = check.connect( "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } { @@ -762,7 +764,7 @@ ui::Window PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -778,7 +780,7 @@ ui::Window PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -797,7 +799,7 @@ ui::Window PatchInspector::BuildDialog(){ { auto vbox2 = ui::VBox( FALSE, 5 ); vbox2.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); { auto label = ui::Label( "Name:" ); @@ -807,13 +809,13 @@ ui::Window PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); // gtk_editable_set_editable (GTK_ENTRY (entry), false); entry.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); AddDialogData( *GTK_ENTRY(entry), m_strName ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { auto table = ui::Table( 5, 4, FALSE ); @@ -851,7 +853,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { @@ -868,7 +870,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { @@ -880,19 +882,19 @@ ui::Window PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); - g_object_set_data( G_OBJECT( window ), "hshift_entry", entry ); + g_object_set_data( G_OBJECT( window ), "hshift_entry", (void *) entry ); // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised // so we need to have at least one initialisation somewhere entry_set_float( entry, g_pi_globals.shift[0] ); auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry ); g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); @@ -904,7 +906,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_widget_set_can_focus( spin, false ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), @@ -913,7 +915,7 @@ ui::Window PatchInspector::BuildDialog(){ entry_set_float( entry, g_pi_globals.shift[1] ); auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); @@ -925,7 +927,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_widget_set_can_focus( spin, false ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_FILL ), @@ -934,7 +936,7 @@ ui::Window PatchInspector::BuildDialog(){ entry_set_float( entry, g_pi_globals.scale[0] ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); @@ -946,7 +948,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_widget_set_can_focus( spin, false ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_FILL ), @@ -955,7 +957,7 @@ ui::Window PatchInspector::BuildDialog(){ entry_set_float( entry, g_pi_globals.scale[1] ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); @@ -967,7 +969,7 @@ ui::Window PatchInspector::BuildDialog(){ gtk_widget_set_can_focus( spin, false ); } { - auto entry = ui::Entry(); + auto entry = ui::Entry(ui::New); entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_FILL ), @@ -976,7 +978,7 @@ ui::Window PatchInspector::BuildDialog(){ entry_set_float( entry, g_pi_globals.rotate ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); @@ -995,35 +997,35 @@ ui::Window PatchInspector::BuildDialog(){ auto button = ui::Button( "Auto Cap" ); button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { auto button = ui::Button( "CAP" ); button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { auto button = ui::Button( "Set..." ); button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { auto button = ui::Button( "Natural" ); button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { auto button = ui::Button( "Fit" ); button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } }