From: TimePath Date: Fri, 21 Jul 2017 14:06:07 +0000 (+1000) Subject: Wrap gtkutil/dialog X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bc29059728a672779f082c864d7b5889dfc86d4e;p=xonotic%2Fnetradiant.git Wrap gtkutil/dialog --- diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index dfeece8d..188f253e 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -26,40 +26,40 @@ #include "button.h" #include "window.h" -GtkVBox* create_dialog_vbox( int spacing, int border ){ - GtkVBox* vbox = ui::VBox( FALSE, spacing ); - gtk_widget_show( GTK_WIDGET( vbox ) ); +ui::VBox create_dialog_vbox( int spacing, int border ){ + auto vbox = ui::VBox( FALSE, spacing ); + vbox.show(); gtk_container_set_border_width( GTK_CONTAINER( vbox ), border ); return vbox; } -GtkHBox* create_dialog_hbox( int spacing, int border ){ - GtkHBox* hbox = ui::HBox( FALSE, spacing ); - gtk_widget_show( GTK_WIDGET( hbox ) ); +ui::HBox create_dialog_hbox( int spacing, int border ){ + auto hbox = ui::HBox( FALSE, spacing ); + hbox.show(); gtk_container_set_border_width( GTK_CONTAINER( hbox ), border ); return hbox; } -GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow ){ - GtkFrame* frame = ui::Frame( label ); - gtk_widget_show( GTK_WIDGET( frame ) ); +ui::Frame create_dialog_frame( const char* label, GtkShadowType shadow ){ + auto frame = ui::Frame( label ); + frame.show(); gtk_frame_set_shadow_type( frame, shadow ); return frame; } -GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){ - GtkTable* table = ui::Table( rows, columns, FALSE ); - gtk_widget_show( GTK_WIDGET( table ) ); +ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){ + auto table = ui::Table( rows, columns, FALSE ); + table.show(); gtk_table_set_row_spacings( table, row_spacing ); gtk_table_set_col_spacings( table, col_spacing ); gtk_container_set_border_width( GTK_CONTAINER( table ), border ); return table; } -GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ){ - GtkButton* button = ui::Button( label ); +ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ){ + auto button = ui::Button( label ); gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 ); - gtk_widget_show( GTK_WIDGET( button ) ); + button.show(); g_signal_connect( G_OBJECT( button ), "clicked", func, data ); return button; } @@ -73,13 +73,13 @@ ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback return window; } -gboolean modal_dialog_button_clicked( GtkWidget *widget, ModalDialogButton* button ){ +gboolean modal_dialog_button_clicked( ui::Widget widget, ModalDialogButton* button ){ button->m_dialog.loop = false; button->m_dialog.ret = button->m_value; return TRUE; } -gboolean modal_dialog_delete( GtkWidget *widget, GdkEvent* event, ModalDialog* dialog ){ +gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* dialog ){ dialog->loop = 0; dialog->ret = eIDCANCEL; return TRUE; @@ -101,7 +101,7 @@ EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){ return dialog.ret; } -GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ){ +ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ){ return create_dialog_button( label, G_CALLBACK( modal_dialog_button_clicked ), &button ); } @@ -110,7 +110,7 @@ ui::Window create_modal_dialog_window( ui::Window parent, const char* title, Mod } ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width, int height ){ - ui::Window window = create_modal_dialog_window( parent, title, dialog, width, height ); + auto window = create_modal_dialog_window( parent, title, dialog, width, height ); gtk_window_set_resizable( window, FALSE ); gtk_window_set_modal( window, TRUE ); @@ -127,37 +127,37 @@ ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* return window; } -gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDOK; return TRUE; } -gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDCANCEL; return TRUE; } -gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDYES; return TRUE; } -gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDNO; return TRUE; } -gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ){ +gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ){ gtk_widget_hide( widget ); data->loop = false; return TRUE; } -ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){ +ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ){ ui::Window window = create_fixedsize_modal_dialog_window(ui::Window(), title, dialog ); GtkVBox* vbox1 = create_dialog_vbox( 8, 4 ); @@ -224,7 +224,7 @@ void PathEntry_setPath( PathEntry& self, const char* path ){ } typedef ReferenceCaller1 PathEntrySetPathCaller; -void BrowsedPathEntry_clicked( GtkWidget* widget, BrowsedPathEntry* self ){ +void BrowsedPathEntry_clicked( ui::Widget widget, BrowsedPathEntry* self ){ self->m_browse( PathEntrySetPathCaller( self->m_entry ) ); } @@ -235,8 +235,8 @@ BrowsedPathEntry::BrowsedPathEntry( const BrowseCallback& browse ) : } -GtkLabel* DialogLabel_new( const char* name ){ - ui::Label label = ui::Label( name ); +ui::Label DialogLabel_new( const char* name ){ + auto label = ui::Label( name ); gtk_widget_show(label); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); @@ -244,8 +244,8 @@ GtkLabel* DialogLabel_new( const char* name ){ return label; } -GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){ - GtkTable* table = ui::Table( 1, 3, TRUE ); +ui::Table DialogRow_new( const char* name, ui::Widget widget ){ + auto table = ui::Table( 1, 3, TRUE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_table_set_col_spacings( table, 4 ); @@ -262,6 +262,6 @@ GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){ return table; } -void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ){ +void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){ gtk_box_pack_start( GTK_BOX( vbox ), row, FALSE, FALSE, 0 ); } diff --git a/libs/gtkutil/dialog.h b/libs/gtkutil/dialog.h index 010432d6..1bf6c0a0 100644 --- a/libs/gtkutil/dialog.h +++ b/libs/gtkutil/dialog.h @@ -70,25 +70,25 @@ typedef struct _GtkFrame GtkFrame; ui::Window create_fixedsize_modal_window( ui::Window parent, const char* title, int width, int height ); ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 ); -GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 ); -GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ); -GtkVBox* create_dialog_vbox( int spacing, int border = 0 ); -GtkHBox* create_dialog_hbox( int spacing, int border = 0 ); -GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN ); +ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 ); +ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ); +ui::VBox create_dialog_vbox( int spacing, int border = 0 ); +ui::HBox create_dialog_hbox( int spacing, int border = 0 ); +ui::Frame create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN ); -GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ); +ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ); ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 ); ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 ); EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ); -gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ); +gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ); +gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ); -ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ); +ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ); class RadioHBox { @@ -131,10 +131,9 @@ BrowseCallback m_browse; BrowsedPathEntry( const BrowseCallback& browse ); }; -GtkLabel* DialogLabel_new( const char* name ); -GtkTable* DialogRow_new( const char* name, GtkWidget* widget ); -typedef struct _GtkVBox GtkVBox; -void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ); +ui::Label DialogLabel_new( const char* name ); +ui::Table DialogRow_new( const char* name, ui::Widget widget ); +void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ); #endif diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index b93bf00b..eadaf9a1 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -458,7 +458,7 @@ ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const ch gtk_widget_show( check ); AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(GTK_WIDGET( DialogRow_new( name, check ) ) )); return check; } @@ -483,8 +483,8 @@ void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange value gtk_container_add( GTK_CONTAINER( alignment ), combo ); } - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row ); } void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){ @@ -526,8 +526,8 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value ); gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); } void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ @@ -539,8 +539,8 @@ void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer ); } - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); } void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){ @@ -576,7 +576,7 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) ); } void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){ @@ -586,21 +586,21 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, String ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddIntEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddSizeEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddFloatEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } @@ -610,8 +610,8 @@ ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_ AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer ); - GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, ui::Widget(GTK_WIDGET( pathEntry.m_frame )) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); return ui::Widget(GTK_WIDGET( row )); } @@ -623,7 +623,7 @@ ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) ); AddIntSpinnerData( *row.m_spin, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return ui::SpinButton(row.m_spin); } @@ -634,6 +634,6 @@ ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) ); AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return ui::SpinButton(row.m_spin); } diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 912cd745..3160bf47 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -911,8 +911,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 ); } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 1758a765..8d07e012 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -444,9 +444,9 @@ class PathsDialog : public Dialog { public: ui::Window BuildDialog(){ - GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); + auto frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); - GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); + auto vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { @@ -454,7 +454,7 @@ ui::Window BuildDialog(){ Paths_constructPreferences( preferencesPage ); } - return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) )); + return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame )); } }; diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 14b6d75f..6c9c7f97 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -319,9 +319,9 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){ } ui::Window CGameDialog::BuildDialog(){ - GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); + auto frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); - GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); + auto vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { @@ -330,7 +330,7 @@ ui::Window CGameDialog::BuildDialog(){ CreateGlobalFrame( preferencesPage ); } - return ui::Window(create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) )); + return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame ); } class LoadGameFile