From c52a4bd4da209e657018e8d799dcb488cd848e4c Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 17 Jul 2017 21:55:47 +1000 Subject: [PATCH] Wrap GTK --- contrib/bkgrnd2d/dialog.cpp | 44 +- contrib/bobtoolz/dialogs/dialogs-gtk.cpp | 611 +++++++++++------------ contrib/bobtoolz/dialogs/dialogs-gtk.h | 3 +- contrib/bobtoolz/lists.cpp | 7 +- contrib/bobtoolz/lists.h | 3 +- contrib/bobtoolz/shapes.cpp | 6 +- contrib/brushexport/callbacks.cpp | 6 +- contrib/brushexport/interface.cpp | 37 +- contrib/brushexport/plugin.cpp | 9 +- contrib/brushexport/support.cpp | 7 +- contrib/brushexport/support.h | 3 +- contrib/camera/dialogs.cpp | 274 +++++----- contrib/gtkgensurf/gendlgs.cpp | 318 ++++++------ contrib/gtkgensurf/gensurf.cpp | 2 +- contrib/gtkgensurf/view.cpp | 36 +- contrib/hydratoolz/plugin.cpp | 74 +-- contrib/prtview/AboutDialog.cpp | 28 +- contrib/prtview/ConfigDialog.cpp | 202 ++++---- contrib/prtview/LoadPortalFileDialog.cpp | 91 ++-- contrib/shaderplug/shaderplug.cpp | 14 +- contrib/sunplug/sunplug.cpp | 49 +- contrib/ufoaiplug/ufoai.cpp | 14 +- include/itoolbar.h | 1 - include/qerplugin.h | 10 +- libs/container/array.h | 1 - libs/container/cache.h | 94 ++-- libs/container/hashtable.h | 1 - libs/debugging/debugging.h | 1 + libs/gtkutil/accelerator.cpp | 10 +- libs/gtkutil/accelerator.h | 4 +- libs/gtkutil/button.cpp | 33 +- libs/gtkutil/button.h | 4 + libs/gtkutil/clipboard.cpp | 8 +- libs/gtkutil/container.h | 2 +- libs/gtkutil/cursor.cpp | 21 +- libs/gtkutil/cursor.h | 6 +- libs/gtkutil/dialog.cpp | 39 +- libs/gtkutil/dialog.h | 2 +- libs/gtkutil/entry.h | 2 +- libs/gtkutil/filechooser.cpp | 13 +- libs/gtkutil/filechooser.h | 7 +- libs/gtkutil/frame.cpp | 5 +- libs/gtkutil/glwidget.cpp | 6 +- libs/gtkutil/image.cpp | 7 +- libs/gtkutil/menu.cpp | 49 +- libs/gtkutil/messagebox.cpp | 22 +- libs/gtkutil/messagebox.h | 3 +- libs/gtkutil/nonmodal.h | 10 +- libs/gtkutil/paned.cpp | 10 +- libs/gtkutil/toolbar.cpp | 46 +- libs/gtkutil/toolbar.h | 9 +- libs/gtkutil/widget.h | 10 +- libs/gtkutil/window.cpp | 13 +- libs/gtkutil/window.h | 2 +- libs/gtkutil/xorrectangle.h | 31 +- libs/modulesystem/moduleregistry.h | 28 +- libs/modulesystem/singletonmodule.h | 2 +- libs/uilib/uilib.cpp | 205 ++++++++ libs/uilib/uilib.h | 281 +++++++++++ plugins/textool/2DView.cpp | 18 +- plugins/textool/TexTool.cpp | 96 ++-- plugins/vfspk3/archive.cpp | 1 + radiant/autosave.cpp | 7 +- radiant/brushmanip.cpp | 7 +- radiant/build.cpp | 41 +- radiant/camwindow.cpp | 63 +-- radiant/camwindow.h | 8 +- radiant/commands.cpp | 73 ++- radiant/console.cpp | 26 +- radiant/console.h | 5 +- radiant/dialog.cpp | 121 ++--- radiant/dialog.h | 51 +- radiant/entity.cpp | 12 +- radiant/entity.h | 5 +- radiant/entityinspector.cpp | 183 ++++--- radiant/entityinspector.h | 6 +- radiant/entitylist.cpp | 20 +- radiant/entitylist.h | 5 +- radiant/feedback.cpp | 21 +- radiant/feedback.h | 4 +- radiant/findtexturedialog.cpp | 62 +-- radiant/findtexturedialog.h | 5 +- radiant/groupdialog.cpp | 54 +- radiant/groupdialog.h | 16 +- radiant/gtkdlgs.cpp | 181 ++++--- radiant/gtkmisc.cpp | 51 +- radiant/gtkmisc.h | 13 +- radiant/main.cpp | 27 +- radiant/mainframe.cpp | 195 ++++---- radiant/mainframe.h | 15 +- radiant/map.cpp | 60 +-- radiant/mru.cpp | 4 +- radiant/multimon.cpp | 6 +- radiant/patchdialog.cpp | 260 +++++----- radiant/patchdialog.h | 6 +- radiant/patchmanip.cpp | 68 ++- radiant/pluginmanager.cpp | 14 +- radiant/pluginmanager.h | 4 +- radiant/pluginmenu.cpp | 25 +- radiant/plugintoolbar.cpp | 65 ++- radiant/preferences.cpp | 106 ++-- radiant/preferences.h | 44 +- radiant/qe3.cpp | 15 +- radiant/qgl.cpp | 3 +- radiant/select.cpp | 73 ++- radiant/server.cpp | 5 +- radiant/surfacedialog.cpp | 229 ++++----- radiant/surfacedialog.h | 6 +- radiant/textureentry.h | 3 +- radiant/texwindow.cpp | 204 ++++---- radiant/texwindow.h | 8 +- radiant/treemodel.cpp | 13 +- radiant/url.cpp | 4 +- radiant/watchbsp.cpp | 222 ++++---- radiant/windowobservers.cpp | 16 +- radiant/windowobservers.h | 9 +- radiant/xmlstuff.h | 3 +- radiant/xywindow.cpp | 85 ++-- radiant/xywindow.h | 14 +- 119 files changed, 3039 insertions(+), 2763 deletions(-) create mode 100644 libs/uilib/uilib.h diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index 6d63bc3f..a787c8fa 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -183,45 +183,45 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ switch ( m_vt ) { case XY: - m_pTabLabel = gtk_label_new( "X/Y" ); + m_pTabLabel = ui::Label( "X/Y" ); m_pImage = &backgroundXY; break; case XZ: - m_pTabLabel = gtk_label_new( "X/Z" ); + m_pTabLabel = ui::Label( "X/Z" ); m_pImage = &backgroundXZ; break; case YZ: - m_pTabLabel = gtk_label_new( "Y/Z" ); + m_pTabLabel = ui::Label( "Y/Z" ); m_pImage = &backgroundYZ; break; } // A vbox to hold everything - m_pWidget = gtk_vbox_new( FALSE,0 ); + m_pWidget = ui::VBox( FALSE,0 ); // Frame for file row - frame = gtk_frame_new( "File" ); + frame = ui::Frame( "File" ); gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 ); // hbox for first row - hbox = gtk_hbox_new( FALSE,5 ); + hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); gtk_container_add( GTK_CONTAINER( frame ), hbox ); // label to display filename - m_pFileLabel = gtk_label_new( NO_FILE_MSG ); + m_pFileLabel = ui::Label( NO_FILE_MSG ); gtk_label_set_selectable( GTK_LABEL( m_pFileLabel ),TRUE ); //TODO set min size ? done with spaces right now gtk_box_pack_start( GTK_BOX( hbox ),m_pFileLabel, TRUE, TRUE, 5 ); gtk_widget_show( m_pFileLabel ); - w = gtk_button_new_with_label( "Browse..." ); + w = ui::Button( "Browse..." ); g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( browse_callback ), ( gpointer ) this ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_tooltips_set_tip( pTooltips, w, "Select a file", NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Reload" ); + w = ui::Button( "Reload" ); g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( reload_callback ), ( gpointer ) this ); // TODO disable until we have file @@ -234,18 +234,18 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_widget_show( frame ); // second row (rendering options) - frame = gtk_frame_new( "Rendering" ); + frame = ui::Frame( "Rendering" ); gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 ); - hbox = gtk_hbox_new( FALSE,5 ); + hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); gtk_container_add( GTK_CONTAINER( frame ), hbox ); - w = gtk_label_new( "Vertex alpha:" ); + w = ui::Label( "Vertex alpha:" ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_widget_show( w ); - w = gtk_hscale_new_with_range( 0.0,1.0,0.01 ); + w = ui::HScale( 0.0, 1.0, 0.01 ); gtk_range_set_value( GTK_RANGE( w ),0.5 ); gtk_scale_set_value_pos( GTK_SCALE( w ),GTK_POS_LEFT ); g_signal_connect( G_OBJECT( w ), "value-changed", @@ -257,15 +257,15 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_widget_show( hbox ); gtk_widget_show( frame ); // Third row (size and position) - frame = gtk_frame_new( "Size/Position (undefined)" ); + frame = ui::Frame( "Size/Position (undefined)" ); m_pPosLabel = gtk_frame_get_label_widget( GTK_FRAME( frame ) ); gtk_box_pack_start( GTK_BOX( m_pWidget ), frame, FALSE, FALSE, 2 ); - hbox = gtk_hbox_new( FALSE,5 ); + hbox = ui::HBox( FALSE,5 ); gtk_container_add( GTK_CONTAINER( frame ), hbox ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - w = gtk_button_new_with_label( "from selection" ); + w = ui::Button( "from selection" ); gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 5 ); g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_sel_callback ), ( gpointer ) this ); @@ -273,7 +273,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_widget_show( w ); if ( m_vt == XY ) { - w = gtk_button_new_with_label( "from map mins/maxs" ); + w = ui::Button( "from map mins/maxs" ); gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 2 ); g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_mm_callback ), ( gpointer ) this ); @@ -320,11 +320,11 @@ void InitBackgroundDialog(){ // GTK_STOCK_CLOSE, // GTK_RESPONSE_CLOSE, NULL ); - gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "delete_event", - GTK_SIGNAL_FUNC( close_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "response", - GTK_SIGNAL_FUNC( response_callback ), NULL ); -// gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL ); + g_signal_connect( GTK_OBJECT( pDialogWnd ), "delete_event", + G_CALLBACK( close_callback ), NULL ); + g_signal_connect( GTK_OBJECT( pDialogWnd ), "response", + G_CALLBACK( response_callback ), NULL ); +// g_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", G_CALLBACK( ci_expose ), NULL ); pTooltips = gtk_tooltips_new(); diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index b596f059..daeb3913 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -59,23 +59,23 @@ void Update_TextureReseter(){ gboolean check; check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexNew ), check ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexOld ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexNew ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexOld ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleHor ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleVert ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftHor ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftVert ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editRotation ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check ); } static void dialog_button_callback( GtkWidget *widget, gpointer data ){ @@ -105,9 +105,9 @@ static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){ TwinWidget* tw = (TwinWidget*)data; GtkEntry* entry = GTK_ENTRY( tw->one ); - GtkCombo* combo = GTK_COMBO( tw->two ); + auto* combo = GTK_BIN(tw->two); - const gchar* tex = gtk_entry_get_text( GTK_ENTRY( combo->entry ) ); + const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo))); gtk_entry_set_text( entry, tex ); } @@ -209,100 +209,100 @@ bool ValidateTextInt( const char* pData, char* error_title, int* value ){ */ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){ - GtkWidget *window, *w, *vbox, *hbox; + ui::Widget window, w, vbox, hbox; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window = ui::Window( ui::window_type::TOP ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( type == eMB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default(w, true); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = eIDOK; } else if ( type == eMB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; } else if ( type == eMB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); ret = eIDNO; } @@ -322,18 +322,17 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ GtkWidget *window, *w, *vbox, *hbox; - GtkWidget *radio1, *radio2; GtkWidget *check1, *check2; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Intersect" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -342,18 +341,18 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" ); + auto radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" ); gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 ); gtk_widget_show( radio1 ); - radio2 = gtk_radio_button_new_with_label( ( (GtkRadioButton*)radio1 )->group, "Use Selected Brushes" ); + auto radio2 = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ); gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 ); gtk_widget_show( radio2 ); @@ -361,31 +360,31 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - check1 = gtk_check_button_new_with_label( "Include Detail Brushes" ); + check1 = ui::CheckButton( "Include Detail Brushes" ); gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Select Duplicate Brushes Only" ); + check2 = ui::CheckButton( "Select Duplicate Brushes Only" ); gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- ok/cancel buttons - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -425,13 +424,13 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -440,55 +439,55 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - vbox2 = gtk_vbox_new( FALSE, 10 ); + vbox2 = ui::VBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 ); gtk_widget_show( vbox2 ); // ---- vbox2 ---- - hbox2 = gtk_hbox_new( FALSE, 10 ); + hbox2 = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 ); gtk_widget_show( hbox2 ); // ---- hbox2 ---- - text1 = gtk_entry_new_with_max_length( 256 ); + text1 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text1, "3" ); gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Sides" ); + w = ui::Label( "Number Of Sides" ); gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox2 ---- - hbox2 = gtk_hbox_new( FALSE, 10 ); + hbox2 = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 ); gtk_widget_show( hbox2 ); // ---- hbox2 ---- - text2 = gtk_entry_new_with_max_length( 256 ); + text2 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text2, "8" ); gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Border Width" ); + w = ui::Label( "Border Width" ); gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -499,23 +498,23 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - vbox2 = gtk_vbox_new( FALSE, 10 ); + vbox2 = ui::VBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 ); gtk_widget_show( vbox2 ); // ---- vbox2 ---- - check1 = gtk_check_button_new_with_label( "Use Border" ); + check1 = ui::CheckButton( "Use Border" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Inverse Polygon" ); + check2 = ui::CheckButton( "Inverse Polygon" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); - check3 = gtk_check_button_new_with_label( "Align Top Edge" ); + check3 = ui::CheckButton( "Align Top Edge" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 ); gtk_widget_show( check3 ); @@ -523,23 +522,23 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // ---- /hbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -597,16 +596,16 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; + char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -614,16 +613,16 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( vbox ), hbox ); gtk_widget_show( hbox ); // dunno if you want this text or not ... - w = gtk_label_new( text ); + w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ... gtk_widget_show( w ); @@ -634,31 +633,31 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // ------------------------- // indenting == good way of keeping track of lines :) // new hbox - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textStairHeight = gtk_entry_new_with_max_length( 256 ); + textStairHeight = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 ); gtk_widget_show( textStairHeight ); - w = gtk_label_new( "Stair Height" ); + w = ui::Label( "Stair Height" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // ------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Direction:" ); + w = ui::Label( "Direction:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); @@ -672,19 +671,19 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 ); gtk_widget_show( radioNorth ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNorth ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) ); radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" ); gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 ); gtk_widget_show( radioSouth ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioSouth ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) ); radioEast = gtk_radio_button_new_with_label( radioDirection, "East" ); gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 ); gtk_widget_show( radioEast ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioEast ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) ); radioWest = gtk_radio_button_new_with_label( radioDirection, "West" ); gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 ); @@ -692,17 +691,17 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Style:" ); + w = ui::Label( "Style:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); @@ -710,13 +709,13 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 ); gtk_widget_show( radioOldStyle ); - radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioOldStyle ) ); + radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) ); radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ); gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 ); gtk_widget_show( radioBobStyle ); - radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioBobStyle ) ); + radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) ); radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" ); gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 ); @@ -729,36 +728,36 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // djbob: think we need some button callback functions or smuffin // FIXME: actually get around to doing what i suggested!!!! - checkUseDetail = gtk_check_button_new_with_label( "Use Detail Brushes" ); + checkUseDetail = ui::CheckButton( "Use Detail Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 ); gtk_widget_show( checkUseDetail ); // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textMainTex = gtk_entry_new_with_max_length( 512 ); + textMainTex = ui::Entry( 512 ); gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture ); gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 ); gtk_widget_show( textMainTex ); - w = gtk_label_new( "Main Texture" ); + w = ui::Label( "Main Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textRiserTex = gtk_entry_new_with_max_length( 512 ); + textRiserTex = ui::Entry( 512 ); gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 ); gtk_widget_show( textRiserTex ); - w = gtk_label_new( "Riser Texture" ); + w = ui::Label( "Riser Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); @@ -767,20 +766,20 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -855,14 +854,14 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -870,126 +869,124 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_widget_realize( window ); char buffer[256]; - GList *listMainTextures = NULL; - GList *listTrimTextures = NULL; - LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), &listMainTextures ); - LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), &listTrimTextures ); + GtkListStore *listMainTextures = gtk_list_store_new( 1, G_TYPE_STRING ); + GtkListStore *listTrimTextures = gtk_list_store_new( 1, G_TYPE_STRING ); + LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures ); + LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textFrontBackTex = gtk_entry_new_with_max_length( 512 ); + textFrontBackTex = ui::Entry( 512 ); gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture ); gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 ); gtk_widget_show( textFrontBackTex ); - w = gtk_label_new( "Door Front/Back Texture" ); + w = ui::Label( "Door Front/Back Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ------------------------ // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textTrimTex = gtk_entry_new_with_max_length( 512 ); + textTrimTex = ui::Entry( 512 ); gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 ); gtk_widget_show( textTrimTex ); - w = gtk_label_new( "Door Trim Texture" ); + w = ui::Label( "Door Trim Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ----------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); // sp: horizontally ???? // djbob: yes mars, u can spell :] - checkScaleMainH = gtk_check_button_new_with_label( "Scale Main Texture Horizontally" ); + checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleMainH ); - checkScaleTrimH = gtk_check_button_new_with_label( "Scale Trim Texture Horizontally" ); + checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleTrimH ); // ---------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - checkScaleMainV = gtk_check_button_new_with_label( "Scale Main Texture Vertically" ); + checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleMainV ); - checkScaleTrimV = gtk_check_button_new_with_label( "Scale Trim Texture Vertically" ); + checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleTrimV ); // --------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); // djbob: lists added - comboMain = gtk_combo_new(); + comboMain = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures)); + gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 ); - gtk_combo_set_popdown_strings( GTK_COMBO( comboMain ), listMainTextures ); - gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 ); gtk_widget_show( comboMain ); tw1.one = textFrontBackTex; - tw1.two = comboMain; + tw1.two = GTK_COMBO_BOX(comboMain); - buttonSetMain = gtk_button_new_with_label( "Set As Main Texture" ); - gtk_signal_connect( GTK_OBJECT( buttonSetMain ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw1 ); + buttonSetMain = ui::Button( "Set As Main Texture" ); + g_signal_connect( GTK_OBJECT( buttonSetMain ), "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 ); gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 ); gtk_widget_show( buttonSetMain ); // ------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - comboTrim = gtk_combo_new(); + comboTrim = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures)); + gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 ); - gtk_combo_set_popdown_strings( GTK_COMBO( comboTrim ), listTrimTextures ); - gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 ); gtk_widget_show( comboTrim ); tw2.one = textTrimTex; - tw2.two = comboTrim; + tw2.two = GTK_COMBO_BOX(comboTrim); - buttonSetTrim = gtk_button_new_with_label( "Set As Trim Texture" ); - gtk_signal_connect( GTK_OBJECT( buttonSetTrim ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw2 ); + buttonSetTrim = ui::Button( "Set As Trim Texture" ); + g_signal_connect( GTK_OBJECT( buttonSetTrim ), "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 ); gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 ); gtk_widget_show( buttonSetTrim ); // ------------------ // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Orientation" ); + w = ui::Label( "Orientation" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -998,7 +995,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 ); gtk_widget_show( radioNS ); - radioOrientation = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNS ) ); + radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) ); radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" ); gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 ); @@ -1012,20 +1009,20 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ // ----------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1070,13 +1067,13 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1085,65 +1082,65 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text1 = gtk_entry_new_with_max_length( 256 ); + text1 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text1, "25" ); gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Points" ); + w = ui::Label( "Number Of Points" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text2 = gtk_entry_new_with_max_length( 256 ); + text2 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text2, "3" ); gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Multipler" ); + w = ui::Label( "Multipler" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - w = gtk_label_new( "Path Distance = dist(start -> apex) * multiplier" ); + w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text3 = gtk_entry_new_with_max_length( 256 ); + text3 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text3, "-800" ); gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 ); gtk_widget_show( text3 ); - w = gtk_label_new( "Gravity" ); + w = ui::Label( "Gravity" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -1154,11 +1151,11 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - check1 = gtk_check_button_new_with_label( "No Dynamic Update" ); + check1 = ui::CheckButton( "No Dynamic Update" ); gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Show Bounding Lines" ); + check2 = ui::CheckButton( "Show Bounding Lines" ); gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); @@ -1173,26 +1170,26 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ // ----------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Enable" ); + w = ui::Button( "Enable" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Disable" ); + w = ui::Button( "Disable" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1241,13 +1238,13 @@ EMessageBoxReturn DoCTFColourChangeBox(){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1256,34 +1253,34 @@ EMessageBoxReturn DoCTFColourChangeBox(){ - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 ); gtk_widget_show( hbox ); // ---- hbox ---- ok/cancel buttons - w = gtk_button_new_with_label( "Red->Blue" ); + w = ui::Button( "Red->Blue" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Blue->Red" ); + w = ui::Button( "Blue->Red" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1312,26 +1309,26 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); @@ -1340,18 +1337,18 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ texSelected = "Currently Selected Texture: "; texSelected += GetCurrentTexture(); - w = gtk_label_new( texSelected ); + w = ui::Label( texSelected ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - frame = gtk_frame_new( "Reset Texture Names" ); + frame = ui::Frame( "Reset Texture Names" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1360,33 +1357,33 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- frame ---- - dlgTexReset.cbTexChange = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbTexChange ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" ); + g_signal_connect( GTK_OBJECT( dlgTexReset.cbTexChange ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbTexChange ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "Old Name: " ); + w = ui::Label( "Old Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editTexOld = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editTexOld = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( dlgTexReset.editTexOld ); - w = gtk_label_new( "New Name: " ); + w = ui::Label( "New Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editTexNew = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editTexNew = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1395,11 +1392,11 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Scales" ); + frame = ui::Frame( "Reset Scales" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1408,20 +1405,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- frame ---- - dlgTexReset.cbScaleHor = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" ); + g_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleHor ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbScaleHor ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Scale: " ); + w = ui::Label( "New Horizontal Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editScaleHor = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editScaleHor = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1429,20 +1426,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_widget_show( dlgTexReset.editScaleHor ); - dlgTexReset.cbScaleVert = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" ); + g_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleVert ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbScaleVert ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Scale: " ); + w = ui::Label( "New Vertical Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editScaleVert = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editScaleVert = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1451,11 +1448,11 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Shift" ); + frame = ui::Frame( "Reset Shift" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1464,20 +1461,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- frame ---- - dlgTexReset.cbShiftHor = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" ); + g_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftHor ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbShiftHor ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Shift: " ); + w = ui::Label( "New Horizontal Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editShiftHor = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editShiftHor = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1485,20 +1482,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_widget_show( dlgTexReset.editShiftHor ); - dlgTexReset.cbShiftVert = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" ); + g_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftVert ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbShiftVert ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Shift: " ); + w = ui::Label( "New Vertical Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editShiftVert = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editShiftVert = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1507,11 +1504,11 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Rotation" ); + frame = ui::Frame( "Reset Rotation" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 1, 3, TRUE ); + table = ui::Table( 1, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1520,19 +1517,19 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- frame ---- - dlgTexReset.cbRotation = gtk_check_button_new_with_label( "Enabled" ); + dlgTexReset.cbRotation = ui::CheckButton( "Enabled" ); gtk_widget_show( dlgTexReset.cbRotation ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Rotation Value: " ); + w = ui::Label( "New Rotation Value: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editRotation = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editRotation = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1541,28 +1538,28 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Use Selected Brushes" ); + w = ui::Button( "Use Selected Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Use All Brushes" ); + w = ui::Button( "Use All Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1648,36 +1645,36 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); - gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop ); - gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); + g_object_set_data( G_OBJECT( window ), "loop", &loop ); + g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- /hbox ---- - frame = gtk_frame_new( "Radii" ); + frame = ui::Frame( "Radii" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1686,13 +1683,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "X: " ); + w = ui::Label( "X: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - radiusX = gtk_entry_new_with_max_length( 256 ); + radiusX = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" ); gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1701,13 +1698,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "Y: " ); + w = ui::Label( "Y: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - radiusY = gtk_entry_new_with_max_length( 256 ); + radiusY = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" ); gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1716,11 +1713,11 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - frame = gtk_frame_new( "Angles" ); + frame = ui::Frame( "Angles" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1729,13 +1726,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - angleStart = gtk_entry_new_with_max_length( 256 ); + angleStart = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" ); gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1744,13 +1741,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - angleEnd = gtk_entry_new_with_max_length( 256 ); + angleEnd = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" ); gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1758,11 +1755,11 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_widget_show( angleEnd ); - frame = gtk_frame_new( "Height" ); + frame = ui::Frame( "Height" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1771,13 +1768,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - heightStart = gtk_entry_new_with_max_length( 256 ); + heightStart = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" ); gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1786,13 +1783,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - heightEnd = gtk_entry_new_with_max_length( 256 ); + heightEnd = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" ); gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1801,11 +1798,11 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - frame = gtk_frame_new( "Points" ); + frame = ui::Frame( "Points" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); + table = ui::Table( 2, 3, TRUE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); @@ -1814,13 +1811,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Number: " ); + w = ui::Label( "Number: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - numPoints = gtk_entry_new_with_max_length( 256 ); + numPoints = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" ); gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1828,23 +1825,23 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_widget_show( numPoints ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1911,14 +1908,14 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1926,16 +1923,16 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( vbox ), hbox ); gtk_widget_show( hbox ); // dunno if you want this text or not ... - w = gtk_label_new( text ); + w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1946,43 +1943,43 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ // ------------------------- // // new hbox - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textlinkNum = gtk_entry_new_with_max_length( 256 ); + textlinkNum = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 ); gtk_widget_show( textlinkNum ); - w = gtk_label_new( "Number of elements in chain" ); + w = ui::Label( "Number of elements in chain" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textlinkName = gtk_entry_new_with_max_length( 256 ); + textlinkName = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 ); gtk_widget_show( textlinkName ); - w = gtk_label_new( "Basename for chain's targetnames." ); + w = ui::Label( "Basename for chain's targetnames." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -2012,4 +2009,4 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_destroy( window ); return ret; -} \ No newline at end of file +} diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.h b/contrib/bobtoolz/dialogs/dialogs-gtk.h index ae354904..75db2d18 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.h +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.h @@ -20,6 +20,7 @@ #if !defined( INCLUDED_DIALOGS_GTK_H ) #define INCLUDED_DIALOGS_GTK_H +#include #include "qerplugin.h" struct BuildStairsRS { @@ -94,7 +95,7 @@ typedef struct _GtkWidget GtkWidget; struct TwinWidget { GtkWidget* one; - GtkWidget* two; + GtkComboBox* two; }; EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ); diff --git a/contrib/bobtoolz/lists.cpp b/contrib/bobtoolz/lists.cpp index 81079839..c2b1ed9e 100644 --- a/contrib/bobtoolz/lists.cpp +++ b/contrib/bobtoolz/lists.cpp @@ -24,6 +24,7 @@ #endif #include +#include #include "misc.h" @@ -54,7 +55,7 @@ bool LoadExclusionList( char* filename, std::list* exclusionList ){ return FALSE; } -bool LoadGList( char* filename, GList** loadlist ){ +bool LoadGList( char* filename, GtkListStore* loadlist ){ FILE* eFile = fopen( filename, "r" ); if ( eFile ) { char buffer[256]; @@ -67,7 +68,9 @@ bool LoadGList( char* filename, GList** loadlist ){ if ( strlen( buffer ) > 0 ) { char* buffer2 = new char[strlen( buffer ) + 1]; strcpy( buffer2, buffer ); - *loadlist = g_list_append( *loadlist, buffer2 ); + GtkTreeIter iter; + gtk_list_store_append(loadlist, &iter); + gtk_list_store_set(loadlist, &iter, 0, buffer2, -1); } else{ cnt++; diff --git a/contrib/bobtoolz/lists.h b/contrib/bobtoolz/lists.h index 827c9cbc..00e50266 100644 --- a/contrib/bobtoolz/lists.h +++ b/contrib/bobtoolz/lists.h @@ -18,8 +18,9 @@ */ #include +#include #include "str.h" typedef struct _GList GList; bool LoadExclusionList( char* filename, std::list* exclusionList ); -bool LoadGList( char* filename, GList** loadlist ); +bool LoadGList( char* filename, GtkListStore* loadlist ); diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index f466c515..2e47035d 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -58,9 +58,9 @@ / | / | / | / | 4 ----- 6 | - | 2|_|___|8 - | / | / - | / | / ----> WEST, definitely + | 2|_|___|8 + | / | / + | / | / ----> WEST, definitely ||/ | / 1|_____|/3 diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index 6a346f3a..be8d0bae 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -18,8 +18,8 @@ void OnDestroy( GtkWidget* w, gpointer data ){ } void OnExportClicked( GtkButton* button, gpointer user_data ){ - GtkWidget* window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); - ASSERT_NOTNULL( window ); + ui::Widget window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); + ASSERT_TRUE( window ); const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true ); if ( !cpath ) { return; @@ -68,7 +68,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){ { radio = lookup_widget( GTK_WIDGET( button ), "r_nocollapse" ); ASSERT_NOTNULL( radio ); - ASSERT_NOTNULL( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); + ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); mode = COLLAPSE_NONE; } } diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index 76279ab0..c0f18c82 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -7,7 +7,7 @@ #define GLADE_HOOKUP_OBJECT( component,widget,name ) \ g_object_set_data_full( G_OBJECT( component ), name, \ - gtk_widget_ref( widget ), (GDestroyNotify) gtk_widget_unref ) + g_object_ref( widget ), (GDestroyNotify) g_object_unref ) #define GLADE_HOOKUP_OBJECT_NO_REF( component,widget,name ) \ g_object_set_data( G_OBJECT( component ), name, widget ) @@ -37,36 +37,33 @@ create_w_plugplug2( void ){ GtkWidget *t_exportmaterials; GtkWidget *t_limitmatnames; GtkWidget *t_objects; - GtkTooltips *tooltips; - tooltips = gtk_tooltips_new(); - - w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + w_plugplug2 = ui::Window( ui::window_type::TOP ); gtk_widget_set_name( w_plugplug2, "w_plugplug2" ); gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" ); gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER ); gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE ); - vbox1 = gtk_vbox_new( FALSE, 0 ); + vbox1 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox1, "vbox1" ); gtk_widget_show( vbox1 ); gtk_container_add( GTK_CONTAINER( w_plugplug2 ), vbox1 ); gtk_container_set_border_width( GTK_CONTAINER( vbox1 ), 5 ); - hbox2 = gtk_hbox_new( TRUE, 5 ); + hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_set_name( hbox2, "hbox2" ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox1 ), hbox2, FALSE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 5 ); - vbox4 = gtk_vbox_new( TRUE, 0 ); + vbox4 = ui::VBox( TRUE, 0 ); gtk_widget_set_name( vbox4, "vbox4" ); gtk_widget_show( vbox4 ); gtk_box_pack_start( GTK_BOX( hbox2 ), vbox4, TRUE, FALSE, 0 ); r_collapse = gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" ); gtk_widget_set_name( r_collapse, "r_collapse" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapse, "Collapse all brushes into a single group", "Collapse all brushes into a single group" ); + gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group"); gtk_widget_show( r_collapse ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapse, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapse ), r_collapse_group ); @@ -74,7 +71,7 @@ create_w_plugplug2( void ){ r_collapsebymaterial = gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" ); gtk_widget_set_name( r_collapsebymaterial, "r_collapsebymaterial" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapsebymaterial, "Collapse into groups by material", "Collapse into groups by material" ); + gtk_widget_set_tooltip_text(r_collapsebymaterial, "Collapse into groups by material"); gtk_widget_show( r_collapsebymaterial ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapsebymaterial, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapsebymaterial ), r_collapse_group ); @@ -82,13 +79,13 @@ create_w_plugplug2( void ){ r_nocollapse = gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" ); gtk_widget_set_name( r_nocollapse, "r_nocollapse" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_nocollapse, "Every brush is stored in its own group", "Every brush is stored in its own group" ); + gtk_widget_set_tooltip_text(r_nocollapse, "Every brush is stored in its own group"); gtk_widget_show( r_nocollapse ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_nocollapse, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_nocollapse ), r_collapse_group ); r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_nocollapse ) ); - vbox3 = gtk_vbox_new( FALSE, 0 ); + vbox3 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox3, "vbox3" ); gtk_widget_show( vbox3 ); gtk_box_pack_start( GTK_BOX( hbox2 ), vbox3, FALSE, FALSE, 0 ); @@ -105,37 +102,37 @@ create_w_plugplug2( void ){ gtk_box_pack_start( GTK_BOX( vbox3 ), b_close, TRUE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( b_close ), 5 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_widget_set_name( vbox2, "vbox2" ); gtk_widget_show( vbox2 ); gtk_box_pack_start( GTK_BOX( vbox1 ), vbox2, TRUE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 2 ); - label1 = gtk_label_new( "Ignored materials:" ); + label1 = ui::Label( "Ignored materials:" ); gtk_widget_set_name( label1, "label1" ); gtk_widget_show( label1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), label1, FALSE, FALSE, 0 ); - scrolledwindow1 = gtk_scrolled_window_new( NULL, NULL ); + scrolledwindow1 = ui::ScrolledWindow(); gtk_widget_set_name( scrolledwindow1, "scrolledwindow1" ); gtk_widget_show( scrolledwindow1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), scrolledwindow1, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_SHADOW_IN ); - t_materialist = gtk_tree_view_new(); + t_materialist = ui::TreeView(); gtk_widget_set_name( t_materialist, "t_materialist" ); gtk_widget_show( t_materialist ); gtk_container_add( GTK_CONTAINER( scrolledwindow1 ), t_materialist ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( t_materialist ), FALSE ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( t_materialist ), FALSE ); - ed_materialname = gtk_entry_new(); + ed_materialname = ui::Entry(); gtk_widget_set_name( ed_materialname, "ed_materialname" ); gtk_widget_show( ed_materialname ); gtk_box_pack_start( GTK_BOX( vbox2 ), ed_materialname, FALSE, FALSE, 0 ); - hbox1 = gtk_hbox_new( TRUE, 0 ); + hbox1 = ui::HBox( TRUE, 0 ); gtk_widget_set_name( hbox1, "hbox1" ); gtk_widget_show( hbox1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox1, FALSE, FALSE, 0 ); @@ -206,7 +203,7 @@ GtkWidget* g_brushexp_window = 0; // spawn plugin window (and make sure it got destroyed first or never created) void CreateWindow( void ){ - ASSERT_NOTNULL( !g_brushexp_window ); + ASSERT_TRUE( !g_brushexp_window ); GtkWidget* wnd = create_w_plugplug2(); @@ -214,7 +211,7 @@ void CreateWindow( void ){ GtkTreeViewColumn* col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title( col, "materials" ); gtk_tree_view_append_column( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), col ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), -1, "", renderer, "text", 0, NULL ); // list store diff --git a/contrib/brushexport/plugin.cpp b/contrib/brushexport/plugin.cpp index 274c840e..8e498987 100644 --- a/contrib/brushexport/plugin.cpp +++ b/contrib/brushexport/plugin.cpp @@ -24,7 +24,6 @@ #include "qerplugin.h" #include -#include #include "debugging/debugging.h" #include "string/string.h" @@ -50,11 +49,11 @@ bool IsWindowOpen( void ); namespace BrushExport { -GtkWindow* g_mainwnd; +ui::Window g_mainwnd; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = (GtkWindow*)pMainWidget; - ASSERT_NOTNULL( g_mainwnd ); + g_mainwnd = ui::Window(GTK_WINDOW(pMainWidget)); + ASSERT_TRUE( g_mainwnd ); return ""; } const char* getName(){ @@ -69,7 +68,7 @@ const char* getCommandTitleList(){ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" + GlobalRadiant().m_pfnMessageBox( g_mainwnd, "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" "Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...", eMB_OK, eMB_ICONDEFAULT ); diff --git a/contrib/brushexport/support.cpp b/contrib/brushexport/support.cpp index 79c5e145..768f213a 100644 --- a/contrib/brushexport/support.cpp +++ b/contrib/brushexport/support.cpp @@ -1,8 +1,9 @@ #include +#include #include "support.h" -GtkWidget* +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ){ GtkWidget *parent, *found_widget; @@ -13,7 +14,7 @@ lookup_widget( GtkWidget *widget, parent = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); } else{ - parent = widget->parent; + parent = gtk_widget_get_parent(widget); } if ( !parent ) { parent = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), "GladeParentKey" ); @@ -29,5 +30,5 @@ lookup_widget( GtkWidget *widget, if ( !found_widget ) { g_warning( "Widget not found: %s", widget_name ); } - return found_widget; + return ui::Widget(found_widget); } diff --git a/contrib/brushexport/support.h b/contrib/brushexport/support.h index e8f4cb04..8a64631d 100644 --- a/contrib/brushexport/support.h +++ b/contrib/brushexport/support.h @@ -7,6 +7,7 @@ #endif #include +#include /* * Public Functions. @@ -18,5 +19,5 @@ * or alternatively any widget in the component, and the name of the widget * you want returned. */ -GtkWidget* lookup_widget( GtkWidget *widget, +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ); diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index acd2fbd4..460f8abf 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -69,10 +69,10 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // char buf[128]; // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "New Camera" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -81,21 +81,21 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -105,17 +105,17 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" ); gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 ); gtk_widget_show( fixed ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) ); interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" ); gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 ); gtk_widget_show( interpolated ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) ); spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" ); gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 ); gtk_widget_show( spline ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) ); // -------------------------- // @@ -125,21 +125,21 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -314,7 +314,7 @@ static gint ci_pathlist_changed( GtkWidget *widget, gpointer data ){ } // start edit mode - if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) { + if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) { DoStartEdit( GetCurrentCam() ); } @@ -362,10 +362,10 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -374,21 +374,21 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - name = gtk_entry_new(); + name = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), name, FALSE, FALSE, 0 ); gtk_widget_show( name ); @@ -407,21 +407,21 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -481,10 +481,10 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Target" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -493,21 +493,21 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - name = gtk_entry_new(); + name = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), name, TRUE, TRUE, 0 ); gtk_widget_show( name ); @@ -516,15 +516,15 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -534,17 +534,17 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" ); gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 ); gtk_widget_show( fixed ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) ); interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" ); gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 ); gtk_widget_show( interpolated ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) ); spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" ); gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 ); gtk_widget_show( spline ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) ); // -------------------------- // @@ -554,21 +554,21 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -756,7 +756,7 @@ static gint ci_camlist_changed( GtkWidget *widget, gpointer data ){ // start edit mode g_iActiveTarget = -1; - if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) { + if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) { DoStartEdit( GetCurrentCam() ); } @@ -829,10 +829,10 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Event" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -841,21 +841,21 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -866,7 +866,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ eventWidget[i] = gtk_radio_button_new_with_label( eventTypeRadio, camEventStr[i] ); gtk_box_pack_start( GTK_BOX( vbox2 ), eventWidget[i], FALSE, FALSE, 3 ); gtk_widget_show( eventWidget[i] ); - eventTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( eventWidget[i] ) ); + eventTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( eventWidget[i] ) ); if ( camEventFlags[i][1] == false ) { gtk_widget_set_sensitive( eventWidget[i], FALSE ); } @@ -874,15 +874,15 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Parameters:" ); + w = ui::Label( "Parameters:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - parameters = gtk_entry_new(); + parameters = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), parameters, TRUE, TRUE, 0 ); gtk_widget_show( parameters ); @@ -894,21 +894,21 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -995,11 +995,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ GtkWidget *window, *w, *vbox, *hbox, *table, *frame; // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( ci_close ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL ); - // gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( ci_close ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "expose_event", G_CALLBACK( ci_expose ), NULL ); + // g_signal_connect( GTK_OBJECT (window), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); // don't use show, as you don't want to have it displayed on startup ;-) @@ -1010,7 +1010,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // the table // -------------------------- // - table = gtk_table_new( 3, 2, FALSE ); + table = ui::Table( 3, 2, FALSE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( window ), table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1020,7 +1020,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // the properties column // -------------------------- // - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1028,11 +1028,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "File:" ); + w = ui::Label( "File:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1042,52 +1042,52 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - g_pCamName = gtk_entry_new(); + g_pCamName = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), g_pCamName, FALSE, FALSE, 0 ); gtk_widget_show( g_pCamName ); - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCamType = GTK_LABEL( w ); RefreshCamListCombo(); - gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pCamListCombo )->entry ), FALSE ); - gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pCamListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_camlist_changed ), NULL ); + gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pCamListCombo )->entry ), FALSE ); + g_signal_connect( GTK_OBJECT( GTK_COMBO( g_pCamListCombo )->entry ), "changed", G_CALLBACK( ci_camlist_changed ), NULL ); // -------------------------- // - frame = gtk_frame_new( "Path and Target editing" ); + frame = ui::Frame( "Path and Target editing" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Edit:" ); + w = ui::Label( "Edit:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1097,28 +1097,28 @@ GtkWidget *CreateCameraInspectorDialog( void ){ RefreshPathListCombo(); - gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pPathListCombo )->entry ), FALSE ); - gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pPathListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_pathlist_changed ), NULL ); + gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pPathListCombo )->entry ), FALSE ); + g_signal_connect( GTK_OBJECT( GTK_COMBO( g_pPathListCombo )->entry ), "changed", G_CALLBACK( ci_pathlist_changed ), NULL ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); g_pEditModeEditRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Edit Points" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeEditRadioButton, FALSE, FALSE, 3 ); gtk_widget_show( g_pEditModeEditRadioButton ); - g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) ); + g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) ); - gtk_signal_connect( GTK_OBJECT( g_pEditModeEditRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_edit ), NULL ); + g_signal_connect( GTK_OBJECT( g_pEditModeEditRadioButton ), "clicked", G_CALLBACK( ci_editmode_edit ), NULL ); g_pEditModeAddRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Add Points" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeAddRadioButton, FALSE, FALSE, 3 ); gtk_widget_show( g_pEditModeAddRadioButton ); - g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) ); + g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) ); - gtk_signal_connect( GTK_OBJECT( g_pEditModeAddRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_add ), NULL ); + g_signal_connect( GTK_OBJECT( g_pEditModeAddRadioButton ), "clicked", G_CALLBACK( ci_editmode_add ), NULL ); // see if we should use a different default if ( g_iEditMode == 1 ) { @@ -1126,141 +1126,141 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE ); } - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pPathType = GTK_LABEL( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Rename..." ); + w = ui::Button( "Rename..." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_rename ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_rename ), NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Add Target..." ); + w = ui::Button( "Add Target..." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add_target ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_add_target ), NULL ); gtk_widget_show( w ); // not available in splines library /*w = gtk_button_new_with_label( "Delete Selected" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_delete_selected ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_delete_selected ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Select All" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_select_all ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_select_all ), NULL ); gtk_widget_show( w );*/ // -------------------------- // - frame = gtk_frame_new( "Time" ); + frame = ui::Frame( "Time" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Length (seconds):" ); + w = ui::Label( "Length (seconds):" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - g_pSecondsEntry = gtk_entry_new(); + g_pSecondsEntry = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), g_pSecondsEntry, FALSE, FALSE, 0 ); gtk_widget_show( g_pSecondsEntry ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Current Time: " ); + w = ui::Label( "Current Time: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCurrentTime = GTK_LABEL( w ); - w = gtk_label_new( " of " ); + w = ui::Label( " of " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pTotalTime = GTK_LABEL( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - g_pTimeLine = GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0, 30000, 100, 250, 0 ) ); - gtk_signal_connect( GTK_OBJECT( g_pTimeLine ), "value_changed", GTK_SIGNAL_FUNC( ci_timeline_changed ), NULL ); - w = gtk_hscale_new( g_pTimeLine ); + g_pTimeLine = ui::Adjustment( 0, 0, 30000, 100, 250, 0 ); + g_signal_connect( GTK_OBJECT( g_pTimeLine ), "value_changed", G_CALLBACK( ci_timeline_changed ), NULL ); + w = ui::HScale( g_pTimeLine ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); gtk_scale_set_draw_value( GTK_SCALE( w ), FALSE ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - g_pTrackCamera = gtk_check_button_new_with_label( "Track Camera" ); + g_pTrackCamera = ui::CheckButton( "Track Camera" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pTrackCamera, FALSE, FALSE, 0 ); gtk_widget_show( g_pTrackCamera ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Events:" ); + w = ui::Label( "Events:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_scrolled_window_new( NULL, NULL ); - gtk_widget_set_usize( w, 0, 150 ); + w = ui::ScrolledWindow(); + gtk_widget_set_size_request( w, 0, 150 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); g_pEventsList = gtk_clist_new( 3 ); gtk_container_add( GTK_CONTAINER( w ), g_pEventsList ); - //gtk_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", GTK_SIGNAL_FUNC (proplist_select_row), NULL); + //g_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", G_CALLBACK (proplist_select_row), NULL); gtk_clist_set_selection_mode( GTK_CLIST( g_pEventsList ), GTK_SELECTION_BROWSE ); gtk_clist_column_titles_hide( GTK_CLIST( g_pEventsList ) ); gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 0, TRUE ); @@ -1268,18 +1268,18 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 2, TRUE ); gtk_widget_show( g_pEventsList ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 ); gtk_widget_show( vbox ); - w = gtk_button_new_with_label( "Add..." ); + w = ui::Button( "Add..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_add ), NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Del" ); + w = ui::Button( "Del" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_del ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_del ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1301,12 +1301,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "New..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_new ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_new ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Load..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_load ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_load ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1319,12 +1319,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Save..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_save ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_save ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Unload" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_unload ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_unload ), NULL ); gtk_widget_show( w ); hbox = gtk_hbox_new( FALSE, 5 ); @@ -1333,12 +1333,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Apply" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_apply ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_apply ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Preview" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_preview ), NULL ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_preview ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1355,8 +1355,8 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Close" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_close ), NULL ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( ci_close ), NULL ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index bfaf9849..d0639f0a 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -1346,7 +1346,7 @@ void create_tooltips(){ GtkWidget* create_main_dialog(){ GtkWidget *dlg, *vbox, *hbox, *hbox2, *button, *notebook, *frame, *table, *table2; GtkWidget *check, *spin, *radio, *label, *entry, *scale; - GtkObject *adj; + ui::Adjustment adj; GSList *group; int i; const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" }; @@ -1355,13 +1355,13 @@ GtkWidget* create_main_dialog(){ const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90", "Wall facing 180","Wall facing 270" }; - g_pWnd = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + g_pWnd = dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( main_close ), NULL ); // g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_container_add( GTK_CONTAINER( dlg ), hbox ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); @@ -1374,23 +1374,23 @@ GtkWidget* create_main_dialog(){ gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_TOP ); g_object_set_data( G_OBJECT( dlg ), "notebook", notebook ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "General" ); + label = ui::Label( "General" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), table, label ); - frame = gtk_frame_new( "Game" ); + frame = ui::Frame( "Game" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); + vbox = ui::VBox( TRUE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( frame ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); @@ -1400,18 +1400,18 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, games[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); game_radios[i] = radio; g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_game ), GINT_TO_POINTER( i ) ); } - frame = gtk_frame_new( "Waveform" ); + frame = ui::Frame( "Waveform" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); + vbox = ui::VBox( TRUE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( frame ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); @@ -1421,18 +1421,18 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, waveforms[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); wave_radios[i] = radio; g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_wave ), GINT_TO_POINTER( i ) ); } - frame = gtk_frame_new( "Orientation" ); + frame = ui::Frame( "Orientation" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); + vbox = ui::VBox( TRUE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( frame ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); @@ -1442,12 +1442,12 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, orientations[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); plane_radios[i] = radio; g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_plane ), GINT_TO_POINTER( i ) ); } - table2 = gtk_table_new( 4, 2, FALSE ); + table2 = ui::Table( 4, 2, FALSE ); gtk_widget_show( table2 ); gtk_table_set_row_spacings( GTK_TABLE( table2 ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table2 ), 5 ); @@ -1455,7 +1455,7 @@ GtkWidget* create_main_dialog(){ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Wavelength:" ); + label = ui::Label( "Wavelength:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1463,7 +1463,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Max. amplitude:" ); + label = ui::Label( "Max. amplitude:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1471,7 +1471,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Roughness:" ); + label = ui::Label( "Roughness:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1479,7 +1479,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Random seed:" ); + label = ui::Label( "Random seed:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1487,298 +1487,298 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "wavelength", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &WaveLength ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "amplitude", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Amplitude ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "roughness", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Roughness ); - adj = gtk_adjustment_new( 1, 1, 32767, 1, 10, 0 ); + adj = ui::Adjustment( 1, 1, 32767, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( general_random ), NULL ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table2 ), spin, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "random", spin ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Extents" ); + label = ui::Label( "Extents" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); - frame = gtk_frame_new( "Extents" ); + frame = ui::Frame( "Extents" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); - table = gtk_table_new( 3, 4, FALSE ); + table = ui::Table( 3, 4, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmin_text", label ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmax_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmin_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmax_text", label ); - label = gtk_label_new( "Lower-left" ); + label = ui::Label( "Lower-left" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right" ); + label = ui::Label( "Upper-right" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "hmin", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hll ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "hmax", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hur ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "vmin", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vll ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "vmax", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vur ); - frame = gtk_frame_new( "Divisions" ); + frame = ui::Frame( "Divisions" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "nh_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "nv_text", label ); - adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 ); + adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NH ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "nh", spin ); - adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 ); + adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NV ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "nv", spin ); - check = gtk_check_button_new_with_label( "Use Bezier patches" ); + check = ui::CheckButton( "Use Bezier patches" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "use_patches", check ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_use_patches ), NULL ); // ^Fishman - Snap to grid, replaced scroll bar with a texbox. - label = gtk_label_new( "Snap to grid:" ); + label = ui::Label( "Snap to grid:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); gtk_object_set_data( GTK_OBJECT( dlg ), "snap_text", label ); - adj = gtk_adjustment_new( 8, 0, 256, 1, 10, 0 ); + adj = ui::Adjustment( 8, 0, 256, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_snaptogrid_spin ), &SP ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( vbox ), spin, FALSE, TRUE, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "sp", spin ); // ^Fishman - End of Snap to grid code. - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 10 ); - label = gtk_label_new( "Decimate:" ); + label = ui::Label( "Decimate:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 0, 0, 110, 1, 10, 0 ); + adj = ui::Adjustment( 0, 0, 110, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_decimate ), NULL ); g_object_set_data( G_OBJECT( dlg ), "decimate_adj", adj ); - scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + scale = ui::HScale( adj ); gtk_widget_show( scale ); gtk_box_pack_start( GTK_BOX( hbox2 ), scale, TRUE, TRUE, 0 ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_RIGHT ); gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); g_object_set_data( G_OBJECT( dlg ), "decimate", scale ); - frame = gtk_frame_new( "Corner values" ); + frame = ui::Frame( "Corner values" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 3, 4, FALSE ); + table = ui::Table( 3, 4, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Upper-left:" ); + label = ui::Label( "Upper-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-left:" ); + label = ui::Label( "Lower-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right:" ); + label = ui::Label( "Upper-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-right:" ); + label = ui::Label( "Lower-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z01", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z01 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z00", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z00 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z11", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z11 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z10", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z10 ); - check = gtk_check_button_new_with_label( "Linear borders" ); + check = ui::CheckButton( "Linear borders" ); gtk_widget_show( check ); gtk_table_attach( GTK_TABLE( table ), check, 0, 4, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1786,34 +1786,34 @@ GtkWidget* create_main_dialog(){ g_object_set_data( G_OBJECT( dlg ), "linearborder", check ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_linearborder ), NULL ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Bitmap" ); + label = ui::Label( "Bitmap" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "" ); + label = ui::Label( "" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_note", label ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Filename:" ); + label = ui::Label( "Filename:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_text1", label ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1821,34 +1821,34 @@ GtkWidget* create_main_dialog(){ g_object_set_data( G_OBJECT( dlg ), "bmp_file", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( bitmap_file_entryfocusout ), NULL ); - hbox2 = gtk_hbox_new( TRUE, 5 ); + hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - button = gtk_button_new_with_label( "Browse..." ); + button = ui::Button( "Browse..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_file_browse", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_browse ), NULL ); - button = gtk_button_new_with_label( "Reload" ); + button = ui::Button( "Reload" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_reload", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_reload ), NULL ); - table = gtk_table_new( 2, 2, TRUE ); + table = ui::Table( 2, 2, TRUE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Map color 0 to:" ); + label = ui::Label( "Map color 0 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1857,7 +1857,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Map color 255 to:" ); + label = ui::Label( "Map color 255 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1866,41 +1866,41 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_black", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.black_value ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_white", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.white_value ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Fix Points" ); + label = ui::Label( "Fix Points" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "Click on a vertex in the lower half of the preview window,\n" + label = ui::Label( "Click on a vertex in the lower half of the preview window,\n" "then use the arrow keys or text box to assign a value.\n" "Use Ctrl+Click to select multiple vertices/toggle a\n" "selection. Use Shift+Click to select a range of vertices.\n\n" @@ -1909,14 +1909,14 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); - table = gtk_table_new( 3, 3, FALSE ); + table = ui::Table( 3, 3, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Value:" ); + label = ui::Label( "Value:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1924,7 +1924,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_value_text", label ); - label = gtk_label_new( "Range affected:" ); + label = ui::Label( "Range affected:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1932,7 +1932,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_range_text", label ); - label = gtk_label_new( "Rate of change:" ); + label = ui::Label( "Rate of change:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -1940,246 +1940,246 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_rate_text", label ); - adj = gtk_adjustment_new( 0, -65536, 65536, 1, 16, 0 ); + adj = ui::Adjustment( 0, -65536, 65536, 1, 16, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( fix_value_changed ), NULL ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_EXPAND ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_value", spin ); g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( fix_value_entryfocusout ), NULL ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_range", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_range_entryfocusout ), NULL ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_rate", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_rate_entryfocusout ), NULL ); - button = gtk_button_new_with_label( "Free" ); + button = ui::Button( "Free" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_free", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_free ), NULL ); - button = gtk_button_new_with_label( "Free All" ); + button = ui::Button( "Free All" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_freeall", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_freeall ), NULL ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Texture" ); + label = ui::Label( "Texture" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); // ^Fishman - Modified to add more labels and textboxes. - table = gtk_table_new( 5, 2, FALSE ); + table = ui::Table( 5, 2, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Surface:" ); + label = ui::Label( "Surface:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Other:" ); + label = ui::Label( "Other:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Steep:" ); + label = ui::Label( "Steep:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture1", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 0 ) ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture2", entry ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 1 ) ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture3", entry ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); - label = gtk_label_new( "\"Steep\" angle:" ); + label = ui::Label( "\"Steep\" angle:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 60, 0, 90, 1, 10, 0 ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 60, 0, 90, 1, 10, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "tex_slant", spin ); - table = gtk_table_new( 2, 4, TRUE ); + table = ui::Table( 2, 4, TRUE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Offset " ); + label = ui::Label( "Offset " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Scale " ); + label = ui::Label( "Scale " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texoffsetx", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texoffsety", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texscalex", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texscaley", entry ); - check = gtk_check_button_new_with_label( "Use detail brushes" ); + check = ui::CheckButton( "Use detail brushes" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "detail", check ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_detail ), NULL ); - check = gtk_check_button_new_with_label( "Detail hint brushes" ); + check = ui::CheckButton( "Detail hint brushes" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "hint", check ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_hint ), NULL ); // ^Fishman - Add terrain key to func_group. - check = gtk_check_button_new_with_label( "Add terrain key" ); + check = ui::CheckButton( "Add terrain key" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "terrain_ent", check ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_terrainent ), NULL ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "go", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_go ), NULL ); - label = gtk_label_new( "Settings:" ); + label = ui::Label( "Settings:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "Open..." ); + button = ui::Button( "Open..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "open", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_open ), NULL ); - button = gtk_button_new_with_label( "Save as..." ); + button = ui::Button( "Save as..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "save", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_save ), NULL ); - button = gtk_button_new_with_label( "Defaults" ); + button = ui::Button( "Defaults" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "defaults", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_defaults ), NULL ); - button = gtk_button_new_with_label( "About..." ); + button = ui::Button( "About..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_about ), NULL ); - check = gtk_check_button_new_with_label( "Preview" ); + check = ui::CheckButton( "Preview" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( main_preview ), NULL ); g_object_set_data( G_OBJECT( dlg ), "main_preview", check ); // ^Fishman - Antializing for the preview window. - check = gtk_check_button_new_with_label( "Antialised lines" ); + check = ui::CheckButton( "Antialised lines" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "main_antialiasing", check ); diff --git a/contrib/gtkgensurf/gensurf.cpp b/contrib/gtkgensurf/gensurf.cpp index b28416e2..cecc8ab2 100644 --- a/contrib/gtkgensurf/gensurf.cpp +++ b/contrib/gtkgensurf/gensurf.cpp @@ -409,7 +409,7 @@ void WriteIniFile( const char *file ){ } void UpdatePreview( bool DataChange ){ - if ( g_pWndPreview && GTK_WIDGET_VISIBLE( g_pWndPreview ) ) { + if ( g_pWndPreview && gtk_widget_get_visible( g_pWndPreview ) ) { if ( DataChange ) { GenerateXYZ(); } diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index ba0c43d5..00c74aaa 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -371,50 +371,50 @@ void CreateViewWindow(){ azimuth = PI / 6.; #endif - g_pWndPreview = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + g_pWndPreview = dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", GTK_SIGNAL_FUNC( preview_close ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "delete_event", G_CALLBACK( preview_close ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pWnd ) ); gtk_window_set_default_size( GTK_WINDOW( dlg ), 300, 400 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); #ifndef ISOMETRIC - hbox = gtk_hbox_new( TRUE, 5 ); + hbox = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 3 ); - label = gtk_label_new( "Elevation" ); + label = ui::Label( "Elevation" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 30, -90, 90, 1, 10, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &elevation ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 30, -90, 90, 1, 10, 0 ); + g_signal_connect( adj, "value_changed", G_CALLBACK( preview_spin ), &elevation ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 ); g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &elevation ); - adj = gtk_adjustment_new( 30, 0, 359, 1, 10, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &azimuth ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 30, 0, 359, 1, 10, 0 ); + g_signal_connect( adj, "value_changed", G_CALLBACK( preview_spin ), &azimuth ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); gtk_box_pack_end( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 ); - label = gtk_label_new( "Azimuth" ); + label = ui::Label( "Azimuth" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_end( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth ); #endif - frame = gtk_frame_new( NULL ); + frame = ui::Frame( nullptr ); gtk_widget_show( frame ); gtk_frame_set_shadow_type( GTK_FRAME( frame ), GTK_SHADOW_IN ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); @@ -422,10 +422,10 @@ void CreateViewWindow(){ g_pPreviewWidget = g_UIGtkTable.m_pfn_glwidget_new( FALSE, NULL ); gtk_widget_set_events( g_pPreviewWidget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "motion_notify_event", GTK_SIGNAL_FUNC( motion ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "button_press_event", - GTK_SIGNAL_FUNC( button_press ), NULL ); + g_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "expose_event", G_CALLBACK( expose ), NULL ); + g_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "motion_notify_event", G_CALLBACK( motion ), NULL ); + g_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "button_press_event", + G_CALLBACK( button_press ), NULL ); gtk_widget_show( g_pPreviewWidget ); gtk_container_add( GTK_CONTAINER( frame ), g_pPreviewWidget ); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 44393ea1..f2e3d89b 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -84,22 +84,22 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ GtkWidget *window, *w, *vbox, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window = ui::Window( ui::window_type::TOP ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop ); gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -108,72 +108,72 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( mode == MB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = IDOK; } else if ( mode == MB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else if ( mode == MB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); ret = IDNO; } diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index 1baec68d..c90c319f 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -20,6 +20,7 @@ #include "AboutDialog.h" #include #include +#include #include "version.h" #include "gtkutil/pointer.h" @@ -52,40 +53,39 @@ void DoAboutDlg(){ GtkWidget *dlg, *hbox, *vbox, *button, *label; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_widget_show( hbox ); gtk_container_add( GTK_CONTAINER( dlg ), hbox ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 ); - label = gtk_label_new( "Version 1.000\n\n" + char const *label_text = "Version 1.000\n\n" "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n" "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n" "Built against NetRadiant " RADIANT_VERSION "\n" - __DATE__ - ); + __DATE__; gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); - vbox = gtk_vbox_new( FALSE, 0 ); + vbox = ui::VBox( FALSE, 0 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); gtk_grab_add( dlg ); gtk_widget_show( dlg ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index a91a6a2b..acb9f5b5 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -20,6 +20,7 @@ #include "ConfigDialog.h" #include #include +#include #include "gtkutil/pointer.h" #include "iscenegraph.h" @@ -54,23 +55,27 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer static int DoColor( PackedColour *c ){ GtkWidget* dlg; - double clr[4]; + GdkColor clr; int loop = 1, ret = IDCANCEL; - clr[0] = ( (double)GetRValue( *c ) ) / 255.0; - clr[1] = ( (double)GetGValue( *c ) ) / 255.0; - clr[2] = ( (double)GetBValue( *c ) ) / 255.0; + clr.red = (guint16) (GetRValue(*c) * (65535 / 255)); + clr.blue = (guint16) (GetGValue(*c) * (65535 / 255)); + clr.green = (guint16) (GetBValue(*c) * (65535 / 255)); dlg = gtk_color_selection_dialog_new( "Choose Color" ); - gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); + g_signal_connect( GTK_OBJECT( dlg ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); + + GtkWidget *ok_button, *cancel_button; + g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + + g_signal_connect( GTK_OBJECT(ok_button), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + g_signal_connect( GTK_OBJECT(cancel_button), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); @@ -80,13 +85,13 @@ static int DoColor( PackedColour *c ){ while ( loop ) gtk_main_iteration(); - gtk_color_selection_get_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); + gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); gtk_grab_remove( dlg ); gtk_widget_destroy( dlg ); if ( ret == IDOK ) { - *c = RGB( clr[0] * 255, clr[1] * 255, clr[2] * 255 ); + *c = RGB( clr.red / (65535 / 255), clr.green / (65535 / 255), clr.blue / (65535 / 255)); } return ret; @@ -125,7 +130,7 @@ static void SetClipText( GtkWidget* label ){ } static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ - portals.width_2d = static_cast( adj->value ); + portals.width_2d = static_cast( gtk_adjustment_get_value(adj) ); Set2DText( GTK_WIDGET( data ) ); Portals_shadersChanged(); @@ -133,21 +138,21 @@ static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ } static void OnScroll3d( GtkAdjustment *adj, gpointer data ){ - portals.width_3d = static_cast( adj->value ); + portals.width_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DText( GTK_WIDGET( data ) ); SceneChangeNotify(); } static void OnScrollTrans( GtkAdjustment *adj, gpointer data ){ - portals.trans_3d = static_cast( adj->value ); + portals.trans_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DTransText( GTK_WIDGET( data ) ); SceneChangeNotify(); } static void OnScrollClip( GtkAdjustment *adj, gpointer data ){ - portals.clip_range = static_cast( adj->value ); + portals.clip_range = static_cast( gtk_adjustment_get_value(adj) ); SetClipText( GTK_WIDGET( data ) ); SceneChangeNotify(); @@ -239,235 +244,220 @@ static void OnClip( GtkWidget *widget, gpointer data ){ void DoConfigDialog(){ GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame; - GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item; + GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *item; GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck; GtkWidget *transslider, *translabel, *clipslider, *cliplabel; GtkWidget *show2check, *show3check, *portalcheck; int loop = 1, ret = IDCANCEL; - GtkObject *adj; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - frame = gtk_frame_new( "3D View" ); + frame = ui::Frame( "3D View" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox2 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, TRUE, 0 ); - adj = gtk_adjustment_new( portals.width_3d, 2, 40, 1, 1, 0 ); - lw3slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + auto adj = ui::Adjustment( portals.width_3d, 2, 40, 1, 1, 0 ); + lw3slider = ui::HScale( adj ); gtk_widget_show( lw3slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw3slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw3slider ), FALSE ); - lw3label = gtk_label_new( "" ); + lw3label = ui::Label( "" ); gtk_widget_show( lw3label ); gtk_box_pack_start( GTK_BOX( hbox ), lw3label, FALSE, TRUE, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll3d ), lw3label ); + g_signal_connect( GTK_OBJECT(adj), "value_changed", G_CALLBACK( OnScroll3d ), lw3label ); - table = gtk_table_new( 2, 4, FALSE ); + table = ui::Table( 2, 4, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - button = gtk_button_new_with_label( "Color" ); + button = ui::Button( "Color" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor3d ), NULL ); + g_signal_connect( GTK_OBJECT( button ), "clicked", G_CALLBACK( OnColor3d ), NULL ); - button = gtk_button_new_with_label( "Depth Color" ); + button = ui::Button( "Depth Color" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColorFog ), NULL ); + g_signal_connect( GTK_OBJECT( button ), "clicked", G_CALLBACK( OnColorFog ), NULL ); - aa3check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" ); + aa3check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" ); gtk_widget_show( aa3check ); gtk_table_attach( GTK_TABLE( table ), aa3check, 1, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( aa3check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias3d ), NULL ); + g_signal_connect( GTK_OBJECT( aa3check ), "toggled", G_CALLBACK( OnAntiAlias3d ), NULL ); - depthcheck = gtk_check_button_new_with_label( "Depth Cue" ); + depthcheck = ui::CheckButton( "Depth Cue" ); gtk_widget_show( depthcheck ); gtk_table_attach( GTK_TABLE( table ), depthcheck, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( depthcheck ), "toggled", GTK_SIGNAL_FUNC( OnFog ), NULL ); + g_signal_connect( GTK_OBJECT( depthcheck ), "toggled", G_CALLBACK( OnFog ), NULL ); - linescheck = gtk_check_button_new_with_label( "Lines" ); + linescheck = ui::CheckButton( "Lines" ); gtk_widget_show( linescheck ); gtk_table_attach( GTK_TABLE( table ), linescheck, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( linescheck ), "toggled", GTK_SIGNAL_FUNC( OnLines ), NULL ); + g_signal_connect( GTK_OBJECT( linescheck ), "toggled", G_CALLBACK( OnLines ), NULL ); - polyscheck = gtk_check_button_new_with_label( "Polygons" ); + polyscheck = ui::CheckButton( "Polygons" ); gtk_widget_show( polyscheck ); gtk_table_attach( GTK_TABLE( table ), polyscheck, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( polyscheck ), "toggled", GTK_SIGNAL_FUNC( OnPoly ), NULL ); + g_signal_connect( GTK_OBJECT( polyscheck ), "toggled", G_CALLBACK( OnPoly ), NULL ); - zlist = gtk_option_menu_new(); + auto zlist = ui::ComboBoxText(); gtk_widget_show( zlist ); gtk_box_pack_start( GTK_BOX( vbox2 ), zlist, TRUE, FALSE, 0 ); - menu = gtk_menu_new(); - gtk_widget_show( menu ); - gtk_option_menu_set_menu( GTK_OPTION_MENU( zlist ), menu ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Test and Write (recommended for solid or no polygons)" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 0 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Test Only (recommended for transparent polygons)" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 1 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Off" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 2 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - table = gtk_table_new( 2, 2, FALSE ); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Test and Write (recommended for solid or no polygons)"); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Test Only (recommended for transparent polygons)"); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Off"); + + g_signal_connect(G_OBJECT(zlist), "changed", G_CALLBACK(+[](GtkComboBox *self, void *) { + OnSelchangeZbuffer(GTK_WIDGET(self), GINT_TO_POINTER(gtk_combo_box_get_active(self))); + }), nullptr); + + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - adj = gtk_adjustment_new( portals.trans_3d, 0, 100, 1, 1, 0 ); - transslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.trans_3d, 0, 100, 1, 1, 0 ); + transslider = ui::HScale( adj ); gtk_widget_show( transslider ); gtk_table_attach( GTK_TABLE( table ), transslider, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( transslider ), FALSE ); - translabel = gtk_label_new( "" ); + translabel = ui::Label( "" ); gtk_widget_show( translabel ); gtk_table_attach( GTK_TABLE( table ), translabel, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( translabel ), 0.0, 0.0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollTrans ), translabel ); + g_signal_connect( GTK_OBJECT(adj), "value_changed", G_CALLBACK( OnScrollTrans ), translabel ); - adj = gtk_adjustment_new( portals.clip_range, 1, 128, 1, 1, 0 ); - clipslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.clip_range, 1, 128, 1, 1, 0 ); + clipslider = ui::HScale( adj ); gtk_widget_show( clipslider ); gtk_table_attach( GTK_TABLE( table ), clipslider, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( clipslider ), FALSE ); - cliplabel = gtk_label_new( "" ); + cliplabel = ui::Label( "" ); gtk_widget_show( cliplabel ); gtk_table_attach( GTK_TABLE( table ), cliplabel, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( cliplabel ), 0.0, 0.0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollClip ), cliplabel ); + g_signal_connect( GTK_OBJECT(adj), "value_changed", G_CALLBACK( OnScrollClip ), cliplabel ); - hbox = gtk_hbox_new( TRUE, 5 ); + hbox = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - show3check = gtk_check_button_new_with_label( "Show" ); + show3check = ui::CheckButton( "Show" ); gtk_widget_show( show3check ); gtk_box_pack_start( GTK_BOX( hbox ), show3check, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( show3check ), "toggled", GTK_SIGNAL_FUNC( OnConfig3d ), NULL ); + g_signal_connect( GTK_OBJECT( show3check ), "toggled", G_CALLBACK( OnConfig3d ), NULL ); - portalcheck = gtk_check_button_new_with_label( "Portal cubic clipper" ); + portalcheck = ui::CheckButton( "Portal cubic clipper" ); gtk_widget_show( portalcheck ); gtk_box_pack_start( GTK_BOX( hbox ), portalcheck, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( portalcheck ), "toggled", GTK_SIGNAL_FUNC( OnClip ), NULL ); + g_signal_connect( GTK_OBJECT( portalcheck ), "toggled", G_CALLBACK( OnClip ), NULL ); - frame = gtk_frame_new( "2D View" ); + frame = ui::Frame( "2D View" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox2 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - adj = gtk_adjustment_new( portals.width_2d, 2, 40, 1, 1, 0 ); - lw2slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.width_2d, 2, 40, 1, 1, 0 ); + lw2slider = ui::HScale( adj ); gtk_widget_show( lw2slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw2slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw2slider ), FALSE ); - lw2label = gtk_label_new( "" ); + lw2label = ui::Label( "" ); gtk_widget_show( lw2label ); gtk_box_pack_start( GTK_BOX( hbox ), lw2label, FALSE, TRUE, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll2d ), lw2label ); + g_signal_connect( GTK_OBJECT(adj), "value_changed", G_CALLBACK( OnScroll2d ), lw2label ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - button = gtk_button_new_with_label( "Color" ); + button = ui::Button( "Color" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor2d ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", G_CALLBACK( OnColor2d ), NULL ); + gtk_widget_set_size_request( button, 60, -1 ); - aa2check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" ); + aa2check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" ); gtk_widget_show( aa2check ); gtk_box_pack_start( GTK_BOX( hbox ), aa2check, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( aa2check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias2d ), NULL ); + g_signal_connect( GTK_OBJECT( aa2check ), "toggled", G_CALLBACK( OnAntiAlias2d ), NULL ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - show2check = gtk_check_button_new_with_label( "Show" ); + show2check = ui::CheckButton( "Show" ); gtk_widget_show( show2check ); gtk_box_pack_start( GTK_BOX( hbox ), show2check, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( show2check ), "toggled", GTK_SIGNAL_FUNC( OnConfig2d ), NULL ); + g_signal_connect( GTK_OBJECT( show2check ), "toggled", G_CALLBACK( OnConfig2d ), NULL ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); // initialize dialog gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( show2check ), portals.show_2d ); @@ -479,7 +469,7 @@ void DoConfigDialog(){ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( polyscheck ), portals.polygons ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( linescheck ), portals.lines ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( aa3check ), portals.aa_3d ); - gtk_option_menu_set_history( GTK_OPTION_MENU( zlist ), portals.zbuffer ); + gtk_combo_box_set_active(zlist, portals.zbuffer); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( portalcheck ), portals.clip ); Set3DText( lw3label ); diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index f3d4df8d..eaee56c4 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -55,47 +55,22 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer return TRUE; } -static void file_sel_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; - int *loop; - char **filename; - - parent = gtk_widget_get_toplevel( widget ); - loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); - filename = (char**)g_object_get_data( G_OBJECT( parent ), "filename" ); - - *loop = 0; - if ( gpointer_to_int( data ) == IDOK ) { - *filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( parent ) ) ); - } -} - static void change_clicked( GtkWidget *widget, gpointer data ){ GtkWidget* file_sel; char* filename = NULL; - int loop = 1; - file_sel = gtk_file_selection_new( "Locate portal (.prt) file" ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDCANCEL ) ); - gtk_signal_connect( GTK_OBJECT( file_sel ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION( file_sel ) ); + file_sel = gtk_file_chooser_dialog_new ( "Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + nullptr); - g_object_set_data( G_OBJECT( file_sel ), "loop", &loop ); - g_object_set_data( G_OBJECT( file_sel ), "filename", &filename ); - gtk_file_selection_set_filename( GTK_FILE_SELECTION( file_sel ), portals.fn ); + gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn ); - gtk_grab_add( file_sel ); - gtk_widget_show( file_sel ); - - while ( loop ) - gtk_main_iteration(); - - gtk_grab_remove( file_sel ); - gtk_widget_destroy( file_sel ); + if (gtk_dialog_run (GTK_DIALOG (file_sel)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_sel)); + } + gtk_widget_destroy (file_sel); if ( filename != NULL ) { strcpy( portals.fn, filename ); @@ -108,60 +83,60 @@ int DoLoadPortalFileDialog(){ GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( dlg ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); - gtk_entry_set_editable( GTK_ENTRY( entry ), FALSE ); + gtk_editable_set_editable( GTK_EDITABLE( entry ), FALSE ); gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 0 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - check3d = gtk_check_button_new_with_label( "Show 3D" ); + check3d = ui::CheckButton( "Show 3D" ); gtk_widget_show( check3d ); gtk_box_pack_start( GTK_BOX( hbox ), check3d, FALSE, FALSE, 0 ); - check2d = gtk_check_button_new_with_label( "Show 2D" ); + check2d = ui::CheckButton( "Show 2D" ); gtk_widget_show( check2d ); gtk_box_pack_start( GTK_BOX( hbox ), check2d, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Change" ); + button = ui::Button( "Change" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( change_clicked ), entry ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", G_CALLBACK( change_clicked ), entry ); + gtk_widget_set_size_request( button, 60, -1 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Cancel" ); + button = ui::Button( "Cancel" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + g_signal_connect( GTK_OBJECT( button ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); strcpy( portals.fn, GlobalRadiant().getMapName() ); char* fn = strrchr( portals.fn, '.' ); diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 62e9abe6..ebe2e6c6 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -57,7 +57,7 @@ ShaderPlugPluginDependencies() : namespace Shaderplug { -GtkWindow* g_window; +ui::Window g_window; std::vector archives; std::set shaders; @@ -67,7 +67,7 @@ XmlTagBuilder TagBuilder; void CreateTagFile(); const char* init( void* hApp, void* pMainWidget ){ - g_window = GTK_WINDOW( pMainWidget ); + g_window = ui::Window(GTK_WINDOW( pMainWidget )); return ""; } const char* getName(){ @@ -81,7 +81,7 @@ const char* getCommandTitleList(){ } void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), "Shaderplug (1.0)\n\n" + GlobalRadiant().m_pfnMessageBox( g_window, "Shaderplug (1.0)\n\n" "by Shaderman (shaderman@gmx.net)", "About", eMB_OK, @@ -181,23 +181,23 @@ void CreateTagFile(){ strcat( message, "\nPlease restart Radiant now.\n" ); if ( file_exists( tagFile ) ) { - EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( g_window , "WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?", eMB_NOYES, eMB_ICONWARNING ); if ( result == eIDYES ) { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + GlobalRadiant().m_pfnMessageBox( g_window, "No shaders or textures found. No XML tag file created!\n" "", "ERROR", diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 50fb2cd8..7bc81d34 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -255,7 +255,7 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server void about_plugin_window(){ GtkWidget *window, *vbox, *label, *button; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create a window + 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 @@ -264,14 +264,14 @@ void about_plugin_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 = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically + 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 - label = gtk_label_new( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label + 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 gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box - button = gtk_button_new_with_label( "OK" ); // create a button with text + button = ui::Button( "OK" ); // create a button with text g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), window ); // 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 @@ -315,13 +315,12 @@ void GetOptimalCoordinates( AABB *levelBoundingBox ){ // MapCoordinator dialog window void MapCoordinator(){ GtkWidget *window, *vbox, *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button; - GtkAdjustment *spinner_adj_MinX, *spinner_adj_MinY, *spinner_adj_MaxX, *spinner_adj_MaxY; Entity *theWorldspawn = NULL; const char *buffer; char line[20]; // in any case we need a window to show the user what to do - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create the window + 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 @@ -330,7 +329,7 @@ void MapCoordinator(){ 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 = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically + 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 scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph @@ -366,48 +365,48 @@ void MapCoordinator(){ globalOutputStream() << "SunPlug: adviced mapcoordsmins=" << minX << " " << maxY << "\n"; // console info about mapcoordsmins globalOutputStream() << "SunPlug: adviced mapcoordsmaxs=" << maxX << " " << minY << "\n"; // console info about mapcoordsmaxs - spinner_adj_MinX = (GtkAdjustment *)gtk_adjustment_new( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value - spinner_adj_MinY = (GtkAdjustment *)gtk_adjustment_new( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value - spinner_adj_MaxX = (GtkAdjustment *)gtk_adjustment_new( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value - spinner_adj_MaxY = (GtkAdjustment *)gtk_adjustment_new( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value + auto spinner_adj_MinX = ui::Adjustment( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value + auto spinner_adj_MinY = ui::Adjustment( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value + 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 = gtk_button_new_with_label( "Get optimal mapcoords" ); // create button with text + 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 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 - table = gtk_table_new( 4, 3, TRUE ); // create table + table = ui::Table( 4, 3, TRUE ); // create table gtk_table_set_row_spacings( GTK_TABLE( table ), 8 ); // set row spacings gtk_table_set_col_spacings( GTK_TABLE( table ), 8 ); // set column spacings gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, FALSE, 2 ); // insert table into vbox - label = gtk_label_new( "x" ); // create label + label = ui::Label( "x" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 1, 2, 0, 1 ); // insert label into table - label = gtk_label_new( "y" ); // create label + label = ui::Label( "y" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 2, 3, 0, 1 ); // insert label into table - label = gtk_label_new( "mapcoordsmins" ); // create label + label = ui::Label( "mapcoordsmins" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 1, 2 ); // insert label into table - spinnerMinX = gtk_spin_button_new( spinner_adj_MinX, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMinX = ui::SpinButton( spinner_adj_MinX, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinX, 1, 2, 1, 2 ); // insert spinbox into table - spinnerMinY = gtk_spin_button_new( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMinY = ui::SpinButton( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinY, 2, 3, 1, 2 ); // insert spinbox into table - label = gtk_label_new( "mapcoordsmaxs" ); // create label + label = ui::Label( "mapcoordsmaxs" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 2, 3 ); // insert label into table - spinnerMaxX = gtk_spin_button_new( spinner_adj_MaxX, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMaxX = ui::SpinButton( spinner_adj_MaxX, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxX, 1, 2, 2, 3 ); // insert spinbox into table - spinnerMaxY = gtk_spin_button_new( spinner_adj_MaxY, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMaxY = ui::SpinButton( spinner_adj_MaxY, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxY, 2, 3, 2, 3 ); // insert spinbox into table // put the references to the spinboxes and the worldspawn into the global exchange @@ -417,22 +416,22 @@ void MapCoordinator(){ msp.spinner4 = GTK_SPIN_BUTTON( spinnerMaxY ); msp.worldspawn = theWorldspawn; - button = gtk_button_new_with_label( "Set" ); // create button with text + 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 gtk_table_attach_defaults( GTK_TABLE( table ), button, 1, 2, 3, 4 ); // insert button into table - button = gtk_button_new_with_label( "Cancel" ); // create button with text + 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 gtk_table_attach_defaults( GTK_TABLE( table ), button, 2, 3, 3, 4 ); // insert button into table } else { globalOutputStream() << "SunPlug: no worldspawn found!\n"; // output error to console - label = gtk_label_new( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label + label = ui::Label( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label 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 = gtk_button_new_with_label( "OK" ); // create a button with text + 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 gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box } diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index bb118664..9bfb46ec 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -59,10 +59,10 @@ UFOAIPluginDependencies( void ) : namespace UFOAI { -GtkWindow* g_mainwnd; + ui::Window g_mainwnd; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = GTK_WINDOW( pMainWidget ); + g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget )); return "Initializing GTKRadiant UFOAI plugin"; } const char* getName(){ @@ -78,8 +78,12 @@ const char* getCommandTitleList(){ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ char *message = NULL; if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), - "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About", + char const *version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ + "\nRadiant version: " RADIANT_VERSION + "\nPlugin version: " PLUGIN_VERSION + "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n"; + GlobalRadiant().m_pfnMessageBox( g_mainwnd, + version_string, "About", eMB_OK, eMB_ICONDEFAULT ); } else if ( string_equal( command, "Level 1" ) ) { @@ -129,7 +133,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush } if ( message != NULL ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), + GlobalRadiant().m_pfnMessageBox( g_mainwnd, message, "Note", eMB_OK, eMB_ICONDEFAULT ); } diff --git a/include/itoolbar.h b/include/itoolbar.h index 62d82b6e..7e5daad3 100644 --- a/include/itoolbar.h +++ b/include/itoolbar.h @@ -33,7 +33,6 @@ enum EType eSpace, eButton, eToggleButton, - eRadioButton, }; virtual const char* getImage() const = 0; diff --git a/include/qerplugin.h b/include/qerplugin.h index cb6c2ba5..e97c0107 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -26,6 +26,7 @@ #ifndef __QERPLUGIN_H__ #define __QERPLUGIN_H__ +#include "uilib/uilib.h" #include "generic/constant.h" @@ -35,7 +36,6 @@ // NOTE: parent can be 0 in all functions but it's best to set them // this API does not depend on gtk+ or glib -typedef struct _GtkWidget GtkWidget; enum EMessageBoxType { @@ -65,22 +65,22 @@ enum EMessageBoxReturn // simple Message Box, see above for the 'type' flags -typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( GtkWidget *parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); +typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); // file and directory selection functions return null if the user hits cancel // - 'title' is the dialog title (can be null) // - 'path' is used to set the initial directory (can be null) // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples -typedef const char* ( *PFN_QERAPP_FILEDIALOG )( GtkWidget *parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); +typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); // returns a gchar* string that must be g_free'd by the user -typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); +typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); // return true if the user closed the dialog with 'Ok' // 'color' is used to set the initial value and store the selected value template class BasicVector3; typedef BasicVector3 Vector3; -typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color, +typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color, const char* title /* = "Choose Color"*/ ); // load a .bmp file and create a GtkImage widget from it diff --git a/libs/container/array.h b/libs/container/array.h index c359df15..390282a7 100644 --- a/libs/container/array.h +++ b/libs/container/array.h @@ -166,5 +166,4 @@ inline void swap( Array& self, Array& ot self.swap( other ); } } - #endif diff --git a/libs/container/cache.h b/libs/container/cache.h index 880a7a7a..047e4ea8 100644 --- a/libs/container/cache.h +++ b/libs/container/cache.h @@ -95,83 +95,83 @@ pointer operator->() const { template, typename CreationPolicy = DefaultCreationPolicy > class HashedCache : public CreationPolicy { -typedef SharedValue Element; -typedef HashTable map_type; + typedef SharedValue Element; + typedef HashTable map_type; -map_type m_map; + map_type m_map; public: -explicit HashedCache( const CreationPolicy& creation = CreationPolicy() ) - : CreationPolicy( creation ), m_map( 256 ){ -} -~HashedCache(){ - ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" ); -} + explicit HashedCache( const CreationPolicy& creation = CreationPolicy() ) + : CreationPolicy( creation ), m_map( 256 ){ + } + ~HashedCache(){ + ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" ); + } -typedef typename map_type::iterator iterator; -typedef typename map_type::value_type value_type; + typedef typename map_type::iterator iterator; + typedef typename map_type::value_type value_type; -iterator begin(){ - return m_map.begin(); -} -iterator end(){ - return m_map.end(); -} + iterator begin(){ + return m_map.begin(); + } + iterator end(){ + return m_map.end(); + } -bool empty() const { - return m_map.empty(); -} + bool empty() const { + return m_map.empty(); + } -iterator find( const Key& key ){ - return m_map.find( key ); -} + iterator find( const Key& key ){ + return m_map.find( key ); + } -void capture( iterator i ){ + void capture( iterator i ){ ( *i ).value.increment(); -} -void release( iterator i ){ + } + void release( iterator i ){ if ( ( *i ).value.decrement() == 0 ) { CreationPolicy::destroy( ( *i ).value.get() ); - m_map.erase( i ); + m_map.erase( i ); + } } -} #if 1 -Element& capture( const Key& key ){ + Element& capture( const Key& key ){ #if 0 Element& elem = m_map[key]; - if ( elem.increment() == 1 ) { - elem.set( CreationPolicy::construct( key ) ); - } + if ( elem.increment() == 1 ) { + elem.set( CreationPolicy::construct( key ) ); + } return elem; #else iterator i = m_map.insert( key, Element() ); if ( ( *i ).value.increment() == 1 ) { ( *i ).value.set( CreationPolicy::construct( ( *i ).key ) ); - } + } return ( *i ).value; #endif -} + } #else value_type& capture( const Key& key ){ - iterator i = m_map.find( key ); - if ( i == m_map.end() ) { - i = m_map.insert( key, Element() ); + iterator i = m_map.find( key ); + if ( i == m_map.end() ) { + i = m_map.insert( key, Element() ); ( *i ).value.set( CreationPolicy::construct( ( *i ).key ) ); - } + } ( *i ).value.increment(); - return ( *i ); + return ( *i ); } #endif -void release( const Key& key ){ - iterator i = m_map.find( key ); - ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" ); - release( i ); -} + void release( const Key& key ){ + iterator i = m_map.find( key ); + ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" ); + release( i ); + } -void clear(){ - m_map.clear(); -} + void clear(){ + m_map.clear(); + } }; diff --git a/libs/container/hashtable.h b/libs/container/hashtable.h index 0f174d20..7fa7907e 100644 --- a/libs/container/hashtable.h +++ b/libs/container/hashtable.h @@ -28,7 +28,6 @@ #include #include "debugging/debugging.h" - namespace HashTableDetail { inline std::size_t next_power_of_two( std::size_t size ){ diff --git a/libs/debugging/debugging.h b/libs/debugging/debugging.h index c549a2f2..e05ff31b 100644 --- a/libs/debugging/debugging.h +++ b/libs/debugging/debugging.h @@ -117,6 +117,7 @@ inline DebugMessageHandler& globalDebugMessageHandler(){ if ( !globalDebugMessageHandler().handleMessage() ) { DEBUGGER_BREAKPOINT(); }} while ( 0 ) #define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" # ptr "\" is null" ) +#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" # flag "\" is false" ) #else diff --git a/libs/gtkutil/accelerator.cpp b/libs/gtkutil/accelerator.cpp index bba9ebe3..c00dcf60 100644 --- a/libs/gtkutil/accelerator.cpp +++ b/libs/gtkutil/accelerator.cpp @@ -25,8 +25,7 @@ #include #include -#include -#include +#include #include "generic/callback.h" #include "generic/bitfield.h" @@ -240,7 +239,7 @@ bool Buttons_press( ButtonMask& buttons, guint button, guint state ){ { GtkWindow* toplevel = *i; ASSERT_MESSAGE( window_has_accel( toplevel ), "ERROR" ); - ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "disabling accel for non-toplevel window" ); + ASSERT_MESSAGE( gtk_widget_is_toplevel( GTK_WIDGET(toplevel) ), "disabling accel for non-toplevel window" ); gtk_window_remove_accel_group( toplevel, global_accel ); #if 0 globalOutputStream() << reinterpret_cast( toplevel ) << ": disabled global accelerators\n"; @@ -266,7 +265,7 @@ bool Buttons_release( ButtonMask& buttons, guint button, guint state ){ { GtkWindow* toplevel = *i; ASSERT_MESSAGE( !window_has_accel( toplevel ), "ERROR" ); - ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "enabling accel for non-toplevel window" ); + ASSERT_MESSAGE( gtk_widget_is_toplevel( GTK_WIDGET(toplevel) ), "enabling accel for non-toplevel window" ); gtk_window_add_accel_group( toplevel, global_accel ); #if 0 globalOutputStream() << reinterpret_cast( toplevel ) << ": enabled global accelerators\n"; @@ -327,6 +326,7 @@ PressedButtons g_pressedButtons; #include +#include struct PressedKeys { @@ -484,7 +484,7 @@ void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerat GtkAccelGroup* global_accel = 0; void global_accel_init(){ - global_accel = gtk_accel_group_new(); + global_accel = ui::AccelGroup(); } void global_accel_destroy(){ diff --git a/libs/gtkutil/accelerator.h b/libs/gtkutil/accelerator.h index d1cd344e..a02572e7 100644 --- a/libs/gtkutil/accelerator.h +++ b/libs/gtkutil/accelerator.h @@ -22,9 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_ACCELERATOR_H ) #define INCLUDED_GTKUTIL_ACCELERATOR_H -#include -#include -#include +#include #include "generic/callback.h" diff --git a/libs/gtkutil/button.cpp b/libs/gtkutil/button.cpp index fc1e58d7..08744ff4 100644 --- a/libs/gtkutil/button.cpp +++ b/libs/gtkutil/button.cpp @@ -21,7 +21,7 @@ #include "button.h" -#include +#include #include "stream/textstream.h" #include "stream/stringstream.h" @@ -42,6 +42,14 @@ void button_connect_callback( GtkButton* button, const Callback& callback ){ #endif } +void button_connect_callback( GtkToolButton* button, const Callback& callback ){ +#if 1 + g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); +#else + g_signal_connect_closure( G_OBJECT( button ), "clicked", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), FALSE ); +#endif +} + guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){ #if 1 guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); @@ -52,6 +60,16 @@ guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& c return handler; } +guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callback& callback ){ +#if 1 + guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); +#else + guint handler = g_signal_connect_closure( G_OBJECT( button ), "toggled", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), TRUE ); +#endif + g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) ); + return handler; +} + void button_set_icon( GtkButton* button, const char* icon ){ GtkImage* image = new_local_image( icon ); gtk_widget_show( GTK_WIDGET( image ) ); @@ -70,10 +88,17 @@ void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean activ g_signal_handler_unblock( G_OBJECT( button ), handler_id ); } +void toggle_button_set_active_no_signal( GtkToggleToolButton* button, gboolean active ){ + guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) ); + g_signal_handler_block( G_OBJECT( button ), handler_id ); + gtk_toggle_tool_button_set_active( button, active ); + g_signal_handler_unblock( G_OBJECT( button ), handler_id ); +} + void radio_button_print_state( GtkRadioButton* button ){ globalOutputStream() << "toggle button: "; - for ( GSList* radio = gtk_radio_button_group( button ); radio != 0; radio = g_slist_next( radio ) ) + for ( GSList* radio = gtk_radio_button_get_group( button ); radio != 0; radio = g_slist_next( radio ) ) { globalOutputStream() << gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio->data ) ); } @@ -81,7 +106,7 @@ void radio_button_print_state( GtkRadioButton* button ){ } GtkToggleButton* radio_button_get_nth( GtkRadioButton* radio, int index ){ - GSList *group = gtk_radio_button_group( radio ); + GSList *group = gtk_radio_button_get_group( radio ); return GTK_TOGGLE_BUTTON( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) ); } @@ -109,7 +134,7 @@ void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){ int radio_button_get_active( GtkRadioButton* radio ){ //radio_button_print_state(radio); - GSList *group = gtk_radio_button_group( radio ); + GSList *group = gtk_radio_button_get_group( radio ); int index = g_slist_length( group ) - 1; for (; group != 0; group = g_slist_next( group ) ) { diff --git a/libs/gtkutil/button.h b/libs/gtkutil/button.h index 15a9f2e8..1ffb025c 100644 --- a/libs/gtkutil/button.h +++ b/libs/gtkutil/button.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_BUTTON_H ) #define INCLUDED_GTKUTIL_BUTTON_H +#include #include "generic/callbackfwd.h" typedef struct _GtkButton GtkButton; @@ -32,10 +33,13 @@ typedef gint gboolean; typedef unsigned int guint; void button_connect_callback( GtkButton* button, const Callback& callback ); +void button_connect_callback( GtkToolButton* button, const Callback& callback ); guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ); +guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callback& callback ); void button_set_icon( GtkButton* button, const char* icon ); void toggle_button_set_active_no_signal( GtkToggleButton* item, gboolean active ); +void toggle_button_set_active_no_signal( GtkToggleToolButton* item, gboolean active ); void radio_button_set_active( GtkRadioButton* radio, int index ); void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ); diff --git a/libs/gtkutil/clipboard.cpp b/libs/gtkutil/clipboard.cpp index c8073aba..29148753 100644 --- a/libs/gtkutil/clipboard.cpp +++ b/libs/gtkutil/clipboard.cpp @@ -83,7 +83,7 @@ void clipboard_paste( ClipboardPasteFunc paste ){ #else -#include +#include enum { @@ -111,11 +111,11 @@ static void clipboard_clear( GtkClipboard *clipboard, gpointer data ){ } static void clipboard_received( GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data ){ - if ( data->length < 0 ) { + if ( gtk_selection_data_get_length(data) < 0 ) { globalErrorStream() << "Error retrieving selection\n"; } - else if ( strcmp( gdk_atom_name( data->type ), clipboard_targets[0].target ) == 0 ) { - BufferInputStream istream( reinterpret_cast( data->data ), data->length ); + else if ( strcmp( gdk_atom_name( gtk_selection_data_get_data_type(data) ), clipboard_targets[0].target ) == 0 ) { + BufferInputStream istream( reinterpret_cast( gtk_selection_data_get_data(data) ), gtk_selection_data_get_length(data) ); ( *reinterpret_cast( user_data ) )( istream ); } } diff --git a/libs/gtkutil/container.h b/libs/gtkutil/container.h index b6b6afa4..e633d81c 100644 --- a/libs/gtkutil/container.h +++ b/libs/gtkutil/container.h @@ -22,7 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_CONTAINER_H ) #define INCLUDED_GTKUTIL_CONTAINER_H -#include +#include inline GtkWidget* container_add_widget( GtkContainer* container, GtkWidget* widget ){ gtk_container_add( container, widget ); diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index f0538a50..431f60fe 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -24,34 +24,21 @@ #include "stream/textstream.h" #include -#include -#include +#include GdkCursor* create_blank_cursor(){ - GdkPixmap *pixmap; - GdkBitmap *mask; - char buffer [( 32 * 32 ) / 8]; - memset( buffer, 0, ( 32 * 32 ) / 8 ); - GdkColor white = {0, 0xffff, 0xffff, 0xffff}; - GdkColor black = {0, 0x0000, 0x0000, 0x0000}; - pixmap = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - mask = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - GdkCursor *cursor = gdk_cursor_new_from_pixmap( pixmap, mask, &white, &black, 1, 1 ); - gdk_drawable_unref( pixmap ); - gdk_drawable_unref( mask ); - - return cursor; + return gdk_cursor_new(GDK_BLANK_CURSOR); } void blank_cursor( GtkWidget* widget ){ GdkCursor* cursor = create_blank_cursor(); - gdk_window_set_cursor( widget->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(widget), cursor ); gdk_cursor_unref( cursor ); } void default_cursor( GtkWidget* widget ){ - gdk_window_set_cursor( widget->window, 0 ); + gdk_window_set_cursor( gtk_widget_get_window(widget), 0 ); } diff --git a/libs/gtkutil/cursor.h b/libs/gtkutil/cursor.h index dfcc962c..bf4f6ee8 100644 --- a/libs/gtkutil/cursor.h +++ b/libs/gtkutil/cursor.h @@ -23,9 +23,7 @@ #define INCLUDED_GTKUTIL_CURSOR_H #include -#include -#include -#include +#include #include "debugging/debugging.h" @@ -157,7 +155,7 @@ void freeze_pointer( GtkWindow* window, MotionDeltaFunction function, void* data GdkCursor* cursor = create_blank_cursor(); //GdkGrabStatus status = - gdk_pointer_grab( GTK_WIDGET( window )->window, TRUE, mask, 0, cursor, GDK_CURRENT_TIME ); + gdk_pointer_grab( gtk_widget_get_window(GTK_WIDGET(window)), TRUE, mask, 0, cursor, GDK_CURRENT_TIME ); gdk_cursor_unref( cursor ); Sys_GetCursorPos( window, &recorded_x, &recorded_y ); diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 59f5c5d9..fce53163 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -21,43 +21,34 @@ #include "dialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "button.h" #include "window.h" GtkVBox* create_dialog_vbox( int spacing, int border ){ - GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, spacing ) ); + GtkVBox* vbox = ui::VBox( FALSE, spacing ); gtk_widget_show( GTK_WIDGET( vbox ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), border ); return vbox; } GtkHBox* create_dialog_hbox( int spacing, int border ){ - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, spacing ) ); + GtkHBox* hbox = ui::HBox( FALSE, spacing ); gtk_widget_show( GTK_WIDGET( hbox ) ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), border ); return hbox; } GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow ){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( label ) ); + GtkFrame* frame = ui::Frame( label ); gtk_widget_show( GTK_WIDGET( frame ) ); 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 = GTK_TABLE( gtk_table_new( rows, columns, FALSE ) ); + GtkTable* table = ui::Table( rows, columns, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_table_set_row_spacings( table, row_spacing ); gtk_table_set_col_spacings( table, col_spacing ); @@ -66,7 +57,7 @@ GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned } GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ){ - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( label ) ); + GtkButton* button = ui::Button( label ); gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 ); gtk_widget_show( GTK_WIDGET( button ) ); g_signal_connect( G_OBJECT( button ), "clicked", func, data ); @@ -174,7 +165,7 @@ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& di gtk_container_add( GTK_CONTAINER( vbox1 ), contents ); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + ui::Alignment alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vbox1 ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); @@ -185,7 +176,7 @@ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& di } RadioHBox RadioHBox_new( StringArrayRange names ){ - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( TRUE, 4 ) ); + GtkHBox* hbox = ui::HBox( TRUE, 4 ); gtk_widget_show( GTK_WIDGET( hbox ) ); GSList* group = 0; @@ -204,21 +195,21 @@ RadioHBox RadioHBox_new( StringArrayRange names ){ PathEntry PathEntry_new(){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( NULL ) ); + GtkFrame* frame = ui::Frame(); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); // path entry - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 0 ) ); + GtkHBox* hbox = ui::HBox( FALSE, 0 ); gtk_widget_show( GTK_WIDGET( hbox ) ); - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_entry_set_has_frame( entry, FALSE ); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); // browse button - GtkButton* button = GTK_BUTTON( gtk_button_new() ); + GtkButton* button = ui::Button(); button_set_icon( button, "ellipsis.bmp" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); @@ -245,8 +236,8 @@ BrowsedPathEntry::BrowsedPathEntry( const BrowseCallback& browse ) : GtkLabel* DialogLabel_new( const char* name ){ - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + ui::Label 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 ); @@ -254,7 +245,7 @@ GtkLabel* DialogLabel_new( const char* name ){ } GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){ - GtkTable* table = GTK_TABLE( gtk_table_new( 1, 3, TRUE ) ); + GtkTable* table = ui::Table( 1, 3, TRUE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_table_set_col_spacings( table, 4 ); diff --git a/libs/gtkutil/dialog.h b/libs/gtkutil/dialog.h index 5a87731e..b3e5017c 100644 --- a/libs/gtkutil/dialog.h +++ b/libs/gtkutil/dialog.h @@ -25,7 +25,7 @@ #include "generic/callback.h" #include "generic/arrayrange.h" #include "qerplugin.h" -#include +#include typedef int gint; typedef gint gboolean; diff --git a/libs/gtkutil/entry.h b/libs/gtkutil/entry.h index 814be152..66beace1 100644 --- a/libs/gtkutil/entry.h +++ b/libs/gtkutil/entry.h @@ -24,7 +24,7 @@ #include #include -#include +#include inline void entry_set_string( GtkEntry* entry, const char* string ){ gtk_entry_set_text( entry, string ); diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index d65d310c..a06c4c93 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -25,11 +25,8 @@ #include #include -#include -#include -#include -#include -#include +#include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -243,7 +240,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c return g_file_dialog_file; } -char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ +char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ GtkWidget* dialog = gtk_file_chooser_dialog_new( title, GTK_WINDOW( parent ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, @@ -268,7 +265,7 @@ char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ return filename; } -const char* file_dialog( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ for (;; ) { const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save ); @@ -276,7 +273,7 @@ const char* file_dialog( GtkWidget* parent, bool open, const char* title, const if ( open || file == 0 || !file_exists( file ) - || gtk_MessageBox( parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION ) == eIDYES ) { + || parent.alert("The file specified already exists.\nDo you want to replace it?", title, ui::alert_type::NOYES, ui::alert_icon::Question ) == ui::alert_response::YES ) { return file; } } diff --git a/libs/gtkutil/filechooser.h b/libs/gtkutil/filechooser.h index f4610bea..ae7c0b34 100644 --- a/libs/gtkutil/filechooser.h +++ b/libs/gtkutil/filechooser.h @@ -19,20 +19,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_FILECHOOSER_H ) #define INCLUDED_GTKUTIL_FILECHOOSER_H /// \file /// GTK+ file-chooser dialogs. -typedef struct _GtkWidget GtkWidget; -const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); /// \brief Prompts the user to browse for a directory. /// The prompt window will be transient to \p parent. /// The directory will initially default to \p path, which must be an absolute path. /// The returned string is allocated with \c g_malloc and must be freed with \c g_free. -char* dir_dialog( GtkWidget *parent, const char* title = "Choose Directory", const char* path = "" ); +char* dir_dialog( ui::Widget parent, const char* title = "Choose Directory", const char* path = "" ); #endif diff --git a/libs/gtkutil/frame.cpp b/libs/gtkutil/frame.cpp index 8914fb70..87f75f36 100644 --- a/libs/gtkutil/frame.cpp +++ b/libs/gtkutil/frame.cpp @@ -21,10 +21,11 @@ #include "frame.h" -#include +#include +#include GtkFrame* create_framed_widget( GtkWidget* widget ){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) ); + GtkFrame* frame = ui::Frame(); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); gtk_container_add( GTK_CONTAINER( frame ), widget ); diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 746b8f0f..3f9b9a00 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -27,7 +27,7 @@ #include "igl.h" -#include +#include #include #include "pointer.h" @@ -187,7 +187,7 @@ GtkWidget* g_shared = 0; gint glwidget_context_created( GtkWidget* widget, gpointer data ){ if ( ++g_context_count == 1 ) { g_shared = widget; - gtk_widget_ref( g_shared ); + g_object_ref( g_shared ); glwidget_make_current( g_shared ); GlobalOpenGL().contextValid = true; @@ -203,7 +203,7 @@ gint glwidget_context_destroyed( GtkWidget* widget, gpointer data ){ GLWidget_sharedContextDestroyed(); - gtk_widget_unref( g_shared ); + g_object_unref( g_shared ); g_shared = 0; } return FALSE; diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index b8cd7bef..961d2e73 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -21,8 +21,7 @@ #include "image.h" -#include -#include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -46,7 +45,7 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ else { GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); - gdk_pixbuf_unref( rgb ); + g_object_unref( rgb ); return rgba; } } @@ -59,7 +58,7 @@ GtkImage* image_new_from_file_with_mask( const char* filename ){ else { GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ); - gdk_pixbuf_unref( rgba ); + g_object_unref( rgba ); return image; } } diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index cbb07df8..7ef18911 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -22,11 +22,9 @@ #include "menu.h" #include -#include -#include -#include -#include -#include +#include +#include +#include #include "generic/callback.h" @@ -56,10 +54,10 @@ GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ){ } GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); + GtkMenuItem* item = ui::MenuItem( mnemonic, true ); gtk_widget_show( GTK_WIDGET( item ) ); - GtkWidget* sub_menu = gtk_menu_new(); + GtkWidget* sub_menu = ui::Menu(); gtk_menu_item_set_submenu( item, sub_menu ); return item; @@ -102,7 +100,7 @@ guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& } GtkMenuItem* new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); + GtkMenuItem* item = ui::MenuItem( mnemonic, true ); gtk_widget_show( GTK_WIDGET( item ) ); menu_item_connect_callback( item, callback ); return item; @@ -130,9 +128,9 @@ GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const cha GtkRadioMenuItem* new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){ GtkRadioMenuItem* item = GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) ); if ( *group == 0 ) { - gtk_check_menu_item_set_state( GTK_CHECK_MENU_ITEM( item ), TRUE ); + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE ); } - *group = gtk_radio_menu_item_group( item ); + *group = gtk_radio_menu_item_get_group( item ); gtk_widget_show( GTK_WIDGET( item ) ); check_menu_item_connect_callback( GTK_CHECK_MENU_ITEM( item ), callback ); return item; @@ -226,38 +224,11 @@ void accelerator_name( const Accelerator& accelerator, GString* gstring ){ } } -void menu_item_set_accelerator( GtkMenuItem* item, Accelerator accelerator ){ - GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) ); - - g_free( accel_label->accel_string ); - accel_label->accel_string = 0; - - GString* gstring = g_string_new( accel_label->accel_string ); - g_string_append( gstring, " " ); - - accelerator_name( accelerator, gstring ); - - g_free( accel_label->accel_string ); - accel_label->accel_string = gstring->str; - g_string_free( gstring, FALSE ); - - if ( !accel_label->accel_string ) { - accel_label->accel_string = g_strdup( "" ); - } - - gtk_widget_queue_resize( GTK_WIDGET( accel_label ) ); -} - void menu_item_add_accelerator( GtkMenuItem* item, Accelerator accelerator ){ if ( accelerator.key != 0 ) { GClosure* closure = global_accel_group_find( accelerator ); - if ( closure != 0 ) { - menu_item_set_accelerator( item, closure ); - } - else - { - menu_item_set_accelerator( item, accelerator ); - } + ASSERT_NOTNULL(closure); + menu_item_set_accelerator( item, closure ); } } diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 8f9fb7fa..2ae955c7 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -22,21 +22,13 @@ #include "messagebox.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "dialog.h" #include "widget.h" GtkWidget* create_padding( int width, int height ){ - GtkWidget* widget = gtk_alignment_new( 0.0, 0.0, 0.0, 0.0 ); + ui::Alignment widget = ui::Alignment( 0.0, 0.0, 0.0, 0.0 ); gtk_widget_show( widget ); gtk_widget_set_size_request( widget, width, height ); return widget; @@ -59,14 +51,14 @@ const char* messagebox_stock_icon( EMessageBoxIcon type ){ } } -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); ModalDialogButton yes_button( dialog, eIDYES ); ModalDialogButton no_button( dialog, eIDNO ); - GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW( parent ) : 0; + GtkWindow* parentWindow = parent ? GTK_WINDOW( parent ) : 0; GtkWindow* window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 ); @@ -75,7 +67,7 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha gtk_window_deiconify( parentWindow ); } - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); GtkVBox* vbox = create_dialog_vbox( 8, 8 ); @@ -94,7 +86,7 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha gtk_widget_show( GTK_WIDGET( image ) ); gtk_box_pack_start( GTK_BOX( iconBox ), GTK_WIDGET( image ), FALSE, FALSE, 0 ); - GtkLabel* label = GTK_LABEL( gtk_label_new( text ) ); + GtkLabel* label = GTK_LABEL( ui::Label( text ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); @@ -105,7 +97,7 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha GtkVBox* vboxDummy = create_dialog_vbox( 0, 0 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( vboxDummy ), FALSE, FALSE, 0 ); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + GtkAlignment* alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vboxDummy ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); diff --git a/libs/gtkutil/messagebox.h b/libs/gtkutil/messagebox.h index 8bdc0ba2..69939939 100644 --- a/libs/gtkutil/messagebox.h +++ b/libs/gtkutil/messagebox.h @@ -24,8 +24,7 @@ #include "qerplugin.h" -typedef struct _GtkWidget GtkWidget; /// \brief Shows a modal message-box. -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); #endif diff --git a/libs/gtkutil/nonmodal.h b/libs/gtkutil/nonmodal.h index 864779bd..4baf54b5 100644 --- a/libs/gtkutil/nonmodal.h +++ b/libs/gtkutil/nonmodal.h @@ -22,9 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_NONMODAL_H ) #define INCLUDED_GTKUTIL_NONMODAL_H -#include -#include -#include +#include #include #include "generic/callback.h" @@ -36,7 +34,7 @@ typedef struct _GtkEntry GtkEntry; inline gboolean escape_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){ - 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; } @@ -60,7 +58,7 @@ static gboolean focus_in( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* } static gboolean focus_out( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){ - if ( self->m_editing && GTK_WIDGET_VISIBLE( entry ) ) { + if ( self->m_editing && gtk_widget_get_visible( GTK_WIDGET(entry) ) ) { self->m_apply(); } self->m_editing = false; @@ -152,7 +150,7 @@ public: NonModalRadio( const Callback& changed ) : m_changed( changed ){ } void connect( GtkRadioButton* radio ){ - GSList* group = gtk_radio_button_group( radio ); + GSList* group = gtk_radio_button_get_group( radio ); for (; group != 0; group = g_slist_next( group ) ) { toggle_button_connect_callback( GTK_TOGGLE_BUTTON( group->data ), m_changed ); diff --git a/libs/gtkutil/paned.cpp b/libs/gtkutil/paned.cpp index c5adc09c..446a8bb4 100644 --- a/libs/gtkutil/paned.cpp +++ b/libs/gtkutil/paned.cpp @@ -21,8 +21,8 @@ #include "paned.h" -#include -#include +#include +#include #include "frame.h" @@ -62,14 +62,14 @@ PanedState g_vpaned1 = { 0.5f, -1, }; PanedState g_vpaned2 = { 0.5f, -1, }; GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright ){ - GtkHPaned* hsplit = GTK_HPANED( gtk_hpaned_new() ); + GtkHPaned* hsplit = ui::HPaned(); gtk_widget_show( GTK_WIDGET( hsplit ) ); g_signal_connect( G_OBJECT( hsplit ), "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned ); g_signal_connect( G_OBJECT( hsplit ), "notify::position", G_CALLBACK( paned_position ), &g_hpaned ); { - GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() ); + GtkVPaned* vsplit = ui::VPaned(); gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) ); gtk_widget_show( GTK_WIDGET( vsplit ) ); @@ -80,7 +80,7 @@ GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidge gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) ); } { - GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() ); + GtkVPaned* vsplit = ui::VPaned(); gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) ); gtk_widget_show( GTK_WIDGET( vsplit ) ); diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 3ac74f61..c0659401 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -21,52 +21,48 @@ #include "toolbar.h" -#include -#include +#include #include "generic/callback.h" #include "accelerator.h" #include "button.h" -#include "closure.h" -#include "pointer.h" +#include "image.h" -void toolbar_append( GtkToolbar* toolbar, GtkButton* button, const char* description ){ - gtk_widget_show( GTK_WIDGET( button ) ); - gtk_button_set_relief( button, GTK_RELIEF_NONE ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT ); - gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", description, "", 0, 0, 0 ); +void toolbar_append( GtkToolbar* toolbar, GtkToolItem* button, const char* description ){ + gtk_widget_show_all(GTK_WIDGET(button)); + gtk_widget_set_tooltip_text(GTK_WIDGET(button), description); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkButton* button = GTK_BUTTON( gtk_button_new() ); - button_set_icon( button, icon ); - button_connect_callback( button, callback ); - toolbar_append( toolbar, button, description ); +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ + auto button = GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr)); + button_connect_callback(button, callback); + toolbar_append(toolbar, GTK_TOOL_ITEM(button), description); return button; } -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkToggleButton* button = GTK_TOGGLE_BUTTON( gtk_toggle_button_new() ); - button_set_icon( GTK_BUTTON( button ), icon ); - toggle_button_connect_callback( button, callback ); - toolbar_append( toolbar, GTK_BUTTON( button ), description ); +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ + auto button = GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new()); + toggle_button_connect_callback(button, callback); + gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_local_image(icon))); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description); + toolbar_append(toolbar, GTK_TOOL_ITEM(button), description); return button; } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){ +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){ return toolbar_append_button( toolbar, description, icon, command.m_callback ); } -void toggle_button_set_active_callback( GtkToggleButton& button, bool active ){ +void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){ toggle_button_set_active_no_signal( &button, active ); } -typedef ReferenceCaller1 ToggleButtonSetActiveCaller; +using ToggleButtonSetActiveCaller = ReferenceCaller1; -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){ - GtkToggleButton* button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback ); +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){ + auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback ); toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button ) ); return button; } diff --git a/libs/gtkutil/toolbar.h b/libs/gtkutil/toolbar.h index 6b9e32fb..687fa0a3 100644 --- a/libs/gtkutil/toolbar.h +++ b/libs/gtkutil/toolbar.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_TOOLBAR_H ) #define INCLUDED_GTKUTIL_TOOLBAR_H +#include #include "generic/callbackfwd.h" typedef struct _GtkButton GtkButton; @@ -30,9 +31,9 @@ typedef struct _GtkToolbar GtkToolbar; class Command; class Toggle; -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ); +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ); +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ); #endif diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index ceb92409..bf84eef0 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -23,7 +23,7 @@ #define INCLUDED_GTKUTIL_WIDGET_H #include -#include +#include #include "generic/callback.h" #include "warnings.h" #include "debugging/debugging.h" @@ -39,7 +39,7 @@ inline void widget_set_visible( GtkWidget* widget, bool shown ){ } inline bool widget_is_visible( GtkWidget* widget ){ - return GTK_WIDGET_VISIBLE( widget ) != FALSE; + return gtk_widget_get_visible( widget ) != FALSE; } inline void widget_toggle_visible( GtkWidget* widget ){ @@ -81,7 +81,7 @@ static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* return FALSE; } static gboolean destroy( GtkWidget* widget, ToggleShown* self ){ - self->m_shownDeferred = GTK_WIDGET_VISIBLE( self->m_widget ) != FALSE; + self->m_shownDeferred = gtk_widget_get_visible( self->m_widget ) != FALSE; self->m_widget = 0; return FALSE; } @@ -101,7 +101,7 @@ bool active() const { } else { - return GTK_WIDGET_VISIBLE( m_widget ) != FALSE; + return gtk_widget_get_visible( m_widget ) != FALSE; } } void exportActive( const BoolImportCallback& importCallback ){ @@ -138,7 +138,7 @@ typedef ReferenceCaller WidgetQueueDrawCaller; inline void widget_make_default( GtkWidget* widget ){ - GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( widget, true ); gtk_widget_grab_default( widget ); } diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index 48b174b3..07e04e56 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -21,7 +21,8 @@ #include "window.h" -#include +#include +#include #include "pointer.h" #include "accelerator.h" @@ -33,7 +34,7 @@ inline void CHECK_RESTORE( GtkWidget* w ){ } inline void CHECK_MINIMIZE( GtkWidget* w ){ - g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( GTK_WIDGET_VISIBLE( w ) ) ); + g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( gtk_widget_get_visible( w ) ) ); gtk_widget_hide( w ); } @@ -82,7 +83,7 @@ guint connect_floating_window_destroy_present( GtkWindow* floating, GtkWindow* m } GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); + GtkWindow* window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( window, title ); if ( parent != 0 ) { @@ -100,7 +101,7 @@ void destroy_floating_window( GtkWindow* window ){ } gint window_realize_remove_sysmenu( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) ); + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) ); return FALSE; } @@ -127,7 +128,7 @@ GtkWindow* create_persistent_floating_window( const char* title, GtkWindow* main } gint window_realize_remove_minmax( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); return FALSE; } @@ -137,7 +138,7 @@ void window_remove_minmax( GtkWindow* window ){ GtkScrolledWindow* create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border ){ - GtkScrolledWindow* scr = GTK_SCROLLED_WINDOW( gtk_scrolled_window_new( 0, 0 ) ); + GtkScrolledWindow* scr = ui::ScrolledWindow(); gtk_widget_show( GTK_WIDGET( scr ) ); gtk_scrolled_window_set_policy( scr, hscrollbar_policy, vscrollbar_policy ); gtk_scrolled_window_set_shadow_type( scr, GTK_SHADOW_IN ); diff --git a/libs/gtkutil/window.h b/libs/gtkutil/window.h index 1a7161e6..96b9be00 100644 --- a/libs/gtkutil/window.h +++ b/libs/gtkutil/window.h @@ -22,7 +22,7 @@ #if !defined( INCLUDED_GTKUTIL_WINDOW_H ) #define INCLUDED_GTKUTIL_WINDOW_H -#include +#include #include "debugging/debugging.h" #include "generic/callback.h" diff --git a/libs/gtkutil/xorrectangle.h b/libs/gtkutil/xorrectangle.h index 6c4d64fc..6c6abdf5 100644 --- a/libs/gtkutil/xorrectangle.h +++ b/libs/gtkutil/xorrectangle.h @@ -22,7 +22,8 @@ #if !defined ( INCLUDED_XORRECTANGLE_H ) #define INCLUDED_XORRECTANGLE_H -#include +#include +#include #include "math/vector.h" class rectangle_t @@ -64,23 +65,14 @@ class XORRectangle rectangle_t m_rectangle; GtkWidget* m_widget; -GdkGC* m_gc; +cairo_t *cr; bool initialised() const { - return m_gc != 0; + return cr != nullptr; } void lazy_init(){ if ( !initialised() ) { - m_gc = gdk_gc_new( m_widget->window ); - - GdkColor color = { 0, 0xffff, 0xffff, 0xffff, }; - GdkColormap* colormap = gdk_window_get_colormap( m_widget->window ); - gdk_colormap_alloc_color( colormap, &color, FALSE, TRUE ); - gdk_gc_copy( m_gc, m_widget->style->white_gc ); - gdk_gc_set_foreground( m_gc, &color ); - gdk_gc_set_background( m_gc, &color ); - - gdk_gc_set_function( m_gc, GDK_INVERT ); + cr = gdk_cairo_create(gtk_widget_get_window(m_widget)); } } void draw() const { @@ -88,19 +80,24 @@ void draw() const { const int y = float_to_integer( m_rectangle.y ); const int w = float_to_integer( m_rectangle.w ); const int h = float_to_integer( m_rectangle.h ); - gdk_draw_rectangle( m_widget->window, m_gc, FALSE, x, -( h ) - ( y - m_widget->allocation.height ), w, h ); + GtkAllocation allocation; + gtk_widget_get_allocation(m_widget, &allocation); + cairo_rectangle(cr, x, -(h) - (y - allocation.height), w, h); + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_stroke(cr); } public: -XORRectangle( GtkWidget* widget ) : m_widget( widget ), m_gc( 0 ){ +XORRectangle( ui::Widget widget ) : m_widget( widget ), cr( 0 ) { } ~XORRectangle(){ if ( initialised() ) { - gdk_gc_unref( m_gc ); + cairo_destroy(cr); } } void set( rectangle_t rectangle ){ - if ( GTK_WIDGET_REALIZED( m_widget ) ) { + if ( gtk_widget_get_realized( m_widget ) ) { lazy_init(); draw(); m_rectangle = rectangle; diff --git a/libs/modulesystem/moduleregistry.h b/libs/modulesystem/moduleregistry.h index abea5a05..7cd84f97 100644 --- a/libs/modulesystem/moduleregistry.h +++ b/libs/modulesystem/moduleregistry.h @@ -28,23 +28,23 @@ class ModuleRegisterable { public: -virtual void selfRegister() = 0; + virtual void selfRegister() = 0; }; class ModuleRegistryList { -typedef std::list RegisterableModules; -RegisterableModules m_modules; + typedef std::list RegisterableModules; + RegisterableModules m_modules; public: -void addModule( ModuleRegisterable& module ){ - m_modules.push_back( &module ); -} -void registerModules() const { - for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) - { - ( *i )->selfRegister(); + void addModule( ModuleRegisterable& module ){ + m_modules.push_back( &module ); + } + void registerModules() const { + for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + { + ( *i )->selfRegister(); + } } -} }; typedef SmartStatic StaticModuleRegistryList; @@ -53,9 +53,9 @@ typedef SmartStatic StaticModuleRegistryList; class StaticRegisterModule : public StaticModuleRegistryList { public: -StaticRegisterModule( ModuleRegisterable& module ){ - StaticModuleRegistryList::instance().addModule( module ); -} + StaticRegisterModule( ModuleRegisterable& module ){ + StaticModuleRegistryList::instance().addModule( module ); + } }; diff --git a/libs/modulesystem/singletonmodule.h b/libs/modulesystem/singletonmodule.h index 6dd9c52a..8dcd88de 100644 --- a/libs/modulesystem/singletonmodule.h +++ b/libs/modulesystem/singletonmodule.h @@ -88,7 +88,7 @@ explicit SingletonModule( const APIConstructor& constructor ) void selfRegister(){ globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this ); -} + } Dependencies& getDependencies(){ return *m_dependencies; diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index e69de29b..eb49165a 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -0,0 +1,205 @@ +#include "uilib.h" + +#include + +#include + +#include "gtkutil/dialog.h" +#include "gtkutil/filechooser.h" +#include "gtkutil/messagebox.h" +#include "gtkutil/window.h" + +namespace ui { + + void init(int argc, char *argv[]) + { + gtk_disable_setlocale(); + gtk_init(&argc, &argv); + } + + void main() + { + gtk_main(); + } + + Widget root; + + alert_response Widget::alert(std::string text, std::string title, alert_type type, alert_icon icon) + { + auto ret = gtk_MessageBox(*this, text.c_str(), + title.c_str(), + type == alert_type::OK ? eMB_OK : + type == alert_type::OKCANCEL ? eMB_OKCANCEL : + type == alert_type::YESNO ? eMB_YESNO : + type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL : + type == alert_type::NOYES ? eMB_NOYES : + eMB_OK, + icon == alert_icon::Default ? eMB_ICONDEFAULT : + icon == alert_icon::Error ? eMB_ICONERROR : + icon == alert_icon::Warning ? eMB_ICONWARNING : + icon == alert_icon::Question ? eMB_ICONQUESTION : + icon == alert_icon::Asterisk ? eMB_ICONASTERISK : + eMB_ICONDEFAULT + ); + return + ret == eIDOK ? alert_response::OK : + ret == eIDCANCEL ? alert_response::CANCEL : + ret == eIDYES ? alert_response::YES : + ret == eIDNO ? alert_response::NO : + alert_response::OK; + } + + const char *Widget::file_dialog(bool open, const char *title, const char *path, + const char *pattern, bool want_load, bool want_import, + bool want_save) + { + return ::file_dialog(*this, open, title, path, pattern, want_load, want_import, want_save); + } + + Window::Window(window_type type) + : Window(GTK_WINDOW(gtk_window_new( + type == window_type::TOP ? GTK_WINDOW_TOPLEVEL : + type == window_type::POPUP ? GTK_WINDOW_POPUP : + GTK_WINDOW_TOPLEVEL))) + { }; + + Window Window::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h) + { + return Window(::create_dialog_window(*this, title, func, data, default_w, default_h)); + } + + Window Window::create_modal_dialog_window(const char *title, ui_modal &dialog, int default_w, int default_h) + { + return Window(::create_modal_dialog_window(*this, title, dialog, default_w, default_h)); + } + + Window Window::create_floating_window(const char *title) + { + return Window(::create_floating_window(title, *this)); + } + + std::uint64_t Window::on_key_press(bool (*f)(Widget widget, ui_evkey *event, void *extra), void *extra) + { + using f_t = decltype(f); + struct user_data { + f_t f; + void *extra; + } *pass = new user_data{f, extra}; + auto dtor = [](user_data *data, GClosure *) { + delete data; + }; + auto func = [](ui_widget *widget, GdkEventKey *event, user_data *args) -> bool { + return args->f(Widget(widget), event, args->extra); + }; + auto clos = g_cclosure_new(G_CALLBACK(+func), pass, reinterpret_cast(+dtor)); + return g_signal_connect_closure(G_OBJECT(*this), "key-press-event", clos, false); + } + + AccelGroup::AccelGroup() : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new())) + { } + + Adjustment::Adjustment(double value, + double lower, double upper, + double step_increment, double page_increment, + double page_size) + : Adjustment( + GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size))) + { } + + Alignment::Alignment(float xalign, float yalign, float xscale, float yscale) + : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale))) + { } + + Button::Button() : Button(GTK_BUTTON(gtk_button_new())) + { } + + Button::Button(const char *label) : Button(GTK_BUTTON(gtk_button_new_with_label(label))) + { } + + CellRendererText::CellRendererText() : CellRendererText(GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new())) + { } + + ComboBoxText::ComboBoxText() : ComboBoxText(GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new())) + { } + + CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label))) + { } + + Entry::Entry() : Entry(GTK_ENTRY(gtk_entry_new())) + { } + + Entry::Entry(std::size_t max_length) : Entry() + { + gtk_entry_set_max_length(*this, static_cast(max_length)); + } + + Frame::Frame(const char *label) : Frame(GTK_FRAME(gtk_frame_new(label))) + { } + + HBox::HBox(bool homogenous, int spacing) : HBox(GTK_HBOX(gtk_hbox_new(homogenous, spacing))) + { } + + HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment))) + { } + + HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step))) + { } + + Image::Image() : Image(GTK_IMAGE(gtk_image_new())) + { } + + Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label))) + { } + + Menu::Menu() : Menu(GTK_MENU(gtk_menu_new())) + { } + + MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem( + GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label))) + { } + + HPaned::HPaned() : HPaned(GTK_HPANED(gtk_hpaned_new())) + { } + + VPaned::VPaned() : VPaned(GTK_VPANED(gtk_vpaned_new())) + { } + + ScrolledWindow::ScrolledWindow() : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr))) + { } + + SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton( + GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits))) + { } + + Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table( + GTK_TABLE(gtk_table_new(rows, columns, homogenous))) + { } + + TextView::TextView() : TextView(GTK_TEXT_VIEW(gtk_text_view_new())) + { } + + TreePath::TreePath() : TreePath(gtk_tree_path_new()) + { } + + TreePath::TreePath(const char *path) : TreePath(gtk_tree_path_new_from_string(path)) + { } + + TreeView::TreeView() : TreeView(GTK_TREE_VIEW(gtk_tree_view_new())) + { } + + TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model))) + { } + + TreeViewColumn::TreeViewColumn(const char *title, CellRenderer renderer, + std::initializer_list attributes) + : TreeViewColumn(gtk_tree_view_column_new_with_attributes(title, renderer, nullptr)) + { + for (auto &it : attributes) { + gtk_tree_view_column_add_attribute(*this, renderer, it.attribute, it.column); + } + }; + + VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing))) + { } + +} diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h new file mode 100644 index 00000000..562d0b08 --- /dev/null +++ b/libs/uilib/uilib.h @@ -0,0 +1,281 @@ +#ifndef INCLUDED_UILIB_H +#define INCLUDED_UILIB_H + +#include + +using ui_accelgroup = struct _GtkAccelGroup; +using ui_adjustment = struct _GtkAdjustment; +using ui_alignment = struct _GtkAlignment; +using ui_box = struct _GtkBox; +using ui_button = struct _GtkButton; +using ui_checkbutton = struct _GtkCheckButton; +using ui_combobox = struct _GtkComboBox; +using ui_comboboxtext = struct _GtkComboBoxText; +using ui_cellrenderer = struct _GtkCellRenderer; +using ui_cellrenderertext = struct _GtkCellRendererText; +using ui_entry = struct _GtkEntry; +using ui_evkey = struct _GdkEventKey; +using ui_frame = struct _GtkFrame; +using ui_hbox = struct _GtkHBox; +using ui_hscale = struct _GtkHScale; +using ui_hpaned = struct _GtkHPaned; +using ui_image = struct _GtkImage; +using ui_label = struct _GtkLabel; +using ui_menu = struct _GtkMenu; +using ui_menuitem = struct _GtkMenuItem; +using ui_modal = struct ModalDialog; +using ui_object = struct _GtkObject; +using ui_paned = struct _GtkPaned; +using ui_scrolledwindow = struct _GtkScrolledWindow; +using ui_spinbutton = struct _GtkSpinButton; +using ui_table = struct _GtkTable; +using ui_textview = struct _GtkTextView; +using ui_treemodel = struct _GtkTreeModel; +using ui_treepath = struct _GtkTreePath; +using ui_treeview = struct _GtkTreeView; +using ui_treeviewcolumn = struct _GtkTreeViewColumn; +using ui_typeinst = struct _GTypeInstance; +using ui_vbox = struct _GtkVBox; +using ui_vpaned = struct _GtkVPaned; +using ui_widget = struct _GtkWidget; +using ui_window = struct _GtkWindow; + +namespace ui { + + void init(int argc, char *argv[]); + + void main(); + + enum class alert_type { + OK, + OKCANCEL, + YESNO, + YESNOCANCEL, + NOYES, + }; + + enum class alert_icon { + Default, + Error, + Warning, + Question, + Asterisk, + }; + + enum class alert_response { + OK, + CANCEL, + YES, + NO, + }; + + enum class window_type { + TOP, + POPUP + }; + + template + struct Convertible; + + template + struct Convertible { + operator T *() const + { return reinterpret_cast(static_cast(this)->_handle); } + }; + + template + struct Convertible { + explicit operator T *() const + { return reinterpret_cast(static_cast(this)->_handle); } + }; + + class Object : public Convertible { + public: + using native = ui_object; + void *_handle; + + Object(void *h) : _handle(h) + { } + + explicit operator bool() const + { return _handle != nullptr; } + + explicit operator ui_typeinst *() const + { return (ui_typeinst *) _handle; } + + explicit operator void *() const + { return _handle; } + }; + + static_assert(sizeof(Object) == sizeof(ui_widget *), "object slicing"); + + class Widget : public Object, public Convertible { + public: + using native = ui_widget; + explicit Widget(ui_widget *h = nullptr) : Object((void *) h) + { } + + alert_response alert(std::string text, std::string title = "NetRadiant", + alert_type type = alert_type::OK, alert_icon icon = alert_icon::Default); + + const char *file_dialog(bool open, const char *title, const char *path = nullptr, + const char *pattern = nullptr, bool want_load = false, bool want_import = false, + bool want_save = false); + }; + + static_assert(sizeof(Widget) == sizeof(Object), "object slicing"); + + extern Widget root; + +#define WRAP(name, super, impl, methods) \ + class name : public super, public Convertible { \ + public: \ + using native = impl; \ + explicit name(impl *h) : super(reinterpret_cast(h)) {} \ + methods \ + }; \ + static_assert(sizeof(name) == sizeof(super), "object slicing") + + WRAP(AccelGroup, Object, ui_accelgroup, + AccelGroup(); + ); + + WRAP(Adjustment, Widget, ui_adjustment, + Adjustment(double value, + double lower, double upper, + double step_increment, double page_increment, + double page_size); + ); + + WRAP(Alignment, Widget, ui_alignment, + Alignment(float xalign, float yalign, float xscale, float yscale); + ); + + WRAP(Box, Widget, ui_box,); + + WRAP(Button, Widget, ui_button, + Button(); + Button(const char *label); + ); + + WRAP(CellRenderer, Object, ui_cellrenderer,); + + WRAP(CellRendererText, CellRenderer, ui_cellrenderertext, + CellRendererText(); + ); + + WRAP(CheckButton, Widget, ui_checkbutton, + CheckButton(const char *label); + ); + + WRAP(ComboBox, Widget, ui_combobox,); + + WRAP(ComboBoxText, ComboBox, ui_comboboxtext, + ComboBoxText(); + ); + + WRAP(Entry, Widget, ui_entry, + Entry(); + Entry(std::size_t max_length); + ); + + WRAP(Frame, Widget, ui_frame, + Frame(const char *label = nullptr); + ); + + WRAP(HBox, Box, ui_hbox, + HBox(bool homogenous, int spacing); + ); + + WRAP(HScale, Widget, ui_hscale, + HScale(Adjustment adjustment); + HScale(double min, double max, double step); + ); + + WRAP(Image, Widget, ui_image, + Image(); + ); + + WRAP(Label, Widget, ui_label, + Label(const char *label); + ); + + WRAP(Menu, Widget, ui_menu, + Menu(); + ); + + WRAP(MenuItem, Widget, ui_menuitem, + MenuItem(const char *label, bool mnemonic = false); + ); + + WRAP(Paned, Widget, ui_paned,); + + WRAP(HPaned, Paned, ui_hpaned, + HPaned(); + ); + + WRAP(VPaned, Paned, ui_vpaned, + VPaned(); + ); + + WRAP(ScrolledWindow, Widget, ui_scrolledwindow, + ScrolledWindow(); + ); + + WRAP(SpinButton, Widget, ui_spinbutton, + SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits); + ); + + WRAP(Table, Widget, ui_table, + Table(std::size_t rows, std::size_t columns, bool homogenous); + ); + + WRAP(TextView, Widget, ui_textview, + TextView(); + ); + + WRAP(TreeModel, Widget, ui_treemodel,); + + WRAP(TreePath, Object, ui_treepath, + TreePath(); + TreePath(const char *path); + ); + + WRAP(TreeView, Widget, ui_treeview, + TreeView(); + TreeView(TreeModel model); + ); + + struct TreeViewColumnAttribute { + const char *attribute; + int column; + }; + WRAP(TreeViewColumn, Widget, ui_treeviewcolumn, + TreeViewColumn(const char *title, CellRenderer renderer, std::initializer_list attributes); + ); + + WRAP(VBox, Box, ui_vbox, + VBox(bool homogenous, int spacing); + ); + + WRAP(Window, Widget, ui_window, + Window() : Window(nullptr) {}; + Window(window_type type); + + Window create_dialog_window(const char *title, void func(), void *data, int default_w = -1, + int default_h = -1); + + Window create_modal_dialog_window(const char *title, ui_modal &dialog, int default_w = -1, + int default_h = -1); + + Window create_floating_window(const char *title); + + std::uint64_t on_key_press(bool (*f)(Widget widget, ui_evkey *event, void *extra), + void *extra = nullptr); + ); + +#undef WRAP + +} + +#endif diff --git a/plugins/textool/2DView.cpp b/plugins/textool/2DView.cpp index 4da3fab3..a01172a1 100644 --- a/plugins/textool/2DView.cpp +++ b/plugins/textool/2DView.cpp @@ -114,25 +114,25 @@ bool C2DView::OnRButtonUp( int x, int y ){ if ( m_bPopup ) { GtkWidget *menu, *item; - menu = gtk_menu_new(); + menu = ui::Menu(); - item = gtk_menu_item_new_with_label( "Validate (RETURN)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Validate ), NULL ); + item = ui::MenuItem( "Validate (RETURN)" ); + g_signal_connect( GTK_OBJECT( item ), "activate", G_CALLBACK( Textool_Validate ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom in (INSERT)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomIn ), this ); + item = ui::MenuItem( "Zoom in (INSERT)" ); + g_signal_connect( GTK_OBJECT( item ), "activate", G_CALLBACK( view_ZoomIn ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom out (DELETE)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomOut ), this ); + item = ui::MenuItem( "Zoom out (DELETE)" ); + g_signal_connect( GTK_OBJECT( item ), "activate", G_CALLBACK( view_ZoomOut ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Cancel (ESC)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Cancel ), NULL ); + item = ui::MenuItem( "Cancel (ESC)" ); + g_signal_connect( GTK_OBJECT( item ), "activate", G_CALLBACK( Textool_Cancel ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 50fbf125..63f77b7f 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -54,22 +54,22 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ GtkWidget *window, *w, *vbox, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window = ui::Window( ui::window_type::TOP ); + g_signal_connect( GTK_OBJECT( window ), "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + g_signal_connect( GTK_OBJECT( window ), "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -78,72 +78,72 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( mode == MB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = IDOK; } else if ( mode == MB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else if ( mode == MB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + g_signal_connect( GTK_OBJECT( w ), "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); ret = IDNO; } @@ -643,17 +643,17 @@ static GtkWidget* CreateOpenGLWidget(){ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); // Connect signal handlers - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "motion_notify_event", - GTK_SIGNAL_FUNC( motion ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_press_event", - GTK_SIGNAL_FUNC( button_press ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_release_event", - GTK_SIGNAL_FUNC( button_release ), NULL ); - - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "delete_event", GTK_SIGNAL_FUNC( close ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "key_press_event", - GTK_SIGNAL_FUNC( keypress ), NULL ); + g_signal_connect( GTK_OBJECT( g_pToolWidget ), "expose_event", G_CALLBACK( expose ), NULL ); + g_signal_connect( GTK_OBJECT( g_pToolWidget ), "motion_notify_event", + G_CALLBACK( motion ), NULL ); + g_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_press_event", + G_CALLBACK( button_press ), NULL ); + g_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_release_event", + G_CALLBACK( button_release ), NULL ); + + g_signal_connect( GTK_OBJECT( g_pToolWnd ), "delete_event", G_CALLBACK( close ), NULL ); + g_signal_connect( GTK_OBJECT( g_pToolWnd ), "key_press_event", + G_CALLBACK( keypress ), NULL ); return g_pToolWidget; } diff --git a/plugins/vfspk3/archive.cpp b/plugins/vfspk3/archive.cpp index 9fd15428..cf2bdeee 100644 --- a/plugins/vfspk3/archive.cpp +++ b/plugins/vfspk3/archive.cpp @@ -37,6 +37,7 @@ #include "archivelib.h" #include "fs_path.h" + class DirectoryArchive : public Archive { CopiedString m_root; diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp index fe42687c..b9f9b824 100644 --- a/radiant/autosave.cpp +++ b/radiant/autosave.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "autosave.h" #include "os/file.h" @@ -91,7 +92,7 @@ void Map_Snapshot(){ { StringOutputStream strMsg( 256 ); strMsg << "Snapshot save failed.. unabled to create directory\n" << snapshotsDir.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), strMsg.c_str() ); + MainFrame_getWindow().alert( strMsg.c_str() ); } } /* @@ -174,8 +175,8 @@ void QE_CheckAutoSave( void ){ } void Autosave_constructPreferences( PreferencesPage& page ){ - GtkWidget* autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); - GtkWidget* autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); + ui::CheckButton autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); + ui::SpinButton autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); Widget_connectToggleDependency( autosave_frequency, autosave_enabled ); page.appendCheckBox( "", "Save Snapshots", g_SnapShots_Enabled ); } diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index c49464be..3979f6a8 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -36,6 +36,7 @@ #include "preferences.h" #include +#include void Brush_ConstructCuboid( Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection ){ const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } }; @@ -1367,9 +1368,9 @@ void Brush_registerCommands(){ GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ClipSelected", FreeCaller(), Accelerator( GDK_Return ) ); - GlobalCommands_insert( "SplitSelected", FreeCaller(), Accelerator( GDK_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "FlipClip", FreeCaller(), Accelerator( GDK_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ClipSelected", FreeCaller(), Accelerator( GDK_KEY_Return ) ); + GlobalCommands_insert( "SplitSelected", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "FlipClip", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "MakeDetail", FreeCaller(), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "MakeStructural", FreeCaller(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); diff --git a/radiant/build.cpp b/radiant/build.cpp index 073e0ddf..1a414988 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -633,14 +633,7 @@ void build_commands_write( const char* filename ){ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "gtkutil/dialog.h" #include "gtkutil/closure.h" @@ -679,7 +672,7 @@ ProjectList( Project& project ) : m_project( project ), m_changed( false ){ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){ Project& project = projectList->m_project; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); @@ -715,7 +708,7 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch return FALSE; } -gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList* projectList ){ +gboolean project_key_press( ui::Widget widget, GdkEventKey* event, ProjectList* projectList ){ Project& project = projectList->m_project; if ( event->keyval == GDK_Delete ) { @@ -786,7 +779,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc } Build& build = *g_current_build; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); @@ -817,7 +810,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc return FALSE; } -gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore* store ){ +gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, GtkListStore* store ){ if ( g_current_build == 0 ) { return FALSE; } @@ -844,10 +837,10 @@ gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore } -GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Build Menu", G_CALLBACK( dialog_delete_callback ), &modal, -1, 400 ); +ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ + ui::Window window = MainFrame_getWindow().create_dialog_window("Build Menu", G_CALLBACK(dialog_delete_callback ), &modal, -1, 400 ); - GtkWidget* buildView = 0; + ui::Widget buildView; { GtkTable* table1 = create_dialog_table( 2, 2, 4, 4, 4 ); @@ -878,14 +871,14 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList ); + g_signal_connect( G_OBJECT(renderer), "edited", G_CALLBACK( project_cell_edited ), &projectList ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); @@ -915,14 +908,14 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store ); + g_signal_connect( G_OBJECT(renderer), "edited", G_CALLBACK( commands_cell_edited ), store ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); @@ -959,7 +952,7 @@ void DoBuildMenu(){ ProjectList projectList( g_build_project ); - GtkWindow* window = BuildMenuDialog_construct( modal, projectList ); + ui::Window window = BuildMenuDialog_construct( modal, projectList ); if ( modal_dialog_show( window, modal ) == eIDCANCEL ) { build_commands_clear(); diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 9e97ce96..d250f873 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -25,6 +25,7 @@ // Leonardo Zide (leo@lokigames.com) // +#include #include "camwindow.h" #include "debugging/debugging.h" @@ -669,8 +670,8 @@ static Shader* m_state_select2; FreezePointer m_freezePointer; public: -GtkWidget* m_gl_widget; -GtkWindow* m_parent; +ui::Widget m_gl_widget; +ui::Window m_parent; SelectionSystemWindowObserver* m_window_observer; XORRectangle m_XORRectangle; @@ -756,17 +757,17 @@ void GlobalCamera_setCamWnd( CamWnd& camwnd ){ } -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ){ +ui::Widget CamWnd_getWidget( CamWnd& camwnd ){ return camwnd.m_gl_widget; } -GtkWindow* CamWnd_getParent( CamWnd& camwnd ){ +ui::Window CamWnd_getParent( CamWnd& camwnd ){ return camwnd.m_parent; } ToggleShown g_camera_shown( true ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ){ +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ){ camwnd.m_parent = parent; g_camera_shown.connect( GTK_WIDGET( camwnd.m_parent ) ); } @@ -799,7 +800,7 @@ void Camera_setAngles( CamWnd& camwnd, const Vector3& angles ){ // ============================================================================= // CamWnd class -gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean enable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->EnableFreeMove(); return TRUE; @@ -807,7 +808,7 @@ gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean disable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->DisableFreeMove(); return TRUE; @@ -816,7 +817,7 @@ gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event } #if 0 -gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean mousecontrol_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { Cam_MouseControl( camwnd->getCamera(), event->x, widget->allocation.height - 1 - event->y ); } @@ -825,20 +826,20 @@ gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, Ca #endif void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){ - if ( GTK_WIDGET_VISIBLE( self.m_gl_widget ) ) { + if ( gtk_widget_get_visible( self.m_gl_widget ) ) { self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) ); } } -gboolean selection_button_press( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } @@ -850,30 +851,32 @@ void selection_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->onMouseMotion( WindowVector_forDouble( x, y ), modifiers_for_state( state ) ); } -inline WindowVector windowvector_for_widget_centre( GtkWidget* widget ){ - return WindowVector( static_cast( widget->allocation.width / 2 ), static_cast( widget->allocation.height / 2 ) ); +inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){ + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + return WindowVector( static_cast( allocation.width / 2 ), static_cast(allocation.height / 2 ) ); } -gboolean selection_button_press_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_motion_freemove( GtkWidget *widget, GdkEventMotion *event, WindowObserver* observer ){ +gboolean selection_motion_freemove( ui::Widget widget, GdkEventMotion *event, WindowObserver* observer ){ observer->onMouseMotion( windowvector_for_widget_centre( widget ), modifiers_for_state( event->state ) ); return FALSE; } -gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){ +gboolean wheelmove_scroll( ui::Widget widget, GdkEventScroll* event, CamWnd* camwnd ){ if ( event->direction == GDK_SCROLL_UP ) { Camera_Freemove_updateAxes( camwnd->getCamera() ); Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); @@ -886,7 +889,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam return FALSE; } -gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, CamWnd* camwnd ){ +gboolean camera_size_allocate( ui::Widget widget, GtkAllocation* allocation, CamWnd* camwnd ){ camwnd->getCamera().width = allocation->width; camwnd->getCamera().height = allocation->height; Camera_updateProjection( camwnd->getCamera() ); @@ -895,7 +898,7 @@ gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, Cam return FALSE; } -gboolean camera_expose( GtkWidget* widget, GdkEventExpose* event, gpointer data ){ +gboolean camera_expose( ui::Widget widget, GdkEventExpose* event, gpointer data ){ reinterpret_cast( data )->draw(); return FALSE; } @@ -913,27 +916,27 @@ void KeyEvent_disconnect( const char* name ){ } void CamWnd_registerCommands( CamWnd& camwnd ){ - GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ), + GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_KEY_Up ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ), + GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_KEY_Down ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ), + GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_KEY_Left ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ), + GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_KEY_Right ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ), + GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ), + GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); @@ -1142,7 +1145,7 @@ CamWnd::CamWnd() : m_view( true ), m_Camera( &m_view, CamWndQueueDraw( *this ) ), m_cameraview( m_Camera, &m_view, ReferenceCaller( *this ) ), - m_gl_widget( glwidget_new( TRUE ) ), + m_gl_widget( ui::Widget(glwidget_new( TRUE )) ), m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ), @@ -1160,10 +1163,10 @@ CamWnd::CamWnd() : m_window_observer->setRectangleDrawCallback( ReferenceCaller1( *this ) ); m_window_observer->setView( m_view ); - gtk_widget_ref( m_gl_widget ); + g_object_ref( m_gl_widget ); gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( m_gl_widget, true ); m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( camera_size_allocate ), this ); m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( camera_expose ), this ); @@ -1191,7 +1194,7 @@ CamWnd::~CamWnd(){ g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler ); - gtk_widget_unref( m_gl_widget ); + g_object_unref( m_gl_widget ); m_window_observer->release(); } @@ -1278,7 +1281,7 @@ void CamWnd::Cam_PositionDrag(){ // NOTE TTimo if there's an OS-level focus out of the application // then we can release the camera cursor grab -static gboolean camwindow_freemove_focusout( GtkWidget* widget, GdkEventFocus* event, gpointer data ){ +static gboolean camwindow_freemove_focusout( ui::Widget widget, GdkEventFocus* event, gpointer data ){ reinterpret_cast( data )->DisableFreeMove(); return FALSE; } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 8e578c85..bfe449e5 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -22,12 +22,10 @@ #if !defined( INCLUDED_CAMWINDOW_H ) #define INCLUDED_CAMWINDOW_H +#include #include "math/vector.h" #include "signal/signalfwd.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - class CamWnd; CamWnd* NewCamWnd(); void DeleteCamWnd( CamWnd* camwnd ); @@ -36,8 +34,8 @@ void AddCameraMovedCallback( const SignalHandler& handler ); void CamWnd_Update( CamWnd& camwnd ); -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ); +ui::Widget CamWnd_getWidget( CamWnd& camwnd ); +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index f608ea49..f463503e 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -27,10 +27,8 @@ #include #include "string/string.h" #include "versionlib.h" -#include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" -#include -#include +#include #include "gtkmisc.h" typedef std::pair ShortcutValue; // accelerator, isRegistered @@ -150,13 +148,8 @@ void connect_accelerator( const char *name ){ } -#include - -#include -#include -#include -#include -#include +#include +#include #include "gtkutil/dialog.h" #include "mainframe.h" @@ -239,7 +232,7 @@ void accelerator_edit_button_clicked( GtkButton *btn, gpointer dialogptr ){ dialog.m_waiting_for_key = true; } -gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gpointer dialogptr ){ +bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpointer dialogptr ){ command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr; if ( !dialog.m_waiting_for_key ) { @@ -253,20 +246,20 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp #else switch ( event->keyval ) { - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Caps_Lock: - case GDK_Shift_Lock: - case GDK_Meta_L: - case GDK_Meta_R: - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Super_L: - case GDK_Super_R: - case GDK_Hyper_L: - case GDK_Hyper_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Caps_Lock: + case GDK_KEY_Shift_Lock: + case GDK_KEY_Meta_L: + case GDK_KEY_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Super_L: + case GDK_KEY_Super_R: + case GDK_KEY_Hyper_L: + case GDK_KEY_Hyper_R: return false; } #endif @@ -293,11 +286,11 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp { const char *commandName; const Accelerator &newAccel; - GtkWidget *widget; + ui::Widget widget; GtkTreeModel *model; public: bool allow; - VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, GtkWidget *w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ + VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, ui::Widget w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ } void visit( const char* name, Accelerator& accelerator ){ if ( !strcmp( name, commandName ) ) { @@ -313,8 +306,8 @@ public: StringOutputStream msg; msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n" << "Do you want to unassign " << name << " first?"; - EMessageBoxReturn r = gtk_MessageBox( widget, msg.c_str(), "Key already used", eMB_YESNOCANCEL ); - if ( r == eIDYES ) { + auto r = widget.alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL ); + if ( r == ui::alert_response::YES ) { // clear the ACTUAL accelerator too! disconnect_accelerator( name ); // delete the modifier @@ -338,7 +331,7 @@ public: } } } - else if ( r == eIDCANCEL ) { + else if ( r == ui::alert_response::CANCEL ) { // aborted allow = false; } @@ -394,10 +387,12 @@ public: void DoCommandListDlg(){ command_list_dialog_t dialog; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Mapped Commands", dialog, -1, 400 ); - g_signal_connect( G_OBJECT( window ), "key-press-event", (GCallback) accelerator_window_key_press, &dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400); + window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) { + return accelerator_window_key_press(widget, event, dialogptr); + }, &dialog); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); GtkHBox* hbox = create_dialog_hbox( 4, 4 ); @@ -410,20 +405,20 @@ void DoCommandListDlg(){ { GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel(GTK_TREE_MODEL(store))); dialog.m_list = GTK_TREE_VIEW( view ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Command", renderer, "text", 0, "weight-set", 2, "weight", 3, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Command", renderer, {{"text", 0}, {"weight-set", 2}, {"weight", 3}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 1, "weight-set", 2, "weight", 3, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 1}, {"weight-set", 2}, {"weight", 3}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } @@ -478,7 +473,7 @@ public: GtkButton* clearbutton = create_dialog_button( "Clear", (GCallback) accelerator_clear_button_clicked, &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( clearbutton ), FALSE, FALSE, 0 ); - GtkWidget *spacer = gtk_image_new(); + ui::Widget spacer = ui::Image(); gtk_widget_show( spacer ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( spacer ), TRUE, TRUE, 0 ); diff --git a/radiant/console.cpp b/radiant/console.cpp index 72a64140..b8968d0c 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -22,10 +22,8 @@ #include "console.h" #include -#include -#include -#include -#include +#include +#include #include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" @@ -69,8 +67,8 @@ void Sys_LogFile( bool enable ){ << "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n"; } else{ - gtk_MessageBox( 0, "Failed to create log file, check write permissions in Radiant directory.\n", - "Console logging", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "Failed to create log file, check write permissions in Radiant directory.\n", + "Console logging", ui::alert_type::OK, ui::alert_icon::Error ); } } else if ( !enable && g_hLogFile != 0 ) { @@ -83,7 +81,7 @@ void Sys_LogFile( bool enable ){ } } -GtkWidget* g_console = 0; +ui::Widget g_console; void console_clear(){ GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) ); @@ -93,27 +91,27 @@ void console_clear(){ void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){ menu_separator( menu ); - GtkWidget* item = gtk_menu_item_new_with_label( "Clear" ); + ui::Widget item(ui::MenuItem( "Clear" )); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 ); gtk_widget_show( item ); container_add_widget( GTK_CONTAINER( menu ), item ); } -gboolean destroy_set_null( GtkWindow* widget, GtkWidget** p ){ - *p = 0; +gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){ + *p = ui::Widget(); return FALSE; } WidgetFocusPrinter g_consoleWidgetFocusPrinter( "console" ); -GtkWidget* Console_constructWindow( GtkWindow* toplevel ){ - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); +ui::Widget Console_constructWindow( ui::Window toplevel ){ + ui::Widget scr = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); gtk_widget_show( scr ); { - GtkWidget* text = gtk_text_view_new(); + ui::Widget text = ui::TextView(); gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE ); @@ -212,7 +210,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ if ( contains_newline ) { gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW( g_console ), end ); - if ( !ScreenUpdates_Enabled() && GTK_WIDGET_REALIZED( g_console ) ) { + if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) { ScreenUpdates_process(); } } diff --git a/radiant/console.h b/radiant/console.h index 38e479fd..8bbe71e1 100644 --- a/radiant/console.h +++ b/radiant/console.h @@ -23,6 +23,7 @@ #define INCLUDED_CONSOLE_H #include +#include #define SYS_VRB 0 ///< verbose support (on/off) #define SYS_STD 1 ///< standard print level - this is the default @@ -35,9 +36,7 @@ class TextOutputStream; TextOutputStream& getSysPrintOutputStream(); TextOutputStream& getSysPrintErrorStream(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* Console_constructWindow( GtkWindow* toplevel ); +ui::Widget Console_constructWindow( ui::Window toplevel ); // will open/close the log file based on the parameter void Sys_LogFile( bool enable ); diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index e98cac92..51c2b107 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -35,18 +35,7 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "stream/stringstream.h" #include "convert.h" @@ -59,7 +48,7 @@ GtkEntry* DialogEntry_new(){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 ); return entry; @@ -68,20 +57,20 @@ GtkEntry* DialogEntry_new(){ class DialogEntryRow { public: -DialogEntryRow( GtkWidget* row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){ +DialogEntryRow( ui::Widget row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){ } -GtkWidget* m_row; +ui::Widget m_row; GtkEntry* m_entry; }; DialogEntryRow DialogEntryRow_new( const char* name ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); GtkEntry* entry = DialogEntry_new(); gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) ); - return DialogEntryRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), entry ); + return DialogEntryRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), entry ); } @@ -92,7 +81,7 @@ GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int { ++digits; } - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( value, lower, upper, step, 10, 0 ) ), step, digits ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 ); return spin; @@ -101,20 +90,20 @@ GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int class DialogSpinnerRow { public: -DialogSpinnerRow( GtkWidget* row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ +DialogSpinnerRow( ui::Widget row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ } -GtkWidget* m_row; +ui::Widget m_row; GtkSpinButton* m_spin; }; DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction ); gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) ); - return DialogSpinnerRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), spin ); + return DialogSpinnerRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), spin ); } @@ -204,7 +193,7 @@ void FloatSpinnerImport( GtkSpinButton& widget, float value ){ gtk_spin_button_set_value( &widget, value ); } void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){ - importCallback( float(gtk_spin_button_get_value_as_float( &widget ) ) ); + importCallback( float(gtk_spin_button_get_value( &widget ) ) ); } typedef ImportExport FloatSpinnerImportExport; @@ -318,39 +307,39 @@ Dialog::~Dialog(){ ( *i )->release(); } - ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" ); + ASSERT_MESSAGE( !m_window, "dialog window not destroyed" ); } void Dialog::ShowDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); importData(); gtk_widget_show( GTK_WIDGET( m_window ) ); } void Dialog::HideDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); exportData(); gtk_widget_hide( GTK_WIDGET( m_window ) ); } -static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ +static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ reinterpret_cast( data )->HideDlg(); reinterpret_cast( data )->EndModal( eIDCANCEL ); return TRUE; } void Dialog::Create(){ - ASSERT_MESSAGE( m_window == 0, "dialog cannot be constructed" ); + ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" ); m_window = BuildDialog(); g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this ); } void Dialog::Destroy(){ - ASSERT_MESSAGE( m_window != 0, "dialog cannot be destroyed" ); + ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" ); gtk_widget_destroy( GTK_WIDGET( m_window ) ); - m_window = 0; + m_window = ui::Window(); } @@ -451,7 +440,7 @@ EMessageBoxReturn Dialog::DoModal(){ PreModal(); EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal ); - ASSERT_NOTNULL( m_window ); + ASSERT_TRUE( (bool) m_window ); if ( ret == eIDOK ) { exportData(); } @@ -464,8 +453,8 @@ EMessageBoxReturn Dialog::DoModal(){ } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ - GtkWidget* check = gtk_check_button_new_with_label( flag ); +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ + auto check = ui::CheckButton( flag ); gtk_widget_show( check ); AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer ); @@ -473,19 +462,19 @@ GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* f return check; } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ){ +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){ return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); +void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); { - GtkWidget* combo = gtk_combo_box_new_text(); + ui::Widget combo = ui::ComboBoxText(); for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i ) { - gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), *i ); + gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i ); } AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer ); @@ -498,23 +487,23 @@ void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange value DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ){ +void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){ addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ +void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ #if 0 if ( draw_value == FALSE ) { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 ); + ui::Widget hbox2 = ui::HBox( FALSE, 0 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( low ); + ui::Widget label = ui::Label( low ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } { - GtkWidget* label = gtk_label_new( high ); + ui::Widget label = ui::Label( high ); gtk_widget_show( label ); gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } @@ -522,14 +511,14 @@ void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean d #endif // adjustment - GtkObject* adj = gtk_adjustment_new( value, lower, upper, step_increment, page_increment, 0 ); - AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) ); + auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 ); + AddIntAdjustmentData( *GTK_ADJUSTMENT(adj), IntImportCaller( data ), IntExportCaller( data ) ); // scale - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 ); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 ); gtk_widget_show( alignment ); - GtkWidget* scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + ui::Widget scale = ui::HScale( adj ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT ); gtk_widget_show( scale ); gtk_container_add( GTK_CONTAINER( alignment ), scale ); @@ -541,8 +530,8 @@ void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean d DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); +void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); { RadioHBox radioBox = RadioHBox_new( names ); @@ -554,19 +543,19 @@ void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ){ +void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){ addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* table = gtk_table_new( 2, static_cast( icons.last - icons.first ), FALSE ); +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE ); gtk_widget_show( table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); GSList* group = 0; - GtkWidget* radio = 0; + ui::Widget radio; for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon ) { guint pos = static_cast( icon - icons.first ); @@ -576,7 +565,7 @@ void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); - radio = gtk_radio_button_new( group ); + radio = ui::Widget(gtk_radio_button_new( group )); gtk_widget_show( radio ); gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2, (GtkAttachOptions) ( 0 ), @@ -590,32 +579,32 @@ void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ){ +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){ addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* Dialog::addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +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 ); return row.m_row; } -GtkWidget* Dialog::addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ +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 ); return row.m_row; } -GtkWidget* Dialog::addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +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 ); return row.m_row; } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ PathEntry pathEntry = PathEntry_new(); g_signal_connect( G_OBJECT( pathEntry.m_button ), "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry ); @@ -624,27 +613,27 @@ GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_ GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) ); DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); - return GTK_WIDGET( row ); + return ui::Widget(GTK_WIDGET( row )); } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool browse_directory ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool browse_directory ){ return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +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 ); - return row.m_row; + return ui::SpinButton(row.m_spin); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){ return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +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 ); - return row.m_row; + return ui::SpinButton(row.m_spin); } diff --git a/radiant/dialog.h b/radiant/dialog.h index 2a0454eb..3e68095f 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -23,6 +23,7 @@ #define INCLUDED_DIALOG_H #include +#include #include "gtkutil/dialog.h" #include "generic/callback.h" @@ -107,11 +108,11 @@ typedef std::list DialogDataList; class Dialog { -GtkWindow* m_window; +ui::Window m_window; DialogDataList m_data; public: ModalDialog m_modal; -GtkWindow* m_parent; +ui::Window m_parent; Dialog(); virtual ~Dialog(); @@ -122,7 +123,7 @@ virtual ~Dialog(); */ EMessageBoxReturn DoModal(); void EndModal( EMessageBoxReturn code ); -virtual GtkWindow* BuildDialog() = 0; +virtual ui::Window BuildDialog() = 0; virtual void exportData(); virtual void importData(); virtual void PreModal() { }; @@ -131,39 +132,39 @@ virtual void ShowDlg(); virtual void HideDlg(); void Create(); void Destroy(); -GtkWindow* GetWidget(){ +ui::Window GetWidget(){ return m_window; } -const GtkWindow* GetWidget() const { +const ui::Window GetWidget() const { return m_window; } -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ); -void addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ); -void addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); -void addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ); -void addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ); -GtkWidget* addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, int& data ){ +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ); +void addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ); +void addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); +void addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ); +void addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ); +ui::Widget addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, int& data ){ return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, std::size_t& data ){ +ui::Widget addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, std::size_t& data ){ return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) ); } -GtkWidget* addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, float& data ){ +ui::Widget addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, float& data ){ return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) ); } -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool directory ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool directory ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); protected: diff --git a/radiant/entity.cpp b/radiant/entity.cpp index ab3243b0..49ed045b 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -45,6 +45,8 @@ #include "qe3.h" #include "commands.h" +#include "uilib/uilib.h" + struct entity_globals_t { Vector3 color_entity; @@ -287,7 +289,7 @@ int g_iLastLightIntensity; void Entity_createFromSelection( const char* name, const Vector3& origin ){ #if 0 if ( string_equal_nocase( name, "worldspawn" ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); + ui::alert( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); return; } #endif @@ -381,7 +383,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ } if ( isModel ) { - const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) ); + const char* model = misc_model_dialog(MainFrame_getWindow()); if ( model != 0 ) { Node_getEntity( node )->setKeyValue( "model", model ); } @@ -501,7 +503,7 @@ void Entity_setColour(){ normalize = false; } - if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) { + if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) { if ( normalize ) { NormalizeColor( g_entity_globals.color_entity ); } @@ -517,7 +519,7 @@ void Entity_setColour(){ } } -const char* misc_model_dialog( GtkWidget* parent ){ +const char* misc_model_dialog( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; @@ -528,7 +530,7 @@ const char* misc_model_dialog( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char *filename = file_dialog( parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); + const char *filename = parent.file_dialog( TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); if ( filename != 0 ) { // use VFS to get the correct relative path const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); diff --git a/radiant/entity.h b/radiant/entity.h index eaf73cbb..752ff189 100644 --- a/radiant/entity.h +++ b/radiant/entity.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_ENTITY_H ) #define INCLUDED_ENTITY_H +#include + template class BasicVector3; typedef BasicVector3 Vector3; void Entity_createFromSelection( const char* name, const Vector3& origin ); @@ -30,8 +32,7 @@ void Scene_EntitySetKeyValue_Selected( const char* key, const char* value ); void Scene_EntitySetClassname_Selected( const char* classname ); -typedef struct _GtkWidget GtkWidget; -const char* misc_model_dialog( GtkWidget* parent ); +const char* misc_model_dialog( ui::Widget parent ); typedef struct _GtkMenu GtkMenu; void Entity_constructMenu( GtkMenu* menu ); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 5c1c330b..3c21a47d 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -33,22 +33,8 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include "os/path.h" @@ -79,7 +65,7 @@ #include "groupdialog.h" GtkEntry* numeric_entry_new(){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 ); return entry; @@ -118,7 +104,7 @@ void Scene_EntitySetKeyValue_Selected_Undoable( const char* key, const char* val class EntityAttribute { public: -virtual GtkWidget* getWidget() const = 0; +virtual ui::Widget getWidget() const = 0; virtual void update() = 0; virtual void release() = 0; }; @@ -128,7 +114,7 @@ class BooleanAttribute : public EntityAttribute CopiedString m_key; GtkCheckButton* m_check; -static gboolean toggled( GtkWidget *widget, BooleanAttribute* self ){ +static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){ self->apply(); return FALSE; } @@ -146,8 +132,8 @@ BooleanAttribute( const char* key ) : update(); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_check ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_check )); } void release(){ delete this; @@ -181,15 +167,15 @@ StringAttribute( const char* key ) : m_key( key ), m_entry( 0 ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_entry = entry; m_nonModal.connect( m_entry ); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } GtkEntry* getEntry() const { return m_entry; @@ -237,8 +223,8 @@ ModelAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -253,7 +239,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = misc_model_dialog( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) )); if ( filename != 0 ) { setPath( filename ); @@ -263,7 +249,7 @@ void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ typedef MemberCaller1 BrowseCaller; }; -const char* browse_sound( GtkWidget* parent ){ +const char* browse_sound( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "sound/"; @@ -274,7 +260,7 @@ const char* browse_sound( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char* filename = file_dialog( parent, TRUE, "Open Wav File", buffer.c_str(), "sound" ); + const char* filename = parent.file_dialog(TRUE, "Open Wav File", buffer.c_str(), "sound" ); if ( filename != 0 ) { const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); if ( relative == filename ) { @@ -300,8 +286,8 @@ SoundAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -316,7 +302,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = browse_sound( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) )) ); if ( filename != 0 ) { setPath( filename ); @@ -347,8 +333,8 @@ AngleAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } void apply(){ StringOutputStream angle( 32 ); @@ -399,7 +385,7 @@ DirectionAttribute( const char* key ) : m_nonModalRadio.connect( m_radio.m_radio ); - m_hbox = GTK_HBOX( gtk_hbox_new( FALSE, 4 ) ); + m_hbox = ui::HBox( FALSE, 4 ); gtk_widget_show( GTK_WIDGET( m_hbox ) ); gtk_box_pack_start( GTK_BOX( m_hbox ), GTK_WIDGET( m_radio.m_hbox ), TRUE, TRUE, 0 ); @@ -408,8 +394,8 @@ DirectionAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angle( 32 ); @@ -481,12 +467,13 @@ class AnglesAttribute : public EntityAttribute CopiedString m_key; AnglesEntry m_angles; NonModalEntry m_nonModal; -GtkBox* m_hbox; +ui::HBox m_hbox; public: AnglesAttribute( const char* key ) : m_key( key ), - m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); + m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ), + m_hbox(ui::HBox( TRUE, 4 )) +{ gtk_widget_show( GTK_WIDGET( m_hbox ) ); { GtkEntry* entry = numeric_entry_new(); @@ -510,8 +497,8 @@ AnglesAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angles( 64 ); @@ -573,7 +560,7 @@ public: Vector3Attribute( const char* key ) : m_key( key ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); + m_hbox = ui::HBox( TRUE, 4 ); gtk_widget_show( GTK_WIDGET( m_hbox ) ); { GtkEntry* entry = numeric_entry_new(); @@ -597,8 +584,8 @@ Vector3Attribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream vector3( 64 ); @@ -675,11 +662,11 @@ ListAttribute( const char* key, const ListAttributeType& type ) : m_combo( 0 ), m_nonModal( ApplyCaller( *this ) ), m_type( type ){ - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + auto combo = ui::ComboBoxText(); for ( ListAttributeType::const_iterator i = type.begin(); i != type.end(); ++i ) { - gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), ( *i ).first.c_str() ); + gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), ( *i ).first.c_str() ); } gtk_widget_show( GTK_WIDGET( combo ) ); @@ -690,8 +677,8 @@ ListAttribute( const char* key, const ListAttributeType& type ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_combo ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_combo )); } void apply(){ Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_type[gtk_combo_box_get_active( m_combo )].second.c_str() ); @@ -715,8 +702,8 @@ typedef MemberCaller UpdateCaller; namespace { -GtkWidget* g_entity_split1 = 0; -GtkWidget* g_entity_split2 = 0; +ui::Widget g_entity_split1; +ui::Widget g_entity_split2; int g_entitysplit1_position; int g_entitysplit2_position; @@ -873,10 +860,10 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), " " ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), " " ); gtk_widget_hide( widget ); - gtk_widget_ref( widget ); + g_object_ref( widget ); gtk_container_remove( GTK_CONTAINER( g_spawnflagsTable ), widget ); } } @@ -886,7 +873,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); gtk_widget_show( widget ); StringOutputStream str( 16 ); @@ -895,9 +882,9 @@ 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 ); - gtk_widget_unref( widget ); + g_object_unref( widget ); - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), str.c_str() ); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), str.c_str() ); } } } @@ -913,7 +900,7 @@ void EntityClassList_selectEntityClass( EntityClass* eclass ){ GtkTreeView* view = g_entityClassList; GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path ); - if ( GTK_WIDGET_REALIZED( view ) ) { + if ( gtk_widget_get_realized( GTK_WIDGET(view) ) ) { gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 ); } gtk_tree_path_free( path ); @@ -1106,7 +1093,7 @@ void EntityClassList_createEntity(){ GtkTreeModel* model; GtkTreeIter iter; if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) ), "You must have a selected class to create an entity", "info" ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) )).alert( "You must have a selected class to create an entity", "info" ); return; } @@ -1134,14 +1121,14 @@ void EntityInspector_applyKeyValue(){ // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "Cannot change \"classname\" key back to worldspawn.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK ); return; } // RR2DO2: we don't want spaces in entity keys if ( strstr( key.c_str(), " " ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "No spaces are allowed in entity keys.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK ); return; } @@ -1197,7 +1184,7 @@ static void EntityClassList_selection_changed( GtkTreeSelection* selection, gpoi } } -static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){ +static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){ if ( event->type == GDK_2BUTTON_PRESS ) { EntityClassList_createEntity(); return TRUE; @@ -1205,7 +1192,7 @@ static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *eve return FALSE; } -static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +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 ) { @@ -1231,7 +1218,7 @@ static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpo if ( toupper( text[0] ) == (int)code ) { GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path ); - if ( GTK_WIDGET_REALIZED( view ) ) { + if ( gtk_widget_get_realized( GTK_WIDGET(view) ) ) { gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 ); } gtk_tree_path_free( path ); @@ -1269,7 +1256,7 @@ static void EntityProperties_selection_changed( GtkTreeSelection* selection, gpo g_free( val ); } -static void SpawnflagCheck_toggled( GtkWidget *widget, gpointer data ){ +static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){ EntityInspector_applySpawnflags(); } @@ -1293,7 +1280,7 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer return FALSE; } -void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ +void EntityInspector_destroyWindow( ui::Widget widget, gpointer data ){ g_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) ); g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) ); @@ -1301,22 +1288,22 @@ void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ GlobalEntityAttributes_clear(); } -GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ - GtkWidget* vbox = gtk_vbox_new( FALSE, 2 ); +ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ + ui::Widget vbox = ui::VBox( FALSE, 2 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 ); g_signal_connect( G_OBJECT( vbox ), "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 ); { - GtkWidget* split1 = gtk_vpaned_new(); + ui::Widget split1 = ui::VPaned(); gtk_box_pack_start( GTK_BOX( vbox ), split1, TRUE, TRUE, 0 ); gtk_widget_show( split1 ); g_entity_split1 = split1; { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::VPaned(); gtk_paned_add1( GTK_PANED( split1 ), split2 ); gtk_widget_show( split2 ); @@ -1324,7 +1311,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // class list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_paned_add1( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -1333,15 +1320,15 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); - GtkTreeView* view = GTK_TREE_VIEW( gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ) ); + GtkTreeView* 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 ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} ); gtk_tree_view_append_column( view, column ); } @@ -1361,14 +1348,14 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_paned_add2( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkTextView* text = GTK_TEXT_VIEW( gtk_text_view_new() ); + GtkTextView* text = ui::TextView(); gtk_widget_set_size_request( GTK_WIDGET( text ), 0, -1 ); // allow shrinking gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD ); gtk_text_view_set_editable( text, FALSE ); @@ -1380,18 +1367,18 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::VPaned(); gtk_paned_add2( GTK_PANED( split1 ), split2 ); gtk_widget_show( split2 ); { - GtkWidget* vbox2 = gtk_vbox_new( FALSE, 2 ); + ui::Widget vbox2 = ui::VBox( FALSE, 2 ); gtk_widget_show( vbox2 ); gtk_paned_pack1( GTK_PANED( split2 ), vbox2, FALSE, FALSE ); { // Spawnflags (4 colums wide max, or window gets too wide.) - GtkTable* table = GTK_TABLE( gtk_table_new( 4, 4, FALSE ) ); + GtkTable* table = ui::Table( 4, 4, FALSE ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 ); gtk_widget_show( GTK_WIDGET( table ) ); @@ -1399,8 +1386,8 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ for ( int i = 0; i < MAX_FLAGS; i++ ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( "" ) ); - gtk_widget_ref( GTK_WIDGET( check ) ); + GtkCheckButton* 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_entitySpawnflagsCheck[i] = check; } @@ -1408,7 +1395,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // key/value list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_box_pack_start( GTK_BOX( vbox2 ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); @@ -1417,19 +1404,19 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget 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( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 1}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } @@ -1450,14 +1437,14 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // key/value entry - GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) ); + GtkTable* table = ui::Table( 2, 2, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 ); gtk_table_set_row_spacings( table, 3 ); gtk_table_set_col_spacings( table, 5 ); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -1468,7 +1455,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -1479,7 +1466,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Value" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Value" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), @@ -1488,7 +1475,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Key" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Key" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), @@ -1498,18 +1485,18 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkBox* hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); + GtkBox* hbox = ui::HBox( TRUE, 4 ); gtk_widget_show( GTK_WIDGET( hbox ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Clear All" ) ); + GtkButton* button = ui::Button( "Clear All" ); gtk_widget_show( GTK_WIDGET( button ) ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 ); gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Delete Key" ) ); + GtkButton* button = ui::Button( "Delete Key" ); gtk_widget_show( GTK_WIDGET( button ) ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 ); gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 ); @@ -1518,15 +1505,15 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - GtkWidget* viewport = gtk_viewport_new( 0, 0 ); + ui::Widget viewport = ui::Widget(gtk_viewport_new( 0, 0 )); gtk_widget_show( viewport ); gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE ); - g_attributeBox = GTK_VBOX( gtk_vbox_new( FALSE, 2 ) ); + g_attributeBox = ui::VBox( FALSE, 2 ); gtk_widget_show( GTK_WIDGET( g_attributeBox ) ); gtk_container_add( GTK_CONTAINER( viewport ), GTK_WIDGET( g_attributeBox ) ); diff --git a/radiant/entityinspector.h b/radiant/entityinspector.h index 1afa2584..e0d359ec 100644 --- a/radiant/entityinspector.h +++ b/radiant/entityinspector.h @@ -19,12 +19,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYINSPECTOR_H ) #define INCLUDED_ENTITYINSPECTOR_H -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* EntityInspector_constructWindow( GtkWindow* parent ); +ui::Widget EntityInspector_constructWindow( ui::Window parent ); void EntityInspector_construct(); void EntityInspector_destroy(); const char *EntityInspector_getCurrentKey(); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 4fdc5b4e..a9b9a668 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -23,10 +23,8 @@ #include "iselection.h" -#include -#include -#include -#include +#include +#include #include "string/string.h" #include "scenelib.h" @@ -62,7 +60,7 @@ EDirty m_dirty; IdleDraw m_idleDraw; WindowPositionTracker m_positionTracker; -GtkWindow* m_window; +ui::Window m_window; GtkTreeView* m_tree_view; GraphTreeModel* m_tree_model; bool m_selection_disabled; @@ -75,7 +73,7 @@ EntityList() : } bool visible() const { - return GTK_WIDGET_VISIBLE( GTK_WIDGET( m_window ) ); + return gtk_widget_get_visible( m_window ); } }; @@ -282,10 +280,10 @@ void DetachEntityTreeModel(){ gtk_tree_view_set_model( getEntityList().m_tree_view, 0 ); } -void EntityList_constructWindow( GtkWindow* main_window ){ - ASSERT_MESSAGE( getEntityList().m_window == 0, "error" ); +void EntityList_constructWindow( ui::Window main_window ){ + ASSERT_TRUE( !getEntityList().m_window ); - GtkWindow* window = create_persistent_floating_window( "Entity List", main_window ); + ui::Window window = ui::Window(create_persistent_floating_window( "Entity List", main_window )); gtk_window_add_accel_group( window, global_accel ); @@ -299,10 +297,10 @@ void EntityList_constructWindow( GtkWindow* main_window ){ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); { - GtkWidget* view = gtk_tree_view_new(); + ui::Widget view = ui::TreeView(); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); GtkTreeViewColumn* column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start( column, renderer, TRUE ); gtk_tree_view_column_set_cell_data_func( column, renderer, entitylist_treeviewcolumn_celldatafunc, 0, 0 ); diff --git a/radiant/entitylist.h b/radiant/entitylist.h index e29f1b9a..4830bb8d 100644 --- a/radiant/entitylist.h +++ b/radiant/entitylist.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYLIST_H ) #define INCLUDED_ENTITYLIST_H void EntityList_Construct(); void EntityList_Destroy(); -typedef struct _GtkWindow GtkWindow; -void EntityList_constructWindow( GtkWindow* main_window ); +void EntityList_constructWindow( ui::Window main_window ); void EntityList_destroyWindow(); void EntityList_toggleShown(); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 1d2856f5..bb565b84 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -32,12 +32,7 @@ #include "igl.h" #include "iselection.h" -#include -#include -#include -#include -#include -#include +#include #include "map.h" #include "dialog.h" @@ -279,7 +274,7 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ // push in the list g_ptr_array_add( m_pFeedbackElements, (void *)pHandler ); - if ( GetWidget() == 0 ) { + if ( !GetWidget() ) { Create(); } @@ -295,10 +290,10 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ ShowDlg(); } -GtkWindow* CDbgDlg::BuildDialog(){ - GtkWindow* window = create_floating_window( "Q3Map debug window", MainFrame_getWindow() ); +ui::Window CDbgDlg::BuildDialog(){ + ui::Window window = MainFrame_getWindow().create_floating_window("Q3Map debug window" ); - GtkWidget* scr = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); @@ -307,12 +302,12 @@ GtkWindow* CDbgDlg::BuildDialog(){ { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } diff --git a/radiant/feedback.h b/radiant/feedback.h index 04e98bb2..78f4fd04 100644 --- a/radiant/feedback.h +++ b/radiant/feedback.h @@ -171,13 +171,13 @@ void draw2D( VIEWTYPE viewType ){ } } void destroyWindow(){ - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } // void HideDlg(); protected: -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); }; extern CDbgDlg g_DbgDlg; diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index 5fd58f7c..13fad1c2 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -31,17 +31,7 @@ #include "ishaders.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "gtkutil/window.h" #include "stream/stringstream.h" @@ -65,9 +55,9 @@ static void updateTextures( const char* name ); FindTextureDialog(); virtual ~FindTextureDialog(); -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); -void constructWindow( GtkWindow* parent ){ +void constructWindow( ui::Window parent ){ m_parent = parent; Create(); } @@ -95,7 +85,7 @@ void FindTextureDialog_apply(){ FindReplaceTextures( find.c_str(), replace.c_str(), g_FindTextureDialog.m_bSelectedOnly ); } -static void OnApply( GtkWidget* widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_FindTextureDialog.exportData(); FindTextureDialog_apply(); } @@ -111,17 +101,17 @@ static void OnOK( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } -static void OnClose( GtkWidget* widget, gpointer data ){ +static void OnClose( ui::Widget widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } -static gint find_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint find_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = true; return FALSE; } -static gint replace_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint replace_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = false; return FALSE; } @@ -137,42 +127,42 @@ FindTextureDialog::FindTextureDialog(){ FindTextureDialog::~FindTextureDialog(){ } -GtkWindow* FindTextureDialog::BuildDialog(){ - GtkWidget* vbox, *hbox, *table, *label; - GtkWidget* button, *check, *entry; +ui::Window FindTextureDialog::BuildDialog(){ + ui::Widget vbox, hbox, table, label; + ui::Widget button, check, entry; - GtkWindow* dlg = create_floating_window( "Find / Replace Texture(s)", m_parent ); + ui::Window dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent )); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( hbox ) ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Find:" ); + label = ui::Label( "Find:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - label = gtk_label_new( "Replace:" ); + label = ui::Label( "Replace:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -182,7 +172,7 @@ GtkWindow* FindTextureDialog::BuildDialog(){ AddDialogData( *GTK_ENTRY( entry ), m_strFind ); GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -192,28 +182,28 @@ GtkWindow* FindTextureDialog::BuildDialog(){ AddDialogData( *GTK_ENTRY( entry ), m_strReplace ); GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); - check = gtk_check_button_new_with_label( "Within selected brushes only" ); + check = ui::CheckButton( "Within selected brushes only" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); AddDialogData( *GTK_TOGGLE_BUTTON( check ), m_bSelectedOnly ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Apply" ); + button = ui::Button( "Apply" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnApply ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "Close" ); + button = ui::Button( "Close" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnClose ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); return dlg; } @@ -231,7 +221,7 @@ void FindTextureDialog::updateTextures( const char* name ){ } bool FindTextureDialog::isOpen(){ - return GTK_WIDGET_VISIBLE( g_FindTextureDialog.GetWidget() ) == TRUE; + return gtk_widget_get_visible( g_FindTextureDialog.GetWidget() ) == TRUE; } void FindTextureDialog::setFindStr( const char* name ){ @@ -251,7 +241,7 @@ void FindTextureDialog::show(){ } -void FindTextureDialog_constructWindow( GtkWindow* main_window ){ +void FindTextureDialog_constructWindow( ui::Window main_window ){ g_FindTextureDialog.constructWindow( main_window ); } diff --git a/radiant/findtexturedialog.h b/radiant/findtexturedialog.h index 2bf06dbb..66022e8b 100644 --- a/radiant/findtexturedialog.h +++ b/radiant/findtexturedialog.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_FINDTEXTUREDIALOG_H ) #define INCLUDED_FINDTEXTUREDIALOG_H void FindTextureDialog_Construct(); void FindTextureDialog_Destroy(); -typedef struct _GtkWindow GtkWindow; -void FindTextureDialog_constructWindow( GtkWindow* main_window ); +void FindTextureDialog_constructWindow( ui::Window main_window ); void FindTextureDialog_destroyWindow(); bool FindTextureDialog_isOpen(); void FindTextureDialog_selectTexture( const char* name ); diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 2e717d12..7b954535 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -32,10 +32,7 @@ #include -#include -#include -#include -#include +#include #include "gtkutil/widget.h" #include "gtkutil/accelerator.h" @@ -46,17 +43,16 @@ #include "commands.h" -#include #include "gtkutil/window.h" class GroupDlg { public: -GtkWidget* m_pNotebook; -GtkWindow* m_window; +ui::Widget m_pNotebook; +ui::Window m_window; GroupDlg(); -void Create( GtkWindow* parent ); +void Create( ui::Window parent ); void Show(){ // workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event @@ -78,14 +74,14 @@ std::size_t g_current_page; std::vector g_pages; } -void GroupDialog_updatePageTitle( GtkWindow* window, std::size_t pageIndex ){ +void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){ if ( pageIndex < g_pages.size() ) { g_pages[pageIndex]( PointerCaller1( window ) ); } } -static gboolean switch_page( GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data ){ - GroupDialog_updatePageTitle( GTK_WINDOW( data ), page_num ); +static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_num, gpointer data ){ + GroupDialog_updatePageTitle( ui::Window(GTK_WINDOW( data )), page_num ); g_current_page = page_num; return FALSE; @@ -95,10 +91,10 @@ GroupDlg::GroupDlg() : m_window( 0 ){ m_position_tracker.setPosition( c_default_window_pos ); } -void GroupDlg::Create( GtkWindow* parent ){ - ASSERT_MESSAGE( m_window == 0, "dialog already created" ); +void GroupDlg::Create( ui::Window parent ){ + ASSERT_MESSAGE( !m_window, "dialog already created" ); - GtkWindow* window = create_persistent_floating_window( "Entities", parent ); + ui::Window window = ui::Window(create_persistent_floating_window( "Entities", parent )); global_accel_connect_window( window ); @@ -116,21 +112,21 @@ void GroupDlg::Create( GtkWindow* parent ){ m_position_tracker.connect( window ); { - GtkWidget* notebook = gtk_notebook_new(); + ui::Widget notebook = ui::Widget(gtk_notebook_new()); gtk_widget_show( notebook ); gtk_container_add( GTK_CONTAINER( window ), notebook ); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); m_pNotebook = notebook; - g_signal_connect( G_OBJECT( notebook ), "switch_page", G_CALLBACK( switch_page ), window ); + g_signal_connect( G_OBJECT(notebook), "switch_page", G_CALLBACK( switch_page ), (gpointer) window ); } } -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ){ - GtkWidget* w = gtk_label_new( tabLabel ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ){ + ui::Widget w = ui::Label( tabLabel ); gtk_widget_show( w ); - GtkWidget* page = gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ); + ui::Widget page = ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) )); g_pages.push_back( title ); return page; @@ -147,33 +143,33 @@ void GroupDialog_ToggleShow(){ GroupDialog_setShown( !GroupDialog_isShown() ); } -void GroupDialog_constructWindow( GtkWindow* main_window ){ +void GroupDialog_constructWindow( ui::Window main_window ){ g_GroupDlg.Create( main_window ); } void GroupDialog_destroyWindow(){ - ASSERT_NOTNULL( g_GroupDlg.m_window ); + ASSERT_TRUE( g_GroupDlg.m_window ); destroy_floating_window( g_GroupDlg.m_window ); - g_GroupDlg.m_window = 0; + g_GroupDlg.m_window = ui::Window(); } -GtkWindow* GroupDialog_getWindow(){ - return g_GroupDlg.m_window; +ui::Window GroupDialog_getWindow(){ + return ui::Window(g_GroupDlg.m_window); } void GroupDialog_show(){ g_GroupDlg.Show(); } -GtkWidget* GroupDialog_getPage(){ - return gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); +ui::Widget GroupDialog_getPage(){ + return ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) )); } -void GroupDialog_setPage( GtkWidget* page ){ +void GroupDialog_setPage( ui::Widget page ){ g_current_page = gtk_notebook_page_num( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), page ); gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_showPage( GtkWidget* page ){ +void GroupDialog_showPage( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_ToggleShow(); } @@ -189,7 +185,7 @@ void GroupDialog_cycle(){ gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_updatePageTitle( GtkWidget* page ){ +void GroupDialog_updatePageTitle( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_updatePageTitle( g_GroupDlg.m_window, g_current_page ); } diff --git a/radiant/groupdialog.h b/radiant/groupdialog.h index 349802b1..50e880b4 100644 --- a/radiant/groupdialog.h +++ b/radiant/groupdialog.h @@ -22,28 +22,26 @@ #if !defined( INCLUDED_GROUPDIALOG_H ) #define INCLUDED_GROUPDIALOG_H +#include #include "generic/callback.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - void GroupDialog_Construct(); void GroupDialog_Destroy(); -void GroupDialog_constructWindow( GtkWindow* main_window ); +void GroupDialog_constructWindow( ui::Window main_window ); void GroupDialog_destroyWindow(); -GtkWindow* GroupDialog_getWindow(); +ui::Window GroupDialog_getWindow(); void GroupDialog_show(); inline void RawStringExport( const char* string, const StringImportCallback& importer ){ importer( string ); } typedef ConstPointerCaller1 RawStringExportCaller; -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ); -void GroupDialog_showPage( GtkWidget* page ); -void GroupDialog_updatePageTitle( GtkWidget* page ); +void GroupDialog_showPage( ui::Widget page ); +void GroupDialog_updatePageTitle( ui::Widget page ); bool GroupDialog_isShown(); -GtkWidget* GroupDialog_getPage(); +ui::Widget GroupDialog_getPage(); #endif diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index dbc3abd6..7b71b3d9 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -45,22 +45,8 @@ #include "iselection.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include "os/path.h" #include "math/aabb.h" @@ -167,11 +153,11 @@ inline void path_copy_clean( char* destination, const char* source ){ struct GameCombo { - GtkComboBox* game_select; + ui::ComboBoxText game_select; GtkEntry* fsgame_entry; }; -gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){ +gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){ const char *gamename; { GtkTreeIter iter; @@ -214,8 +200,8 @@ GameCombo game_combo; GtkComboBox* gamemode_combo; }; -GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Project Settings", G_CALLBACK( dialog_delete_callback ), &modal ); +ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ + ui::Window window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal ); { GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 ); @@ -244,7 +230,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Select mod" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Select mod" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -252,13 +238,13 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); } { - dialog.game_combo.game_select = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + dialog.game_combo.game_select = ui::ComboBoxText(); - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame ); if ( globalGameComboConfiguration().known[0] != '\0' ) { - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known ); } - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom ); gtk_widget_show( GTK_WIDGET( dialog.game_combo.game_select ) ); gtk_table_attach( table2, GTK_WIDGET( dialog.game_combo.game_select ), 1, 2, 0, 1, @@ -269,7 +255,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "fs_game" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "fs_game" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -277,7 +263,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table2, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -287,16 +273,16 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } if ( globalMappingMode().do_mapping_mode ) { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Mapping mode" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Mapping mode" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); - gtk_combo_box_append_text( combo, globalMappingMode().sp_mapping_mode ); - gtk_combo_box_append_text( combo, globalMappingMode().mp_mapping_mode ); + auto combo = ui::ComboBoxText(); + gtk_combo_box_text_append_text( combo, globalMappingMode().sp_mapping_mode ); + gtk_combo_box_text_append_text( combo, globalMappingMode().mp_mapping_mode ); gtk_widget_show( GTK_WIDGET( combo ) ); gtk_table_attach( table2, GTK_WIDGET( combo ), 1, 2, 3, 4, @@ -366,7 +352,7 @@ void DoProjectSettings(){ ModalDialog modal; ProjectSettingsDialog dialog; - GtkWindow* window = ProjectSettingsDialog_construct( dialog, modal ); + ui::Window window = ProjectSettingsDialog_construct( dialog, modal ); if ( modal_dialog_show( window, modal ) == eIDOK ) { ProjectSettingsDialog_ok( dialog ); @@ -383,21 +369,21 @@ void DoSides( int type, int axis ){ ModalDialog dialog; GtkEntry* sides_entry; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { GtkHBox* hbox = create_dialog_hbox( 4, 4 ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Sides:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Sides:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 ); sides_entry = entry; @@ -432,13 +418,13 @@ void DoSides( int type, int axis ){ // ============================================================================= // About dialog (no program is complete without one) -void about_button_changelog( GtkWidget *widget, gpointer data ){ +void about_button_changelog( ui::Widget widget, gpointer data ){ StringOutputStream log( 256 ); log << "https://gitlab.com/xonotic/netradiant/commits/master"; OpenURL( log.c_str() ); } -void about_button_credits( GtkWidget *widget, gpointer data ){ +void about_button_credits( ui::Widget widget, gpointer data ){ StringOutputStream cred( 256 ); cred << "https://gitlab.com/xonotic/netradiant/graphs/master"; OpenURL( cred.c_str() ); @@ -454,7 +440,7 @@ void DoAbout(){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); { GtkVBox* vbox = create_dialog_vbox( 4, 4 ); @@ -479,15 +465,16 @@ void DoAbout(){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "NetRadiant " RADIANT_VERSION "\n" - __DATE__ "\n\n" - RADIANT_ABOUTMSG "\n\n" - "By xonotic.org\n\n" - "This program is free software\n" - "licensed under the GNU GPL.\n\n" - "NetRadiant is unsupported, however\n" - "you may report your problems on issue tracker.\n" - ) ); + char const *label_text = "NetRadiant " RADIANT_VERSION "\n" + __DATE__ "\n\n" + RADIANT_ABOUTMSG "\n\n" + "This program is free software\n" + "licensed under the GNU GPL.\n\n" + "NetRadiant is unsupported, however\n" + "you may report your problems at\n" + "https://gitlab.com/xonotic/netradiant/issues"; + + GtkLabel* label = GTK_LABEL( ui::Label( label_text ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); @@ -523,7 +510,7 @@ void DoAbout(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vendor:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vendor:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -531,7 +518,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Version:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Version:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -539,7 +526,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Renderer:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Renderer:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -547,7 +534,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VENDOR ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_VENDOR ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -555,7 +542,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VERSION ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_VERSION ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -563,7 +550,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_RENDERER ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_RENDERER ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -578,7 +565,7 @@ void DoAbout(){ GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) ); { - GtkWidget* text_extensions = gtk_text_view_new(); + ui::Widget text_extensions = ui::TextView(); gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE ); gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions ); GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) ); @@ -610,9 +597,9 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkEntry* x; GtkEntry* y; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Patch texture layout", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -622,7 +609,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture will be fit across the patch based\n" + GtkLabel* label = GTK_LABEL( ui::Label( "Texture will be fit across the patch based\n" "on the x and y values given. Values of 1x1\n" "will \"fit\" the texture. 2x2 will repeat\n" "it twice, etc." ) ); @@ -635,7 +622,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture x:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Texture x:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -643,7 +630,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture y:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Texture y:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -651,7 +638,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -660,7 +647,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ x = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -718,11 +705,11 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ // Text Editor dialog // master window widget -static GtkWidget *text_editor = 0; -static GtkWidget *text_widget; // slave, text widget from the gtk editor +static ui::Widget text_editor; +static ui::Widget text_widget; // slave, text widget from the gtk editor -static gint editor_delete( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static gint editor_delete( ui::Widget widget, gpointer data ){ + if ( widget.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return TRUE; } @@ -731,12 +718,12 @@ static gint editor_delete( GtkWidget *widget, gpointer data ){ return TRUE; } -static void editor_save( GtkWidget *widget, gpointer data ){ +static void editor_save( ui::Widget widget, gpointer data ){ FILE *f = fopen( (char*)g_object_get_data( G_OBJECT( data ), "filename" ), "w" ); gpointer text = g_object_get_data( G_OBJECT( data ), "text" ); if ( f == 0 ) { - gtk_MessageBox( GTK_WIDGET( data ), "Error saving file !" ); + ui::Widget(GTK_WIDGET( data )).alert( "Error saving file !" ); return; } @@ -745,8 +732,8 @@ static void editor_save( GtkWidget *widget, gpointer data ){ fclose( f ); } -static void editor_close( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static void editor_close( ui::Widget widget, gpointer data ){ + if ( text_editor.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return; } @@ -754,49 +741,49 @@ static void editor_close( GtkWidget *widget, gpointer data ){ } static void CreateGtkTextEditor(){ - GtkWidget *dlg; - GtkWidget *vbox, *hbox, *button, *scr, *text; + ui::Widget dlg; + ui::Widget vbox, hbox, button, scr, text; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + dlg = ui::Window( ui::window_type::TOP ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( editor_delete ), 0 ); gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - scr = gtk_scrolled_window_new( 0, 0 ); + scr = ui::ScrolledWindow(); gtk_widget_show( scr ); gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); - text = gtk_text_view_new(); + text = ui::TextView(); gtk_container_add( GTK_CONTAINER( scr ), text ); gtk_widget_show( text ); - g_object_set_data( G_OBJECT( dlg ), "text", text ); + g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "Close" ); + button = ui::Button( "Close" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( editor_close ), dlg ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "Save" ); + button = ui::Button( "Save" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( editor_save ), dlg ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); text_editor = dlg; text_widget = text; @@ -871,9 +858,9 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Light intensity", dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -883,12 +870,12 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC for default, ENTER to validate" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "ESC for default, ENTER to validate" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); @@ -938,9 +925,9 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -951,12 +938,12 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { //GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces")); - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC to cancel, ENTER to validate" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "ESC to cancel, ENTER to validate" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); @@ -997,9 +984,9 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -1009,22 +996,22 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "The selected shader" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "The selected shader" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); + GtkLabel* label = GTK_LABEL( ui::Label( name ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "is located in file" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "is located in file" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( filename ) ); + GtkLabel* label = GTK_LABEL( ui::Label( filename ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } @@ -1063,7 +1050,7 @@ void DoTextEditor( const char* filename, int cursorpos ){ #ifdef WIN32 if ( g_TextEditor_useWin32Editor ) { globalOutputStream() << "opening file '" << filename << "' (line " << cursorpos << " info ignored)\n"; - ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", filename, 0, 0, SW_SHOW ); + ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", filename, 0, 0, SW_SHOW ); return; } #else diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 59dab2a9..a2e6e5c7 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -34,8 +34,8 @@ #include "gtkmisc.h" -#include -#include +#include +#include "uilib/uilib.h" #include "math/vector.h" #include "os/path.h" @@ -86,47 +86,40 @@ GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic return create_menu_item_with_mnemonic( menu, mnemonic, command ); } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ return toolbar_append_button( toolbar, description, icon, GlobalCommands_find( commandName ) ); } -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ return toolbar_append_toggle_button( toolbar, description, icon, GlobalToggles_find( commandName ) ); } // ============================================================================= // File dialog -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ - GtkWidget* dlg; - double clr[3]; +bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ + ui::Widget dlg; + GdkColor clr = { 0, guint16(color[0] * 65535), guint16(color[1] * 65535), guint16(color[2] * 65535) }; ModalDialog dialog; - clr[0] = color[0]; - clr[1] = color[1]; - clr[2] = color[2]; - - dlg = gtk_color_selection_dialog_new( title ); - gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); + dlg = ui::Widget(gtk_color_selection_dialog_new( title )); + gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); - g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); - g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); + GtkWidget *ok_button, *cancel_button; + g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + g_signal_connect( ok_button, "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); + g_signal_connect( cancel_button, "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); - if ( parent != 0 ) { + if ( parent ) { gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) ); } bool ok = modal_dialog_show( GTK_WINDOW( dlg ), dialog ) == eIDOK; if ( ok ) { - GdkColor gdkcolor; - gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), &gdkcolor ); - clr[0] = gdkcolor.red / 65535.0; - clr[1] = gdkcolor.green / 65535.0; - clr[2] = gdkcolor.blue / 65535.0; - - color[0] = (float)clr[0]; - color[1] = (float)clr[1]; - color[2] = (float)clr[2]; + gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); + color[0] = clr.red / 65535.0f; + color[1] = clr.green / 65535.0f; + color[2] = clr.blue / 65535.0f; } gtk_widget_destroy( dlg ); @@ -134,17 +127,17 @@ bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ return ok; } -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){ - const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) ); +void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ){ + const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { gtk_entry_set_text( entry, filename ); } } -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ){ +void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ){ const char* text = gtk_entry_get_text( entry ); - char *dir = dir_dialog( gtk_widget_get_toplevel( widget ), "Choose Directory", path_is_absolute( text ) ? text : "" ); + char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" ); if ( dir != 0 ) { gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 14cdd816..867aaccb 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -31,7 +31,8 @@ #if !defined( INCLUDED_GTKMISC_H ) #define INCLUDED_GTKMISC_H -#include +#include +#include inline void process_gui(){ while ( gtk_events_pending() ) @@ -59,17 +60,17 @@ typedef struct _GtkToggleButton GtkToggleButton; typedef struct _GtkToolbar GtkToolbar; // this DOES NOT set up the shortcut using command_connect_accelerator -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); +GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); // this DOES NOT set up the shortcut using command_connect_accelerator -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); +GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); template class BasicVector3; typedef BasicVector3 Vector3; -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title = "Choose Color" ); +bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" ); typedef struct _GtkEntry GtkEntry; -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ); -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ); +void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ); +void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ); #endif diff --git a/radiant/main.cpp b/radiant/main.cpp index e46d903f..6620d662 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -69,7 +69,8 @@ #include "iundo.h" -#include +#include "uilib/uilib.h" +#include #include "cmdlib.h" #include "os/file.h" @@ -303,12 +304,12 @@ bool handleMessage(){ ScopedLock lock( m_lock ); #if defined _DEBUG m_buffer << "Break into the debugger?\n"; - bool handled = gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO; + bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO; m_buffer.clear(); return handled; #else m_buffer << "Please report this error to the developers\n"; - gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_OK, eMB_ICONERROR ); + ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error ); m_buffer.clear(); #endif } @@ -394,9 +395,9 @@ bool check_version(){ if ( !bVerIsGood ) { StringOutputStream msg( 256 ); msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n" - "Make sure you run the right/latest editor binary you installed\n" + "Make sure you run the right/latest editor binary you installed\n" << AppPath_get(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT ); + ui::alert( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT ); } return bVerIsGood; #else @@ -424,7 +425,7 @@ void create_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -434,14 +435,14 @@ void create_global_pid(){ "The failure may be related to current global preferences.\n" "Do you want to reset global preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) { g_GamesDialog.Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // set without saving, the class is not in a coherent state yet @@ -465,7 +466,7 @@ void remove_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } } @@ -483,7 +484,7 @@ void create_local_pid(){ if ( remove( g_pidGameFile.c_str() ) == -1 ) { StringOutputStream msg; msg << "WARNING: Could not delete " << g_pidGameFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -493,14 +494,14 @@ void create_local_pid(){ "The failure may be caused by current preferences.\n" "Do you want to reset all preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) { Preferences_Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // force console logging on! (will go in prefs too) @@ -668,7 +669,7 @@ int main( int argc, char* argv[] ){ remove_local_pid(); - gtk_main(); + ui::main(); // avoid saving prefs when the app is minimized if ( g_pParentWnd->IsSleeping() ) { diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 53ef24a6..1758a765 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -43,16 +43,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "cmdlib.h" @@ -452,18 +443,18 @@ void Paths_registerPreferencesPage(){ class PathsDialog : public Dialog { public: -GtkWindow* BuildDialog(){ +ui::Window BuildDialog(){ GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Paths_constructPreferences( preferencesPage ); } - return 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, GTK_WIDGET( frame ) )); } }; @@ -828,7 +819,7 @@ ChooseColour( const GetColourCallback& get, const SetColourCallback& set ) void operator()(){ Vector3 colour; m_get( colour ); - color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour ); + color_dialog( MainFrame_getWindow(), colour ); m_set( colour ); } }; @@ -973,13 +964,13 @@ void OpenBugReportURL(){ } -GtkWidget* g_page_console; +ui::Widget g_page_console; void Console_ToggleShow(){ GroupDialog_showPage( g_page_console ); } -GtkWidget* g_page_entity; +ui::Widget g_page_entity; void EntityInspector_ToggleShow(){ GroupDialog_showPage( g_page_entity ); @@ -1608,33 +1599,33 @@ guint s_qe_every_second_id = 0; void EverySecondTimer_enable(){ if ( s_qe_every_second_id == 0 ) { - s_qe_every_second_id = gtk_timeout_add( 1000, qe_every_second, 0 ); + s_qe_every_second_id = g_timeout_add( 1000, qe_every_second, 0 ); } } void EverySecondTimer_disable(){ if ( s_qe_every_second_id != 0 ) { - gtk_timeout_remove( s_qe_every_second_id ); + g_source_remove( s_qe_every_second_id ); s_qe_every_second_id = 0; } } -gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); +gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); return FALSE; } class WaitDialog { public: -GtkWindow* m_window; +ui::Window m_window; GtkLabel* m_label; }; WaitDialog create_wait_dialog( const char* title, const char* text ){ WaitDialog dialog; - dialog.m_window = create_floating_window( title, MainFrame_getWindow() ); + dialog.m_window = MainFrame_getWindow().create_floating_window(title); gtk_window_set_resizable( dialog.m_window, FALSE ); gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 ); gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT ); @@ -1642,7 +1633,7 @@ WaitDialog create_wait_dialog( const char* title, const char* text ){ g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 ); { - dialog.m_label = GTK_LABEL( gtk_label_new( text ) ); + dialog.m_label = GTK_LABEL( ui::Label( text ) ); gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 ); gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT ); gtk_widget_show( GTK_WIDGET( dialog.m_label ) ); @@ -1692,7 +1683,7 @@ bool ScreenUpdates_Enabled(){ } void ScreenUpdates_process(){ - if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { + if ( redrawRequired() && gtk_widget_get_visible( g_wait.m_window ) ) { process_gui(); } } @@ -1714,7 +1705,7 @@ void ScreenUpdates_Disable( const char* message, const char* title ){ ScreenUpdates_process(); } } - else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { gtk_label_set_text( g_wait.m_label, message ); ScreenUpdates_process(); } @@ -1730,11 +1721,11 @@ void ScreenUpdates_Enable(){ gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) ); destroy_floating_window( g_wait.m_window ); - g_wait.m_window = 0; + g_wait.m_window = ui::Window(); //gtk_window_present(MainFrame_getWindow()); } - else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() ); ScreenUpdates_process(); } @@ -1893,10 +1884,10 @@ void fill_view_xz_front_menu( GtkMenu* menu ){ } -GtkWidget* g_toggle_z_item = 0; -GtkWidget* g_toggle_console_item = 0; -GtkWidget* g_toggle_entity_item = 0; -GtkWidget* g_toggle_entitylist_item = 0; +ui::Widget g_toggle_z_item; +ui::Widget g_toggle_console_item; +ui::Widget g_toggle_entity_item; +ui::Widget g_toggle_entitylist_item; GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ // View menu @@ -2330,67 +2321,73 @@ void Manipulators_constructToolbar( GtkToolbar* toolbar ){ GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL ); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); gtk_widget_show( GTK_WIDGET( toolbar ) ); + auto space = [&]() { + auto btn = gtk_separator_tool_item_new(); + gtk_widget_show(GTK_WIDGET(btn)); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(btn)); + }; + File_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); UndoRedo_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); RotateFlip_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Select_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); CSG_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); ComponentModes_constructToolbar( toolbar ); if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) { - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); XYWnd_constructToolbar( toolbar ); } - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); CamWnd_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Manipulators_constructToolbar( toolbar ); if ( g_Layout_enablePatchToolbar.m_value ) { - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Patch_constructToolbar( toolbar ); } - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT +T)", "texture_lock.png", "TogTexLock" ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); - GtkButton* g_view_entities_button = toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" ); - GtkButton* g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" ); - GtkButton* g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" ); + /*auto g_view_entities_button =*/ toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" ); + auto g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" ); + auto g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" ); // TODO: call light inspector //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector"); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); - GtkButton* g_refresh_models_button = toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" ); + space(); + /*auto g_refresh_models_button =*/ toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" ); // disable the console and texture button in the regular layouts @@ -2402,36 +2399,36 @@ GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ return toolbar; } -GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){ - GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) ); +ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){ + GtkTable* table = ui::Table( 1, c_count_status, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 ); - pStatusLabel[c_command_status] = GTK_WIDGET( label ); + pStatusLabel[c_command_status] = ui::Widget(GTK_WIDGET( label )); } for ( int i = 1; i < c_count_status; ++i ) { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) ); + GtkFrame* frame = ui::Frame(); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 ); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) ); - pStatusLabel[i] = GTK_WIDGET( label ); + pStatusLabel[i] = ui::Widget(GTK_WIDGET( label )); } - return GTK_WIDGET( table ); + return ui::Widget(GTK_WIDGET( table )); } #if 0 @@ -2443,15 +2440,15 @@ class WindowFocusPrinter { const char* m_name; -static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){ +static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " frame_event\n"; return FALSE; } -static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){ +static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " keys_changed\n"; return FALSE; } -static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){ +static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){ if ( gtk_window_is_active( window ) ) { globalOutputStream() << self->m_name << " takes toplevel focus\n"; } @@ -2464,7 +2461,7 @@ static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* s public: WindowFocusPrinter( const char* name ) : m_name( name ){ } -void connect( GtkWindow* toplevel_window ){ +void connect( ui::Window toplevel_window ){ g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this ); g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this ); @@ -2478,15 +2475,15 @@ WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" ); class MainWindowActive { -static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){ - if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { +static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){ + if ( g_wait.m_window && gtk_window_is_active( window ) && !gtk_widget_get_visible( g_wait.m_window ) ) { gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); } return FALSE; } public: -void connect( GtkWindow* toplevel_window ){ +void connect( ui::Window toplevel_window ){ g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this ); } }; @@ -2514,14 +2511,12 @@ void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){ MainFrame* g_pParentWnd = 0; -GtkWindow* MainFrame_getWindow(){ - if ( g_pParentWnd == 0 ) { - return 0; - } - return g_pParentWnd->m_window; +ui::Window MainFrame_getWindow() +{ + return g_pParentWnd ? g_pParentWnd->m_window : ui::Window(); } -std::vector g_floating_windows; +std::vector g_floating_windows; MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){ m_pXYWnd = 0; @@ -2533,7 +2528,7 @@ MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusText for ( int n = 0; n < c_count_status; n++ ) { - m_pStatusLabel[n] = 0; + m_pStatusLabel[n] = ui::root; } m_bSleeping = false; @@ -2548,7 +2543,7 @@ MainFrame::~MainFrame(){ Shutdown(); - for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) + for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) { gtk_widget_destroy( *i ); } @@ -2673,8 +2668,8 @@ void MainFrame::OnSleep(){ } -GtkWindow* create_splash(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); +ui::Window create_splash(){ + ui::Window window = ui::Window( ui::window_type::TOP ); gtk_window_set_decorated( window, FALSE ); gtk_window_set_resizable( window, FALSE ); gtk_window_set_modal( window, TRUE ); @@ -2692,7 +2687,7 @@ GtkWindow* create_splash(){ return window; } -static GtkWindow *splash_screen = 0; +static ui::Window splash_screen; void show_splash(){ splash_screen = create_splash(); @@ -2709,7 +2704,7 @@ WindowPositionTracker g_posXYWnd; WindowPositionTracker g_posXZWnd; WindowPositionTracker g_posYZWnd; -static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){ +static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){ if ( ConfirmModified( "Exit Radiant" ) ) { gtk_main_quit(); } @@ -2718,7 +2713,7 @@ static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data } void MainFrame::Create(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); + ui::Window window = ui::Window( ui::window_type::TOP ); GlobalWindowObservers_connectTopLevel( window ); @@ -2729,7 +2724,7 @@ void MainFrame::Create(){ GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); if ( pixbuf != 0 ) { gtk_window_set_icon( window, pixbuf ); - gdk_pixbuf_unref( pixbuf ); + g_object_unref( pixbuf ); } } #endif @@ -2746,9 +2741,9 @@ void MainFrame::Create(){ g_MainWindowActive.connect( window ); - GetPlugInMgr().Init( GTK_WIDGET( window ) ); + GetPlugInMgr().Init( window ); - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); + ui::Widget vbox = ui::VBox( FALSE, 0 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); @@ -2770,7 +2765,7 @@ void MainFrame::Create(){ } gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 ); - GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel ); + ui::Widget main_statusbar = create_main_statusbar( m_pStatusLabel ); gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 ); GroupDialog_constructWindow( window ); @@ -2803,17 +2798,17 @@ void MainFrame::Create(){ if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { { - GtkWidget* vsplit = gtk_vpaned_new(); + ui::Widget vsplit = ui::VPaned(); m_vSplit = vsplit; gtk_box_pack_start( GTK_BOX( vbox ), vsplit, TRUE, TRUE, 0 ); gtk_widget_show( vsplit ); // console - GtkWidget* console_window = Console_constructWindow( window ); + ui::Widget console_window = Console_constructWindow( window ); gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); { - GtkWidget* hsplit = gtk_hpaned_new(); + ui::Widget hsplit = ui::HPaned(); gtk_widget_show( hsplit ); m_hSplit = hsplit; gtk_paned_add1( GTK_PANED( vsplit ), hsplit ); @@ -2821,10 +2816,10 @@ void MainFrame::Create(){ // xy m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) ); + ui::Widget xy_window = ui::Widget(GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) )); { - GtkWidget* vsplit2 = gtk_vpaned_new(); + ui::Widget vsplit2 = ui::VPaned(); gtk_widget_show( vsplit2 ); m_vSplit2 = vsplit2; @@ -2869,7 +2864,7 @@ void MainFrame::Create(){ } else if ( CurrentStyle() == eFloating ) { { - GtkWindow* window = create_persistent_floating_window( "Camera", m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window )); global_accel_connect_window( window ); g_posCamWnd.connect( window ); @@ -2884,11 +2879,11 @@ void MainFrame::Create(){ } CamWnd_setParent( *m_pCamWnd, window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window )); global_accel_connect_window( window ); g_posXYWnd.connect( window ); @@ -2903,11 +2898,11 @@ void MainFrame::Create(){ } XY_Top_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window )); global_accel_connect_window( window ); g_posXZWnd.connect( window ); @@ -2922,11 +2917,11 @@ void MainFrame::Create(){ XZ_Front_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window )); global_accel_connect_window( window ); g_posYZWnd.connect( window ); @@ -2941,12 +2936,12 @@ void MainFrame::Create(){ YZ_Side_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } GroupDialog_show(); @@ -2957,29 +2952,29 @@ void MainFrame::Create(){ GlobalCamera_setCamWnd( *m_pCamWnd ); CamWnd_setParent( *m_pCamWnd, window ); - GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd ); + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); m_pYZWnd = new XYWnd(); m_pYZWnd->SetViewType( YZ ); - GtkWidget* yz = m_pYZWnd->GetWidget(); + ui::Widget yz = m_pYZWnd->GetWidget(); m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy = m_pXYWnd->GetWidget(); + ui::Widget xy = m_pXYWnd->GetWidget(); m_pXZWnd = new XYWnd(); m_pXZWnd->SetViewType( XZ ); - GtkWidget* xz = m_pXZWnd->GetWidget(); + ui::Widget xz = m_pXZWnd->GetWidget(); GtkHPaned* split = create_split_views( camera, yz, xy, xz ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 ); { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } } @@ -3020,7 +3015,7 @@ void MainFrame::SaveWindowInfo(){ g_layout_globals.m_position = m_position_tracker.getPosition(); - g_layout_globals.nState = gdk_window_get_state( GTK_WIDGET( m_window )->window ); + g_layout_globals.nState = gdk_window_get_state( gtk_widget_get_window(GTK_WIDGET( m_window )) ); } void MainFrame::Shutdown(){ diff --git a/radiant/mainframe.h b/radiant/mainframe.h index c450fd54..cb5274f3 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_MAINFRAME_H ) #define INCLUDED_MAINFRAME_H +#include #include "gtkutil/window.h" #include "gtkutil/idledraw.h" #include "gtkutil/widget.h" @@ -60,7 +61,7 @@ enum EViewStyle MainFrame(); ~MainFrame(); -GtkWindow* m_window; +ui::Window m_window; CopiedString m_command_status; CopiedString m_position_status; @@ -73,9 +74,9 @@ void Create(); void SaveWindowInfo(); void Shutdown(); -GtkWidget* m_vSplit; -GtkWidget* m_hSplit; -GtkWidget* m_vSplit2; +ui::Widget m_vSplit; +ui::Widget m_hSplit; +ui::Widget m_vSplit2; XYWnd* m_pXYWnd; XYWnd* m_pYZWnd; @@ -86,7 +87,7 @@ XYWnd* m_pActiveXY; bool m_bSleeping; -GtkWidget *m_pStatusLabel[c_count_status]; +ui::Widget m_pStatusLabel[c_count_status]; EViewStyle m_nCurrentStyle; @@ -142,7 +143,7 @@ bool FloatingGroupDialog(){ extern MainFrame* g_pParentWnd; -GtkWindow* MainFrame_getWindow(); +ui::Window MainFrame_getWindow(); enum EMouseButtonMode { @@ -271,6 +272,6 @@ void XYWindowDestroyed_disconnect( SignalHandlerId id ); MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler ); void XYWindowMouseDown_disconnect( MouseEventHandlerId id ); -extern GtkWidget* g_page_entity; +extern ui::Widget g_page_entity; #endif diff --git a/radiant/map.cpp b/radiant/map.cpp index 147cfa98..0dc0798d 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -42,15 +42,9 @@ MapModules& ReferenceAPI_getMapModules(); #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include "uilib/uilib.h" #include "scenelib.h" #include "transformlib.h" @@ -772,7 +766,7 @@ void DoMapInfo(){ GtkEntry* entities_entry; GtkListStore* EntityBreakdownWalker; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Map Info", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog ); window_set_position( window, g_posMapInfoWnd ); @@ -789,27 +783,27 @@ void DoMapInfo(){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_entry_set_editable( entry, FALSE ); + gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE ); brushes_entry = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_entry_set_editable( entry, FALSE ); + gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE ); entities_entry = entry; } { - GtkWidget* label = gtk_label_new( "Total Brushes" ); + ui::Widget label = ui::Label( "Total Brushes" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -817,7 +811,7 @@ void DoMapInfo(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkWidget* label = gtk_label_new( "Total Entities" ); + ui::Widget label = ui::Label( "Total Entities" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -836,7 +830,7 @@ void DoMapInfo(){ } } { - GtkWidget* label = gtk_label_new( "Entity breakdown" ); + ui::Widget label = ui::Label( "Entity breakdown" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, TRUE, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); @@ -848,19 +842,19 @@ void DoMapInfo(){ { GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 0 ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 1 ); } @@ -1812,15 +1806,15 @@ const char* getLastFolderPath(){ } const char* map_open( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getLastFolderPath(), MapFormat::Name(), true, false, false ); } const char* map_import( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); } const char* map_save( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getLastFolderPath(), MapFormat::Name(), false, false, true ); + return MainFrame_getWindow().file_dialog( FALSE, title, getLastFolderPath(), MapFormat::Name(), false, false, true ); } void OpenMap(){ @@ -2044,9 +2038,9 @@ void DoFind(){ GtkEntry* entity; GtkEntry* brush; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Find Brush", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -2056,21 +2050,21 @@ void DoFind(){ GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( "Entity number" ); + ui::Widget label = ui::Label( "Entity number" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Brush number" ); + ui::Widget label = ui::Label( "Brush number" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -2079,7 +2073,7 @@ void DoFind(){ entity = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -2095,12 +2089,12 @@ void DoFind(){ GtkButton* button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Close", G_CALLBACK( dialog_button_cancel ), &dialog ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } } } diff --git a/radiant/mru.cpp b/radiant/mru.cpp index cb833010..3198b924 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "os/file.h" #include "generic/callback.h" @@ -159,7 +159,7 @@ void MRU_Activate( std::size_t index ){ MRU_SetText( i, MRU_GetText( i + 1 ) ); if ( MRU_used == 0 ) { - gtk_label_set_text( GTK_LABEL( GTK_BIN( MRU_items[0] )->child ), "Recent Files" ); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( MRU_items[0] )) ), "Recent Files" ); gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), FALSE ); } else diff --git a/radiant/multimon.cpp b/radiant/multimon.cpp index 04407591..6fd41003 100644 --- a/radiant/multimon.cpp +++ b/radiant/multimon.cpp @@ -32,8 +32,8 @@ multimon_globals_t g_multimon_globals; LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" ); void MultiMonitor_constructPreferences( PreferencesPage& page ){ - GtkWidget* primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); - GtkWidget* popup = page.appendCheckBox( + ui::CheckButton primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); + ui::CheckButton popup = page.appendCheckBox( "", "Disable system menu on popup windows", LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ), BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched ) @@ -44,7 +44,7 @@ void MultiMonitor_constructPreferences( PreferencesPage& page ){ #include "preferencesystem.h" #include "stringio.h" -#include +#include namespace { diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 73639e54..10d1806f 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -31,15 +31,7 @@ #include "debugging/debugging.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "gtkutil/idledraw.h" #include "gtkutil/entry.h" @@ -212,7 +204,7 @@ static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){ class PatchInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); Subdivisions m_subdivisions; NonModalEntry m_horizontalSubdivisionsEntry; NonModalEntry m_verticalSubdivisionsEntry; @@ -235,8 +227,8 @@ float m_fZ; float m_fVShift; */ int m_nCol; int m_nRow; -GtkComboBox *m_pRowCombo; -GtkComboBox *m_pColCombo; +ui::ComboBoxText m_pRowCombo{nullptr}; +ui::ComboBoxText m_pColCombo{nullptr}; std::size_t m_countRows; std::size_t m_countCols; @@ -265,7 +257,7 @@ PatchInspector() : } bool visible(){ - return GTK_WIDGET_VISIBLE( GetWidget() ); + return gtk_widget_get_visible( GetWidget() ); } // void UpdateInfo(); @@ -284,7 +276,7 @@ void exportData(); PatchInspector g_PatchInspector; -void PatchInspector_constructWindow( GtkWindow* main_window ){ +void PatchInspector_constructWindow( ui::Window main_window ){ g_PatchInspector.m_parent = main_window; g_PatchInspector.Create(); } @@ -320,7 +312,7 @@ void PatchInspector_toggleShown(){ // static functions // memorize the current state (that is don't try to undo our do before changing something else) -static void OnApply( GtkWidget *widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_PatchInspector.exportData(); if ( g_PatchInspector.m_Patch != 0 ) { UndoableCommand command( "patchSetTexture" ); @@ -347,7 +339,7 @@ static void OnApply( GtkWidget *widget, gpointer data ){ } } -static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){ +static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){ if ( !g_PatchInspector.m_bListenChanged ) { return; } @@ -375,27 +367,27 @@ void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){ SceneChangeNotify(); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchfit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){ Patch_FlipTextureX(); } -static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){ Patch_FlipTextureY(); } @@ -455,7 +447,7 @@ void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) ); } -static void OnBtnPatchAutoCap( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){ Patch_AutoCapTexture(); } @@ -466,14 +458,14 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ td.scale[0] = td.scale[1] = 0; td.shift[0] = td.shift[1] = 0; - if ( adj->value == 0 ) { + if ( gtk_adjustment_get_value(adj) == 0 ) { return; } if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hshift_adj" ) ) { g_pi_globals.shift[0] = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.shift[0] = g_pi_globals.shift[0]; } else{ @@ -483,7 +475,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vshift_adj" ) ) { g_pi_globals.shift[1] = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.shift[1] = g_pi_globals.shift[1]; } else{ @@ -495,7 +487,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ if ( g_pi_globals.scale[0] == 0.0f ) { return; } - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.scale[0] = g_pi_globals.scale[0]; } else{ @@ -507,7 +499,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ if ( g_pi_globals.scale[1] == 0.0f ) { return; } - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.scale[1] = g_pi_globals.scale[1]; } else{ @@ -517,7 +509,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "rotate_adj" ) ) { g_pi_globals.rotate = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.rotate = g_pi_globals.rotate; } else{ @@ -525,7 +517,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } } - adj->value = 0; + gtk_adjustment_set_value(adj, 0); // will scale shift rotate the patch accordingly @@ -544,12 +536,12 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } // update the point-by-point view - OnSelchangeComboColRow( 0,0 ); + OnSelchangeComboColRow( ui::root ,0 ); } -static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){ if ( event->keyval == GDK_Return ) { - OnApply( 0, 0 ); + OnApply( ui::root, 0 ); return TRUE; } else if ( event->keyval == GDK_Escape ) { @@ -562,8 +554,8 @@ static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ // ============================================================================= // PatchInspector class -GtkWindow* PatchInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Patch Properties", m_parent ); +ui::Window PatchInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Patch Properties", m_parent )); m_position_tracker.connect( window ); @@ -573,116 +565,116 @@ GtkWindow* PatchInspector::BuildDialog(){ { - GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + GtkVBox* vbox = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); gtk_widget_show( GTK_WIDGET( vbox ) ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); { - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 5 ) ); + GtkHBox* hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( GTK_WIDGET( hbox ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 ); { - GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 0 ) ); + GtkVBox* vbox2 = ui::VBox( FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 0 ); gtk_widget_show( GTK_WIDGET( vbox2 ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, TRUE, 0 ); { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Details" ) ); + GtkFrame* frame = ui::Frame( "Details" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + GtkVBox* vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); gtk_widget_show( GTK_WIDGET( vbox3 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); { - GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) ); + GtkTable* table = ui::Table( 2, 2, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Row:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Row:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Column:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Column:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + auto combo = ui::ComboBoxText(); g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *combo, m_nRow ); + AddDialogData( *GTK_COMBO_BOX(combo), m_nRow ); gtk_widget_show( GTK_WIDGET( combo ) ); gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); m_pRowCombo = combo; } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + auto combo = ui::ComboBoxText(); g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *combo, m_nCol ); + AddDialogData( *GTK_COMBO_BOX(combo), m_nCol ); gtk_widget_show( GTK_WIDGET( combo ) ); gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); m_pColCombo = combo; } } - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) ); + GtkTable* table = ui::Table( 5, 2, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "X:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "X:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Y:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Y:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Z:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Z:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "S:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "S:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "T:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "T:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -692,7 +684,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -702,7 +694,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -712,7 +704,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -722,7 +714,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -734,22 +726,22 @@ GtkWindow* PatchInspector::BuildDialog(){ } } if ( g_pGameDescription->mGameType == "doom3" ) { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Tesselation" ) ); + GtkFrame* frame = ui::Frame( "Tesselation" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + GtkVBox* vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); gtk_widget_show( GTK_WIDGET( vbox3 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); { - GtkTable* table = GTK_TABLE( gtk_table_new( 3, 2, FALSE ) ); + GtkTable* table = ui::Table( 3, 2, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Fixed" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Fixed" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -766,14 +758,14 @@ GtkWindow* PatchInspector::BuildDialog(){ g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* 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 ), @@ -782,14 +774,14 @@ GtkWindow* PatchInspector::BuildDialog(){ m_horizontalSubdivisionsEntry.connect( entry ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -802,24 +794,24 @@ GtkWindow* PatchInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Texturing" ) ); + GtkFrame* frame = ui::Frame( "Texturing" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + GtkVBox* vbox2 = ui::VBox( FALSE, 5 ); gtk_widget_show( GTK_WIDGET( vbox2 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Name:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Name:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - // gtk_entry_set_editable (GTK_ENTRY (entry), false); + GtkEntry* entry = ui::Entry(); + // gtk_editable_set_editable (GTK_ENTRY (entry), false); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); AddDialogData( *entry, m_strName ); @@ -827,13 +819,13 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 4, FALSE ) ); + GtkTable* table = ui::Table( 5, 4, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -841,7 +833,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -849,7 +841,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Stretch Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Stretch Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -857,16 +849,16 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); + GtkButton* button = ui::Button( "Flip" ); gtk_widget_show( GTK_WIDGET( button ) ); 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 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Stretch Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -874,16 +866,16 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); + GtkButton* button = ui::Button( "Flip" ); gtk_widget_show( GTK_WIDGET( button ) ); 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 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Rotate Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -891,151 +883,151 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); g_object_set_data( G_OBJECT( window ), "hshift_entry", 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] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hshift_adj", adj ); + auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); + g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry ); + g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.shift[1] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vshift_adj", adj ); + g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.scale[0] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hscale_adj", adj ); + g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.scale[1] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vscale_adj", adj ); + g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.rotate ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 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 + 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 ); - g_object_set_data( G_OBJECT( window ), "rotate_adj", adj ); + g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } } - GtkHBox* hbox2 = GTK_HBOX( gtk_hbox_new( TRUE, 5 ) ); + GtkHBox* hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_show( GTK_WIDGET( hbox2 ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox2 ), TRUE, FALSE, 0 ); { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Auto Cap" ) ); + GtkButton* button = ui::Button( "Auto Cap" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "CAP" ) ); + GtkButton* button = ui::Button( "CAP" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Set..." ) ); + GtkButton* button = ui::Button( "Set..." ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Natural" ) ); + GtkButton* button = ui::Button( "Natural" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Fit" ) ); + GtkButton* button = ui::Button( "Fit" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } } } @@ -1082,7 +1074,7 @@ void PatchInspector::GetPatchInfo(){ for ( std::size_t i = 0; i < m_countRows; ++i ) { - gtk_combo_box_remove_text( m_pRowCombo, gint( m_countRows - i - 1 ) ); + gtk_combo_box_text_remove( m_pRowCombo, gint( m_countRows - i - 1 ) ); } m_countRows = m_Patch->getHeight(); @@ -1090,7 +1082,7 @@ void PatchInspector::GetPatchInfo(){ { char buffer[16]; sprintf( buffer, "%u", Unsigned( i ) ); - gtk_combo_box_append_text( m_pRowCombo, buffer ); + gtk_combo_box_text_append_text( m_pRowCombo, buffer ); } gtk_combo_box_set_active( m_pRowCombo, 0 ); @@ -1101,7 +1093,7 @@ void PatchInspector::GetPatchInfo(){ for ( std::size_t i = 0; i < m_countCols; ++i ) { - gtk_combo_box_remove_text( m_pColCombo, gint( m_countCols - i - 1 ) ); + gtk_combo_box_text_remove( m_pColCombo, gint( m_countCols - i - 1 ) ); } m_countCols = m_Patch->getWidth(); @@ -1109,7 +1101,7 @@ void PatchInspector::GetPatchInfo(){ { char buffer[16]; sprintf( buffer, "%u", Unsigned( i ) ); - gtk_combo_box_append_text( m_pColCombo, buffer ); + gtk_combo_box_text_append_text( m_pColCombo, buffer ); } gtk_combo_box_set_active( m_pColCombo, 0 ); diff --git a/radiant/patchdialog.h b/radiant/patchdialog.h index 1304ccbe..ca1f6c9e 100644 --- a/radiant/patchdialog.h +++ b/radiant/patchdialog.h @@ -19,15 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PATCHDIALOG_H ) #define INCLUDED_PATCHDIALOG_H void PatchInspector_Construct(); void PatchInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void PatchInspector_constructWindow( GtkWindow* main_window ); +void PatchInspector_constructWindow( ui::Window main_window ); void PatchInspector_destroyWindow(); namespace scene diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 909e3466..ac4dbd3a 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "patchmanip.h" #include "debugging/debugging.h" @@ -723,13 +724,13 @@ void Patch_registerCommands(){ GlobalCommands_insert( "PatchCone", FreeCaller() ); GlobalCommands_insert( "PatchSphere", FreeCaller() ); GlobalCommands_insert( "SimplePatchMesh", FreeCaller(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchInsertAddRow", FreeCaller() ); GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller() ); GlobalCommands_insert( "InvertCurve", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "RedisperseRows", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); @@ -837,12 +838,7 @@ void Patch_constructMenu( GtkMenu* menu ){ } -#include -#include -#include -#include -#include -#include +#include #include "gtkutil/dialog.h" #include "gtkutil/widget.h" @@ -851,9 +847,9 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkComboBox* width; GtkComboBox* height; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -863,7 +859,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Width:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -871,7 +867,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Height:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -880,8 +876,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); -#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_append_text( combo, # x ) + auto combo = ui::ComboBoxText(); +#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, # x ) D_ITEM( 3 ); D_ITEM( 5 ); D_ITEM( 7 ); @@ -906,8 +902,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, width = combo; } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); -#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_append_text( combo, # x ) + auto combo = ui::ComboBoxText(); +#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, # x ) D_ITEM( 3 ); D_ITEM( 5 ); D_ITEM( 7 ); @@ -972,15 +968,15 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWidget* bevel; - GtkWidget* ibevel; - GtkWidget* endcap; - GtkWidget* iendcap; - GtkWidget* cylinder; + ui::Widget bevel; + ui::Widget ibevel; + ui::Widget endcap; + ui::Widget iendcap; + ui::Widget cylinder; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -993,7 +989,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) ); { - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) ); + GtkTable* table = ui::Table( 5, 2, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( radio_vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); @@ -1037,52 +1033,52 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GSList* group = 0; { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); bevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); endcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); ibevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); iendcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); cylinder = button; } diff --git a/radiant/pluginmanager.cpp b/radiant/pluginmanager.cpp index 30cc0c23..91e9f9ae 100644 --- a/radiant/pluginmanager.cpp +++ b/radiant/pluginmanager.cpp @@ -53,7 +53,7 @@ public: /*! build directly from a SYN_PROVIDE interface */ -CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ); +CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ); /*! dispatching a command by name to the plugin */ @@ -69,7 +69,7 @@ bool ownsCommandID( std::size_t n ); }; -CPluginSlot::CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +CPluginSlot::CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mpTable = &table; m_menu_name = name; @@ -149,7 +149,7 @@ std::list mSlots; public: virtual ~CPluginSlots(); -void AddPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +void AddPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mSlots.push_back( new CPluginSlot( main_window, name, table ) ); } @@ -190,13 +190,13 @@ bool CPluginSlots::Dispatch( std::size_t n, const char* p ){ CPluginSlots g_plugin_slots; -void FillPluginSlots( CPluginSlots& slots, GtkWidget* main_window ){ +void FillPluginSlots( CPluginSlots& slots, ui::Widget main_window ){ class AddPluginVisitor : public PluginModules::Visitor { CPluginSlots& m_slots; - GtkWidget* m_main_window; + ui::Widget m_main_window; public: - AddPluginVisitor( CPluginSlots& slots, GtkWidget* main_window ) + AddPluginVisitor( CPluginSlots& slots, ui::Widget main_window ) : m_slots( slots ), m_main_window( main_window ){ } void visit( const char* name, const _QERPluginTable& table ) const { @@ -220,7 +220,7 @@ void CPlugInManager::Dispatch( std::size_t n, const char * p ){ g_plugin_slots.Dispatch( n, p ); } -void CPlugInManager::Init( GtkWidget* main_window ){ +void CPlugInManager::Init( ui::Widget main_window ){ FillPluginSlots( g_plugin_slots, main_window ); } diff --git a/radiant/pluginmanager.h b/radiant/pluginmanager.h index d7943fb3..6603f6e1 100644 --- a/radiant/pluginmanager.h +++ b/radiant/pluginmanager.h @@ -23,8 +23,8 @@ #define INCLUDED_PLUGINMANAGER_H #include +#include -typedef struct _GtkWidget GtkWidget; /*! \class IPlugin @@ -55,7 +55,7 @@ class CPlugInManager { public: void Dispatch( std::size_t n, const char *p ); -void Init( GtkWidget* main_window ); +void Init( ui::Widget main_window ); void constructMenu( PluginsVisitor& menu ); void Shutdown(); }; diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 4708a78c..fb97825a 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -23,8 +23,7 @@ #include "stream/textstream.h" -#include -#include +#include #include "gtkutil/pointer.h" #include "gtkutil/menu.h" @@ -36,26 +35,26 @@ int m_nNextPlugInID = 0; -void plugin_activated( GtkWidget* widget, gpointer data ){ +void plugin_activated( ui::Widget widget, gpointer data ){ const char* str = (const char*)g_object_get_data( G_OBJECT( widget ),"command" ); GetPlugInMgr().Dispatch( gpointer_to_int( data ), str ); } #include -typedef std::stack WidgetStack; +typedef std::stack WidgetStack; void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ - GtkWidget *menu, *item, *parent, *subMenu; + ui::Widget menu, item, parent, subMenu; const char *menuText, *menuCommand; WidgetStack menuStack; - parent = gtk_menu_item_new_with_label( pPlugIn->getMenuName() ); + parent = ui::MenuItem( pPlugIn->getMenuName() ); gtk_widget_show( parent ); gtk_container_add( GTK_CONTAINER( plugin_menu ), parent ); std::size_t nCount = pPlugIn->getCommandCount(); if ( nCount > 0 ) { - menu = gtk_menu_new(); + menu = ui::Menu(); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( GTK_MENU( menu ) ); } @@ -66,7 +65,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ if ( menuText != 0 && strlen( menuText ) > 0 ) { if ( !strcmp( menuText, "-" ) ) { - item = gtk_menu_item_new(); + item = ui::Widget(gtk_menu_item_new()); gtk_widget_set_sensitive( item, FALSE ); } else if ( !strcmp( menuText, ">" ) ) { @@ -77,11 +76,11 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ continue; } - item = gtk_menu_item_new_with_label( menuText ); + item = ui::MenuItem( menuText ); gtk_widget_show( item ); gtk_container_add( GTK_CONTAINER( menu ), item ); - subMenu = gtk_menu_new(); + subMenu = ui::Menu(); gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu ); menuStack.push( menu ); menu = subMenu; @@ -100,7 +99,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } else { - item = gtk_menu_item_new_with_label( menuText ); + item = ui::MenuItem( menuText ); g_object_set_data( G_OBJECT( item ),"command", const_cast( static_cast( menuCommand ) ) ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); } @@ -147,11 +146,11 @@ public: void PluginsMenu_clear(){ m_nNextPlugInID = 0; - GList* lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); + GList* lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); while ( lst->next ) { gtk_container_remove( GTK_CONTAINER( g_plugins_menu ), GTK_WIDGET( lst->next->data ) ); - lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); + lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); } } diff --git a/radiant/plugintoolbar.cpp b/radiant/plugintoolbar.cpp index 03ef2074..4f554744 100644 --- a/radiant/plugintoolbar.cpp +++ b/radiant/plugintoolbar.cpp @@ -25,7 +25,7 @@ #include "itoolbar.h" #include "modulesystem.h" -#include +#include #include "stream/stringstream.h" #include "gtkutil/image.h" @@ -38,59 +38,58 @@ GtkImage* new_plugin_image( const char* filename ){ { StringOutputStream fullpath( 256 ); fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } { StringOutputStream fullpath( 256 ); fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } { StringOutputStream fullpath( 256 ); fullpath << AppPath_get() << g_modulesDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } return image_new_missing(); } -inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype( IToolbarButton::EType type ){ - switch ( type ) - { - case IToolbarButton::eSpace: - return GTK_TOOLBAR_CHILD_SPACE; - case IToolbarButton::eButton: - return GTK_TOOLBAR_CHILD_BUTTON; - case IToolbarButton::eToggleButton: - return GTK_TOOLBAR_CHILD_TOGGLEBUTTON; - case IToolbarButton::eRadioButton: - return GTK_TOOLBAR_CHILD_RADIOBUTTON; +void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){ + if (type == IToolbarButton::eSpace) { + auto it = gtk_separator_tool_item_new(); + gtk_widget_show(GTK_WIDGET(it)); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(it)); + return; + } + if (type == IToolbarButton::eButton) { + auto button = gtk_tool_button_new(GTK_WIDGET(new_plugin_image(icon)), text); + gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip); + gtk_widget_show_all(GTK_WIDGET(button)); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(handler), data); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); + return; + } + if (type == IToolbarButton::eToggleButton) { + auto button = gtk_toggle_tool_button_new(); + gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_plugin_image(icon))); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), text); + gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip); + gtk_widget_show_all(GTK_WIDGET(button)); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(handler), data); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); + return; } ERROR_MESSAGE( "invalid toolbar button type" ); - return (GtkToolbarChildType)0; -} - -void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data ){ - gtk_toolbar_append_element( toolbar, gtktoolbarchildtype_for_toolbarbuttontype( type ), 0, text, tooltip, "", GTK_WIDGET( new_plugin_image( icon ) ), handler, data ); } -void ActivateToolbarButton( GtkWidget *widget, gpointer data ){ - const_cast( reinterpret_cast( data ) )->activate(); +void ActivateToolbarButton( GtkToolButton *widget, gpointer data ){ + (const_cast( reinterpret_cast( data )))->activate(); } void PlugInToolbar_AddButton( GtkToolbar* toolbar, const IToolbarButton* button ){ - toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), GTK_SIGNAL_FUNC( ActivateToolbarButton ), reinterpret_cast( const_cast( button ) ) ); + toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), G_CALLBACK( ActivateToolbarButton ), reinterpret_cast( const_cast( button ) ) ); } GtkToolbar* g_plugin_toolbar = 0; @@ -124,7 +123,7 @@ GtkToolbar* create_plugin_toolbar(){ GtkToolbar *toolbar; toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL ); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); gtk_widget_show( GTK_WIDGET( toolbar ) ); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 46d15c7a..14b6d75f 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -30,20 +30,7 @@ #include "debugging/debugging.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "generic/callback.h" #include "math/vector.h" @@ -74,8 +61,8 @@ void Interface_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Default Text Editor", g_TextEditor_useWin32Editor ); #else { - GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); - GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); + ui::CheckButton use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); + ui::Widget custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); Widget_connectToggleDependency( custom_editor, use_custom ); } #endif @@ -104,6 +91,7 @@ void Mouse_registerPreferencesPage(){ */ #include +#include inline const char* xmlAttr_getName( xmlAttrPtr attr ){ return reinterpret_cast( attr->name ); @@ -330,19 +318,19 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){ page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt ); } -GtkWindow* CGameDialog::BuildDialog(){ +ui::Window CGameDialog::BuildDialog(){ GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Global_constructPreferences( preferencesPage ); CreateGlobalFrame( preferencesPage ); } - return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) ); + return ui::Window(create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) )); } class LoadGameFile @@ -471,7 +459,7 @@ CGameDialog::~CGameDialog(){ delete ( *iGame ); *iGame = 0; } - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } @@ -491,11 +479,11 @@ CGameDialog g_GamesDialog; // ============================================================================= // Widget callbacks for PrefsDlg -static void OnButtonClean( GtkWidget *widget, gpointer data ){ +static void OnButtonClean( ui::Widget widget, gpointer data ){ // make sure this is what the user wants - if ( gtk_MessageBox( GTK_WIDGET( g_Preferences.GetWidget() ), "This will close Radiant and clean the corresponding registry entries.\n" + if ( ui::Widget(GTK_WIDGET( g_Preferences.GetWidget() )).alert( "This will close Radiant and clean the corresponding registry entries.\n" "Next time you start Radiant it will be good as new. Do you wish to continue?", - "Reset Registry", eMB_YESNO, eMB_ICONASTERISK ) == eIDYES ) { + "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) { PrefsDlg *dlg = (PrefsDlg*)data; dlg->EndModal( eIDCANCEL ); @@ -541,14 +529,14 @@ void PrefsDlg::Init(){ g_string_append( m_inipath, PREFS_LOCAL_FILENAME ); } -void notebook_set_page( GtkWidget* notebook, GtkWidget* page ){ +void notebook_set_page( ui::Widget notebook, ui::Widget page ){ int pagenum = gtk_notebook_page_num( GTK_NOTEBOOK( notebook ), page ); if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) ) != pagenum ) { gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), pagenum ); } } -void PrefsDlg::showPrefPage( GtkWidget* prefpage ){ +void PrefsDlg::showPrefPage( ui::Widget prefpage ){ notebook_set_page( m_notebook, prefpage ); return; } @@ -559,7 +547,7 @@ static void treeSelection( GtkTreeSelection* selection, gpointer data ){ GtkTreeModel* model; GtkTreeIter selected; if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) { - GtkWidget* prefpage; + ui::Widget prefpage; gtk_tree_model_get( model, &selected, 1, (gpointer*)&prefpage, -1 ); dlg->showPrefPage( prefpage ); } @@ -619,47 +607,47 @@ void PreferencesDialog_addSettingsPage( const PreferenceGroupCallback& callback PreferenceGroupCallbacks_pushBack( g_settingsCallbacks, callback ); } -void Widget_updateDependency( GtkWidget* self, GtkWidget* toggleButton ){ - gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && GTK_WIDGET_IS_SENSITIVE( toggleButton ) ); +void Widget_updateDependency( ui::Widget self, ui::Widget toggleButton ){ + gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && gtk_widget_is_sensitive( toggleButton ) ); } -void ToggleButton_toggled_Widget_updateDependency( GtkWidget *toggleButton, GtkWidget* self ){ +void ToggleButton_toggled_Widget_updateDependency( ui::Widget toggleButton, ui::Widget self ){ Widget_updateDependency( self, toggleButton ); } -void ToggleButton_state_changed_Widget_updateDependency( GtkWidget* toggleButton, GtkStateType state, GtkWidget* self ){ +void ToggleButton_state_changed_Widget_updateDependency( ui::Widget toggleButton, GtkStateType state, ui::Widget self ){ if ( state == GTK_STATE_INSENSITIVE ) { Widget_updateDependency( self, toggleButton ); } } -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ){ +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){ g_signal_connect( G_OBJECT( toggleButton ), "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self ); g_signal_connect( G_OBJECT( toggleButton ), "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self ); Widget_updateDependency( self, toggleButton ); } -inline GtkWidget* getVBox( GtkWidget* page ){ - return gtk_bin_get_child( GTK_BIN( page ) ); +inline ui::Widget getVBox( ui::Widget page ){ + return ui::Widget(gtk_bin_get_child( GTK_BIN( page ) )); } -GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, GtkWidget* page ){ +GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){ GtkTreeIter group; gtk_tree_store_append( store, &group, parent ); gtk_tree_store_set( store, &group, 0, name, 1, page, -1 ); return group; } -GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ - GtkWidget* preflabel = gtk_label_new( name ); +ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){ + ui::Widget preflabel = ui::Label( name ); gtk_widget_show( preflabel ); - GtkWidget* pageframe = gtk_frame_new( name ); + ui::Widget pageframe = ui::Frame( name ); gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 ); gtk_widget_show( pageframe ); - GtkWidget* vbox = gtk_vbox_new( FALSE, 4 ); + ui::Widget vbox = ui::VBox( FALSE, 4 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 ); gtk_container_add( GTK_CONTAINER( pageframe ), vbox ); @@ -673,37 +661,37 @@ GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ class PreferenceTreeGroup : public PreferenceGroup { Dialog& m_dialog; -GtkWidget* m_notebook; +ui::Widget m_notebook; GtkTreeStore* m_store; GtkTreeIter m_group; public: -PreferenceTreeGroup( Dialog& dialog, GtkWidget* notebook, GtkTreeStore* store, GtkTreeIter group ) : +PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, GtkTreeStore* store, GtkTreeIter group ) : m_dialog( dialog ), m_notebook( notebook ), m_store( store ), m_group( group ){ } PreferencesPage createPage( const char* treeName, const char* frameName ){ - GtkWidget* page = PreferencePages_addPage( m_notebook, frameName ); + ui::Widget page = PreferencePages_addPage( m_notebook, frameName ); PreferenceTree_appendPage( m_store, &m_group, treeName, page ); return PreferencesPage( m_dialog, getVBox( page ) ); } }; -GtkWindow* PrefsDlg::BuildDialog(){ +ui::Window PrefsDlg::BuildDialog(){ PreferencesDialog_addInterfacePreferences( FreeCaller1() ); Mouse_registerPreferencesPage(); - GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent ); + ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent )); { - GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 ); + ui::Widget mainvbox = ui::VBox( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( dialog ), mainvbox ); gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 ); gtk_widget_show( mainvbox ); { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_end( GTK_BOX( mainvbox ), hbox, FALSE, TRUE, 0 ); @@ -722,19 +710,19 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( mainvbox ), hbox, TRUE, TRUE, 0 ); gtk_widget_show( hbox ); { - GtkWidget* sc_win = gtk_scrolled_window_new( 0, 0 ); + ui::Widget sc_win = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 ); gtk_widget_show( sc_win ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN ); // prefs pages notebook - m_notebook = gtk_notebook_new(); + m_notebook = ui::Widget(gtk_notebook_new()); // hide the notebook tabs since its not supposed to look like a notebook gtk_notebook_set_show_tabs( GTK_NOTEBOOK( m_notebook ), FALSE ); gtk_box_pack_start( GTK_BOX( hbox ), m_notebook, TRUE, TRUE, 0 ); @@ -744,12 +732,12 @@ GtkWindow* PrefsDlg::BuildDialog(){ { GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Preferences", renderer, "text", 0, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Preferences", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } @@ -771,14 +759,14 @@ GtkWindow* PrefsDlg::BuildDialog(){ PreferencePages_addPage( m_notebook, "Front Page" ); { - GtkWidget* global = PreferencePages_addPage( m_notebook, "Global Preferences" ); + ui::Widget global = PreferencePages_addPage( m_notebook, "Global Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( global ) ); Global_constructPreferences( preferencesPage ); } GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global ); { - GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" ); + ui::Widget game = PreferencePages_addPage( m_notebook, "Game" ); PreferencesPage preferencesPage( *this, getVBox( game ) ); g_GamesDialog.CreateGlobalFrame( preferencesPage ); @@ -787,7 +775,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); + ui::Widget interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( interfacePage ) ); PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage ); @@ -800,7 +788,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* display = PreferencePages_addPage( m_notebook, "Display Preferences" ); + ui::Widget display = PreferencePages_addPage( m_notebook, "Display Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( display ) ); PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage ); @@ -812,7 +800,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* settings = PreferencePages_addPage( m_notebook, "General Settings" ); + ui::Widget settings = PreferencePages_addPage( m_notebook, "General Settings" ); { PreferencesPage preferencesPage( *this, getVBox( settings ) ); PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage ); @@ -833,7 +821,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } } - gtk_notebook_set_page( GTK_NOTEBOOK( m_notebook ), 0 ); + gtk_notebook_set_current_page( GTK_NOTEBOOK( m_notebook ), 0 ); return dialog; } @@ -843,7 +831,7 @@ preferences_globals_t g_preferences_globals; PrefsDlg g_Preferences; // global prefs instance -void PreferencesDialog_constructWindow( GtkWindow* main_window ){ +void PreferencesDialog_constructWindow( ui::Window main_window ){ g_Preferences.m_parent = main_window; g_Preferences.Create(); } @@ -931,7 +919,7 @@ void PreferencesDialog_showDialog(){ { message << ( *i ) << '\n'; } - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), message.c_str() ); + MainFrame_getWindow().alert( message.c_str() ); g_restart_required.clear(); } } diff --git a/radiant/preferences.h b/radiant/preferences.h index 293541a5..8ece483f 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -34,19 +34,19 @@ #include #include -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ); +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ); class PreferencesPage { Dialog& m_dialog; -GtkWidget* m_vbox; +ui::Widget m_vbox; public: -PreferencesPage( Dialog& dialog, GtkWidget* vbox ) : m_dialog( dialog ), m_vbox( vbox ){ +PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){ } -GtkWidget* appendCheckBox( const char* name, const char* flag, bool& data ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){ return m_dialog.addCheckBox( m_vbox, name, flag, data ); } -GtkWidget* appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback ); } void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ @@ -70,37 +70,37 @@ void appendRadioIcons( const char* name, StringArrayRange icons, const IntImport void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){ m_dialog.addRadioIcons( m_vbox, name, data, icons ); } -GtkWidget* appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, int& data ){ +ui::Widget appendEntry( const char* name, int& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, std::size_t& data ){ +ui::Widget appendEntry( const char* name, std::size_t& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, float& data ){ +ui::Widget appendEntry( const char* name, float& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ +ui::Widget appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback ); } -GtkWidget* appendPathEntry( const char* name, CopiedString& data, bool directory ){ +ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){ return m_dialog.addPathEntry( m_vbox, name, data, directory ); } -GtkWidget* appendSpinner( const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){ return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } }; @@ -197,7 +197,6 @@ void Dump(); extern CGameDescription *g_pGameDescription; -typedef struct _GtkWidget GtkWidget; class PrefsDlg; class PreferencesPage; @@ -270,7 +269,7 @@ void DoGameDialog(); Dialog API this is only called when the dialog is built at startup for main engine select */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void GameFileImport( int value ); void GameFileExport( const IntImportCallback& importCallback ) const; @@ -329,7 +328,7 @@ std::list mGames; public: -GtkWidget *m_notebook; +ui::Widget m_notebook; virtual ~PrefsDlg(){ g_string_free( m_rc_path, true ); @@ -362,12 +361,12 @@ GString *m_inipath; void Init(); /*! Utility function for swapping notebook pages for tree list selections */ -void showPrefPage( GtkWidget* prefpage ); +void showPrefPage( ui::Widget prefpage ); protected: /*! Dialog API */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void PostModal( EMessageBoxReturn code ); }; @@ -382,8 +381,7 @@ struct preferences_globals_t }; extern preferences_globals_t g_preferences_globals; -typedef struct _GtkWindow GtkWindow; -void PreferencesDialog_constructWindow( GtkWindow* main_window ); +void PreferencesDialog_constructWindow( ui::Window main_window ); void PreferencesDialog_destroyWindow(); void PreferencesDialog_showDialog(); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 1bce60b9..4de16016 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -41,7 +41,8 @@ #include -#include +#include +#include #include "stream/textfilestream.h" #include "cmdlib.h" @@ -140,11 +141,11 @@ bool ConfirmModified( const char* title ){ return true; } - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, eMB_YESNOCANCEL, eMB_ICONQUESTION ); - if ( result == eIDCANCEL ) { + auto result = MainFrame_getWindow().alert( "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::Question ); + if ( result == ui::alert_response::CANCEL ) { return false; } - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { if ( Map_Unnamed( g_map ) ) { return Map_SaveAs(); } @@ -324,7 +325,7 @@ void Sys_SetTitle( const char *text, bool modified ){ title << " *"; } - gtk_window_set_title( MainFrame_getWindow(), title.c_str() ); + gtk_window_set_title(MainFrame_getWindow(), title.c_str() ); } bool g_bWaitCursor = false; @@ -332,14 +333,14 @@ bool g_bWaitCursor = false; void Sys_BeginWait( void ){ ScreenUpdates_Disable( "Processing...", "Please Wait" ); GdkCursor *cursor = gdk_cursor_new( GDK_WATCH ); - gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(MainFrame_getWindow()), cursor ); gdk_cursor_unref( cursor ); g_bWaitCursor = true; } void Sys_EndWait( void ){ ScreenUpdates_Enable(); - gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, 0 ); + gdk_window_set_cursor(gtk_widget_get_window(MainFrame_getWindow()), 0 ); g_bWaitCursor = false; } diff --git a/radiant/qgl.cpp b/radiant/qgl.cpp index 6cc9d7ca..a352b8d0 100644 --- a/radiant/qgl.cpp +++ b/radiant/qgl.cpp @@ -59,7 +59,6 @@ PROC ( WINAPI * qwglGetProcAddress )( LPCSTR ); #include #include -#include Bool ( *qglXQueryExtension )( Display *dpy, int *errorb, int *event ); void* ( *qglXGetProcAddressARB )( const GLubyte * procName ); @@ -555,7 +554,7 @@ int QGL_Init( OpenGLBinding& table ){ qwglGetProcAddress = wglGetProcAddress; #elif defined( XWINDOWS ) qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym( RTLD_DEFAULT, "glXGetProcAddressARB" ); - if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension( GDK_DISPLAY(),0,0 ) != True ) ) { + if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension(XOpenDisplay(nullptr), 0, 0) != True ) ) { return 0; } #elif defined (__APPLE__) diff --git a/radiant/select.cpp b/radiant/select.cpp index 5d34645a..0586d417 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -830,10 +830,7 @@ void Selection_destroy(){ #include "gtkdlgs.h" -#include -#include -#include -#include +#include #include @@ -870,10 +867,10 @@ struct RotateDialog GtkSpinButton* x; GtkSpinButton* y; GtkSpinButton* z; - GtkWindow *window; + ui::Window window; }; -static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){ Vector3 eulerXYZ; eulerXYZ[0] = static_cast( gtk_spin_button_get_value( rotateDialog->x ) ); @@ -888,7 +885,7 @@ static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ) return TRUE; } -static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){ gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close @@ -898,23 +895,23 @@ static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog return TRUE; } -static gboolean rotatedlg_ok( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){ rotatedlg_apply( widget, rotateDialog ); gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); return TRUE; } -static gboolean rotatedlg_delete( GtkWidget *widget, GdkEventAny *event, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_delete( ui::Widget widget, GdkEventAny *event, RotateDialog* rotateDialog ){ rotatedlg_cancel( widget, rotateDialog ); return TRUE; } RotateDialog g_rotate_dialog; void DoRotateDlg(){ - if ( g_rotate_dialog.window == NULL ) { - g_rotate_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK( rotatedlg_delete ), &g_rotate_dialog ); + if ( !g_rotate_dialog.window ) { + g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( g_rotate_dialog.window, accel ); { @@ -924,29 +921,29 @@ void DoRotateDlg(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); + ui::Widget label = ui::Label( " X " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); + ui::Widget label = ui::Label( " Y " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); + ui::Widget label = ui::Label( " Z " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + GtkSpinButton* spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -959,8 +956,8 @@ void DoRotateDlg(){ g_rotate_dialog.x = spin; } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + GtkSpinButton* spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -971,8 +968,8 @@ void DoRotateDlg(){ g_rotate_dialog.y = spin; } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + GtkSpinButton* spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1018,13 +1015,13 @@ void DoRotateDlg(){ struct ScaleDialog { - GtkWidget* x; - GtkWidget* y; - GtkWidget* z; - GtkWindow *window; + ui::Widget x; + ui::Widget y; + ui::Widget z; + ui::Window window; }; -static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ float sx, sy, sz; sx = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( scaleDialog->x ) ) ) ); @@ -1040,7 +1037,7 @@ static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" ); @@ -1050,13 +1047,13 @@ static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_ok( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){ scaledlg_apply( widget, scaleDialog ); gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); return TRUE; } -static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_delete( ui::Widget widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ scaledlg_cancel( widget, scaleDialog ); return TRUE; } @@ -1064,10 +1061,10 @@ static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDia ScaleDialog g_scale_dialog; void DoScaleDlg(){ - if ( g_scale_dialog.window == NULL ) { - g_scale_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary scale", G_CALLBACK( scaledlg_delete ), &g_scale_dialog ); + if ( !g_scale_dialog.window ) { + g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( g_scale_dialog.window, accel ); { @@ -1077,28 +1074,28 @@ void DoScaleDlg(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); + ui::Widget label = ui::Label( " X " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); + ui::Widget label = ui::Label( " Y " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); + ui::Widget label = ui::Label( " Z " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 0, 1, @@ -1108,7 +1105,7 @@ void DoScaleDlg(){ g_scale_dialog.x = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 1, 2, @@ -1118,7 +1115,7 @@ void DoScaleDlg(){ g_scale_dialog.y = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 2, 3, diff --git a/radiant/server.cpp b/radiant/server.cpp index c58ad879..12997d4d 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -144,9 +144,8 @@ FunctionPointer findSymbol( const char* symbol ){ #include -class DynamicLibrary -{ -void* m_library; +class DynamicLibrary { + void *m_library; public: typedef int ( *FunctionPointer )(); diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 73312a07..438498e0 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -35,15 +35,8 @@ #include "iundo.h" #include "iselection.h" -#include -#include -#include -#include -#include -#include -#include +#include #include -#include //Shamus: For Textool #include "signal/isignal.h" #include "generic/object.h" @@ -89,18 +82,18 @@ namespace TexTool { //Shamus: Textool function prototypes -gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer ); -gboolean expose( GtkWidget *, GdkEventExpose *, gpointer ); -gboolean button_press( GtkWidget *, GdkEventButton *, gpointer ); -gboolean button_release( GtkWidget *, GdkEventButton *, gpointer ); -gboolean motion( GtkWidget *, GdkEventMotion *, gpointer ); +gboolean size_allocate( ui::Widget, GtkAllocation *, gpointer ); +gboolean expose( ui::Widget, GdkEventExpose *, gpointer ); +gboolean button_press( ui::Widget, GdkEventButton *, gpointer ); +gboolean button_release( ui::Widget, GdkEventButton *, gpointer ); +gboolean motion( ui::Widget, GdkEventMotion *, gpointer ); void flipX( GtkToggleButton *, gpointer ); void flipY( GtkToggleButton *, gpointer ); //End Textool function prototypes //Shamus: Textool globals -GtkWidget * g_textoolWin; +ui::Widget g_textoolWin; //End Textool globals void queueDraw(){ @@ -113,7 +106,7 @@ void queueDraw(){ inline void spin_button_set_step( GtkSpinButton* spin, gfloat step ){ #if 1 - gtk_spin_button_get_adjustment( spin )->step_increment = step; + gtk_adjustment_set_step_increment(gtk_spin_button_get_adjustment( spin ), step); #else GValue gvalue = GValue_default(); g_value_init( &gvalue, G_TYPE_DOUBLE ); @@ -145,7 +138,7 @@ void SurfaceInspector_GridChange(); class SurfaceInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); NonModalEntry m_textureEntry; NonModalSpinner m_hshiftSpinner; @@ -208,7 +201,7 @@ SurfaceInspector() : m_positionTracker.setPosition( c_default_window_pos ); } -void constructWindow( GtkWindow* main_window ){ +void constructWindow( ui::Window main_window ){ m_parent = main_window; Create(); AddGridChangeCallback( FreeCaller() ); @@ -217,7 +210,7 @@ void destroyWindow(){ Destroy(); } bool visible() const { - return GTK_WIDGET_VISIBLE( const_cast( GetWidget() ) ); + return gtk_widget_get_visible( GetWidget() ); } void queueDraw(){ if ( visible() ) { @@ -245,7 +238,7 @@ inline SurfaceInspector& getSurfaceInspector(){ } } -void SurfaceInspector_constructWindow( GtkWindow* main_window ){ +void SurfaceInspector_constructWindow( ui::Window main_window ){ getSurfaceInspector().constructWindow( main_window ); } void SurfaceInspector_destroyWindow(){ @@ -400,10 +393,10 @@ void SurfaceInspector_GridChange(){ // we move the textures in pixels, not world units. (i.e. increment values are in pixel) // depending on the texture scale it doesn't take the same amount of pixels to move of GetGridSize() // increment * scale = gridsize -static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ +static void OnBtnMatchGrid( ui::Widget widget, gpointer data ){ float hscale, vscale; - hscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); - vscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); + hscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); + vscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); if ( hscale == 0.0f || vscale == 0.0f ) { globalOutputStream() << "ERROR: unexpected scale == 0.0f\n"; @@ -417,7 +410,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ // or update it because something new has been selected // Shamus: It does get called when the SI is hidden, but not when you select something new. ;-) void DoSurface( void ){ - if ( getSurfaceInspector().GetWidget() == 0 ) { + if ( !getSurfaceInspector().GetWidget() ) { getSurfaceInspector().Create(); } @@ -441,23 +434,23 @@ void SurfaceInspector_FitTexture(){ Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical ); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnAxial( GtkWidget *widget, gpointer data ){ +static void OnBtnAxial( ui::Widget widget, gpointer data ){ //globalOutputStream() << "--> [OnBtnAxial]...\n"; UndoableCommand undo( "textureDefault" ); TextureProjection projection; @@ -486,7 +479,7 @@ static void OnBtnAxial( GtkWidget *widget, gpointer data ){ Select_SetTexdef( projection ); } -static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){ +static void OnBtnFaceFit( ui::Widget widget, gpointer data ){ getSurfaceInspector().exportData(); SurfaceInspector_FitTexture(); } @@ -587,8 +580,8 @@ guint togglebutton_connect_toggled( GtkToggleButton* button, const Callback& cal return g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); } -GtkWindow* SurfaceInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Surface Inspector", m_parent ); +ui::Window SurfaceInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Surface Inspector", m_parent )); m_positionTracker.connect( window ); @@ -599,23 +592,23 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { // replaced by only the vbox: - GtkWidget* vbox = gtk_vbox_new( FALSE, 5 ); + ui::Widget vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( "Texture" ); + ui::Widget label = ui::Label( "Texture" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( hbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_texture = entry; @@ -626,13 +619,13 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { - GtkWidget* table = gtk_table_new( 6, 4, FALSE ); + ui::Widget table = ui::Table( 6, 4, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Horizontal shift" ); + ui::Widget label = ui::Label( "Horizontal shift" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, @@ -640,17 +633,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_hshiftIncrement.m_spin = spin; m_hshiftSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, @@ -658,17 +651,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_hshiftIncrement.m_entry = entry; m_hshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical shift" ); + ui::Widget label = ui::Label( "Vertical shift" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, @@ -676,17 +669,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_vshiftIncrement.m_spin = spin; m_vshiftSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, @@ -694,17 +687,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_vshiftIncrement.m_entry = entry; m_vshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Horizontal stretch" ); + ui::Widget label = ui::Label( "Horizontal stretch" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, @@ -712,17 +705,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_hscaleIncrement.m_spin = spin; m_hscaleSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, @@ -730,17 +723,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 2, 3 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 2, 3 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_hscaleIncrement.m_entry = entry; m_hscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical stretch" ); + ui::Widget label = ui::Label( "Vertical stretch" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, @@ -748,17 +741,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_vscaleIncrement.m_spin = spin; m_vscaleSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, @@ -766,17 +759,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_vscaleIncrement.m_entry = entry; m_vscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Rotate" ); + ui::Widget label = ui::Label( "Rotate" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, @@ -784,18 +777,18 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_rotateIncrement.m_spin = spin; m_rotateSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); gtk_spin_button_set_wrap( spin, TRUE ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, @@ -803,18 +796,18 @@ GtkWindow* SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_rotateIncrement.m_entry = entry; m_rotateEntry.connect( entry ); } { // match grid button - GtkWidget* button = gtk_button_new_with_label( "Match Grid" ); + ui::Widget button = ui::Button( "Match Grid" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -824,136 +817,136 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } { - GtkWidget* frame = gtk_frame_new( "Texturing" ); + ui::Widget frame = ui::Frame( "Texturing" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkWidget* table = gtk_table_new( 4, 4, FALSE ); + ui::Widget table = ui::Table( 4, 4, FALSE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Brush" ); + ui::Widget label = ui::Label( "Brush" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Patch" ); + ui::Widget label = ui::Label( "Patch" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Width" ); + ui::Widget label = ui::Label( "Width" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Height" ); + ui::Widget label = ui::Label( "Height" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* button = gtk_button_new_with_label( "Axial" ); + ui::Widget button = ui::Button( "Axial" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnAxial ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); + ui::Widget button = ui::Button( "Fit" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnFaceFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "CAP" ); + ui::Widget button = ui::Button( "CAP" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Set..." ); + ui::Widget button = ui::Button( "Set..." ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Natural" ); + ui::Widget button = ui::Button( "Natural" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); + ui::Widget button = ui::Button( "Fit" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); + ui::Widget spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); + ui::Widget spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitVertical ); } } } if ( !string_empty( g_pGameDescription->getKeyValue( "si_flags" ) ) ) { { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Surface Flags" ) ); + GtkFrame* frame = ui::Frame( "Surface Flags" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + GtkVBox* vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); gtk_widget_show( GTK_WIDGET( vbox3 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); + GtkTable* table = ui::Table( 8, 4, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); @@ -965,7 +958,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { for ( int r = 0; r != 8; ++r ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getSurfaceFlagName( c * 8 + r ) ) ); + GtkCheckButton* check = ui::CheckButton( getSurfaceFlagName( c * 8 + r ) ); gtk_widget_show( GTK_WIDGET( check ) ); gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -979,17 +972,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Content Flags" ) ); + GtkFrame* frame = ui::Frame( "Content Flags" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + GtkVBox* vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); gtk_widget_show( GTK_WIDGET( vbox3 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); + GtkTable* table = ui::Table( 8, 4, FALSE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); @@ -1001,7 +994,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { for ( int r = 0; r != 8; ++r ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getContentFlagName( c * 8 + r ) ) ); + GtkCheckButton* check = ui::CheckButton( getContentFlagName( c * 8 + r ) ); gtk_widget_show( GTK_WIDGET( check ) ); gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -1018,17 +1011,17 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Value" ) ); + GtkFrame* frame = ui::Frame( "Value" ); gtk_widget_show( GTK_WIDGET( frame ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + GtkVBox* vbox3 = ui::VBox( FALSE, 4 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 ); gtk_widget_show( GTK_WIDGET( vbox3 ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + GtkEntry* entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_valueEntryWidget = entry; @@ -1041,19 +1034,19 @@ GtkWindow* SurfaceInspector::BuildDialog(){ #if TEXTOOL_ENABLED if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) { // Shamus: Textool goodies... - GtkWidget * frame = gtk_frame_new( "Textool" ); + ui::Widget frame = ui::Frame( "Textool" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { //Prolly should make this a member or global var, so the SI can draw on it... TexTool::g_textoolWin = glwidget_new( FALSE ); // --> Dunno, but this stuff may be necessary... (Looks like it!) - gtk_widget_ref( TexTool::g_textoolWin ); + g_object_ref( TexTool::g_textoolWin ); gtk_widget_set_events( TexTool::g_textoolWin, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); - GTK_WIDGET_SET_FLAGS( TexTool::g_textoolWin, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( TexTool::g_textoolWin, true ); // <-- end stuff... gtk_widget_show( TexTool::g_textoolWin ); - gtk_widget_set_usize( TexTool::g_textoolWin, -1, 240 ); //Yeah! + gtk_widget_set_size_request( TexTool::g_textoolWin, -1, 240 ); //Yeah! gtk_container_add( GTK_CONTAINER( frame ), TexTool::g_textoolWin ); g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); @@ -1063,12 +1056,12 @@ GtkWindow* SurfaceInspector::BuildDialog(){ g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); } { - GtkWidget * hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 ); // Checkboxes go here... (Flip X/Y) - GtkWidget * flipX = gtk_check_button_new_with_label( "Flip X axis" ); - GtkWidget * flipY = gtk_check_button_new_with_label( "Flip Y axis" ); + ui::Widget flipX = ui::CheckButton( "Flip X axis" ); + ui::Widget flipY = ui::CheckButton( "Flip Y axis" ); gtk_widget_show( flipX ); gtk_widget_show( flipY ); gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 ); @@ -1111,7 +1104,7 @@ void spin_button_set_value_no_signal( GtkSpinButton* spin, gdouble value ){ void spin_button_set_step_increment( GtkSpinButton* spin, gdouble value ){ GtkAdjustment* adjust = gtk_spin_button_get_adjustment( spin ); - adjust->step_increment = value; + gtk_adjustment_set_step_increment(adjust, value); } void SurfaceInspector::Update(){ @@ -1214,11 +1207,11 @@ void SurfaceInspector::ApplyShader(){ void SurfaceInspector::ApplyTexdef(){ texdef_t shiftScaleRotate; - shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value_as_float( m_hshiftIncrement.m_spin ) ); - shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value_as_float( m_vshiftIncrement.m_spin ) ); - shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value_as_float( m_hscaleIncrement.m_spin ) ); - shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value_as_float( m_vscaleIncrement.m_spin ) ); - shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value_as_float( m_rotateIncrement.m_spin ) ); + shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value( m_hshiftIncrement.m_spin ) ); + shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value( m_vshiftIncrement.m_spin ) ); + shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value( m_hscaleIncrement.m_spin ) ); + shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value( m_vscaleIncrement.m_spin ) ); + shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value( m_rotateIncrement.m_spin ) ); TextureProjection projection; //Shamus: This is the other place that screws up, it seems, since it doesn't seem to do the @@ -1877,14 +1870,14 @@ void focus(){ // << extents.maxX << ", " << extents.minY << ", " << extents.maxY << "\n"; } -gboolean size_allocate( GtkWidget * win, GtkAllocation * a, gpointer ){ +gboolean size_allocate( ui::Widget win, GtkAllocation * a, gpointer ){ windowSize.x() = a->width; windowSize.y() = a->height; queueDraw(); return false; } -gboolean expose( GtkWidget * win, GdkEventExpose * e, gpointer ){ +gboolean expose( ui::Widget win, GdkEventExpose * e, gpointer ){ // globalOutputStream() << "--> Textool Window was exposed!\n"; // globalOutputStream() << " (window width/height: " << cc << "/" << e->area.height << ")\n"; @@ -1983,7 +1976,7 @@ Vector2 trans; Vector2 trans2; Vector2 dragPoint; // Defined in terms of window space (+x/-y) Vector2 oldTrans; -gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_press( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button press...\n"; if ( e->button == 1 ) { @@ -2045,7 +2038,7 @@ gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ return false; } -gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_release( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button release...\n"; if ( e->button == 1 ) { @@ -2107,7 +2100,7 @@ gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ c[1] = ((float)(y))/((float)(m_rect.bottom-m_rect.top))*(m_Maxs[1]-m_Mins[1])+m_Mins[1]; } */ -gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){ +gboolean motion( ui::Widget win, GdkEventMotion * e, gpointer ){ // globalOutputStream() << "--> Textool motion...\n"; if ( lButtonDown ) { diff --git a/radiant/surfacedialog.h b/radiant/surfacedialog.h index 0e0ed24a..2c1d945d 100644 --- a/radiant/surfacedialog.h +++ b/radiant/surfacedialog.h @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_SURFACEDIALOG_H ) #define INCLUDED_SURFACEDIALOG_H @@ -26,9 +28,7 @@ void SurfaceInspector_Construct(); void SurfaceInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void SurfaceInspector_constructWindow( GtkWindow* widget ); +void SurfaceInspector_constructWindow( ui::Window widget ); void SurfaceInspector_destroyWindow(); bool SelectedFaces_empty(); diff --git a/radiant/textureentry.h b/radiant/textureentry.h index 3406d2a0..45151373 100644 --- a/radiant/textureentry.h +++ b/radiant/textureentry.h @@ -23,8 +23,7 @@ #define INCLUDED_TEXTUREENTRY_H -#include -#include +#include #include "gtkutil/idledraw.h" #include "generic/static.h" diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 1ab87084..eddd84de 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -41,11 +41,7 @@ #include #include -#include -#include -#include -#include -#include +#include #include "signal/signal.h" #include "math/vector.h" @@ -210,7 +206,7 @@ void value_changed( gdouble value ){ } } static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){ - self->value_changed( adjustment->value ); + self->value_changed( gtk_adjustment_get_value(adjustment) ); } }; @@ -259,21 +255,21 @@ int m_nTotalHeight; CopiedString shader; -GtkWindow* m_parent; -GtkWidget* m_gl_widget; -GtkWidget* m_texture_scroll; -GtkWidget* m_treeViewTree; -GtkWidget* m_treeViewTags; -GtkWidget* m_tag_frame; +ui::Window m_parent; +ui::Widget m_gl_widget; +ui::Widget m_texture_scroll; +ui::Widget m_treeViewTree; +ui::Widget m_treeViewTags; +ui::Widget m_tag_frame; GtkListStore* m_assigned_store; GtkListStore* m_available_store; -GtkWidget* m_assigned_tree; -GtkWidget* m_available_tree; -GtkWidget* m_scr_win_tree; -GtkWidget* m_scr_win_tags; -GtkWidget* m_tag_notebook; -GtkWidget* m_search_button; -GtkWidget* m_shader_info_item; +ui::Widget m_assigned_tree; +ui::Widget m_available_tree; +ui::Widget m_scr_win_tree; +ui::Widget m_scr_win_tags; +ui::Widget m_tag_notebook; +ui::Widget m_search_button; +ui::Widget m_shader_info_item; std::set m_all_tags; GtkListStore* m_all_tags_list; @@ -741,7 +737,7 @@ void visit( const char* name ){ void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ); -GtkWidget* g_page_textures; +ui::Widget g_page_textures; void TextureBrowser_toggleShow(){ GroupDialog_showPage( g_page_textures ); @@ -1359,7 +1355,7 @@ void BuildStoreAvailableTags( GtkListStore* storeAvailable, } } -gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_PRESS ) { if ( event->button == 3 ) { if ( GlobalTextureBrowser().m_tags ) { @@ -1392,7 +1388,7 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_release( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_RELEASE ) { if ( event->button == 3 ) { if ( !GlobalTextureBrowser().m_tags ) { @@ -1403,11 +1399,11 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event return FALSE; } -gboolean TextureBrowser_motion( GtkWidget *widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_motion( ui::Widget widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ return FALSE; } -gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ if ( event->direction == GDK_SCROLL_UP ) { TextureBrowser_MouseWheel( *textureBrowser, true ); } @@ -1423,7 +1419,7 @@ void TextureBrowser_scrollChanged( void* data, gdouble value ){ } static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){ - textureBrowser->m_scrollAdjustment.value_changed( adjustment->value ); + textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) ); } void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){ @@ -1434,18 +1430,18 @@ void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){ GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( textureBrowser.m_texture_scroll ) ); - vadjustment->value = -TextureBrowser_getOriginY( textureBrowser ); - vadjustment->page_size = textureBrowser.height; - vadjustment->page_increment = textureBrowser.height / 2; - vadjustment->step_increment = 20; - vadjustment->lower = 0; - vadjustment->upper = totalHeight; + gtk_adjustment_set_value(vadjustment, -TextureBrowser_getOriginY( textureBrowser )); + gtk_adjustment_set_page_size(vadjustment, textureBrowser.height); + gtk_adjustment_set_page_increment(vadjustment, textureBrowser.height / 2); + gtk_adjustment_set_step_increment(vadjustment, 20); + gtk_adjustment_set_lower(vadjustment, 0); + gtk_adjustment_set_upper(vadjustment, totalHeight); g_signal_emit_by_name( G_OBJECT( vadjustment ), "changed" ); } } -gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ textureBrowser->width = allocation->width; textureBrowser->height = allocation->height; TextureBrowser_heightChanged( *textureBrowser ); @@ -1454,7 +1450,7 @@ gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocat return FALSE; } -gboolean TextureBrowser_expose( GtkWidget* widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) { GlobalOpenGL_debugAssertNoErrors(); TextureBrowser_evaluateHeight( *textureBrowser ); @@ -1590,14 +1586,13 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV } void TextureBrowser_createTreeViewTree(){ - GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTree = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTree = ui::TreeView(); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL ); - renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL ); TextureBrowser_constructTreeStore(); @@ -1607,18 +1602,18 @@ void TextureBrowser_addTag(); void TextureBrowser_renameTag(); void TextureBrowser_deleteTag(); -void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *event ){ - GtkWidget* menu = gtk_menu_new(); +void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){ + ui::Widget menu = ui::Menu(); - GtkWidget* menuitem = gtk_menu_item_new_with_label( "Add tag" ); + ui::Widget menuitem = ui::MenuItem( "Add tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Rename tag" ); + menuitem = ui::MenuItem( "Rename tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Delete tag" ); + menuitem = ui::MenuItem( "Delete tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); @@ -1629,7 +1624,7 @@ void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *even gdk_event_get_time( (GdkEvent*)event ) ); } -gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *event ){ +gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *event ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { GtkTreePath *path; GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ) ); @@ -1647,22 +1642,21 @@ gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *even } void TextureBrowser_createTreeViewTags(){ - GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTags = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTags = ui::TreeView(); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE ); g_signal_connect( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE ); - renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), -1, "", renderer, "text", 0, NULL ); TextureBrowser_constructTreeStoreTags(); } -GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_View" ); +ui::MenuItem TextureBrowser_constructViewMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1702,7 +1696,7 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) { menu_separator( menu ); - g_TextureBrowser.m_shader_info_item = GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) ); + g_TextureBrowser.m_shader_info_item = ui::Widget(GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) )); gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE ); } @@ -1710,8 +1704,8 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" ); +ui::MenuItem TextureBrowser_constructToolsMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1723,8 +1717,8 @@ GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "T_ags" ); +ui::MenuItem TextureBrowser_constructTagsMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1926,14 +1920,14 @@ void TextureBrowser_toggleSearchButton(){ gtk_widget_show_all( g_TextureBrowser.m_search_button ); } else { - gtk_widget_hide_all( g_TextureBrowser.m_search_button ); + gtk_widget_hide( g_TextureBrowser.m_search_button ); } } void TextureBrowser_constructTagNotebook(){ - g_TextureBrowser.m_tag_notebook = gtk_notebook_new(); - GtkWidget* labelTags = gtk_label_new( "Tags" ); - GtkWidget* labelTextures = gtk_label_new( "Textures" ); + g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new()); + ui::Widget labelTags = ui::Label( "Tags" ); + ui::Widget labelTextures = ui::Label( "Textures" ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tree, labelTextures ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tags, labelTags ); @@ -1944,12 +1938,10 @@ void TextureBrowser_constructTagNotebook(){ } void TextureBrowser_constructSearchButton(){ - GtkTooltips* tooltips = gtk_tooltips_new(); - - GtkWidget* image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ); - g_TextureBrowser.m_search_button = gtk_button_new(); + ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR )); + g_TextureBrowser.m_search_button = ui::Button(); g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), g_TextureBrowser.m_search_button, "Search with selected tags", "Search with selected tags" ); + gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags"); gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image ); } @@ -2001,7 +1993,7 @@ void TextureBrowser_SetNotex(){ g_shadernotex = name.c_str(); } -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ // The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider // position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't // seem to work in gtk 2.4 and the arrow buttons don't handle GTK_FILL, so here's another thing @@ -2014,31 +2006,31 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ g_TextureBrowser.m_parent = toplevel; - GtkWidget* table = gtk_table_new( 3, 3, FALSE ); - GtkWidget* frame_table = NULL; - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); + ui::Widget table = ui::Table( 3, 3, FALSE ); + ui::Widget frame_table; + ui::Widget vbox = ui::VBox( FALSE, 0 ); gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); gtk_widget_show( vbox ); - GtkWidget* menu_bar; + ui::Widget menu_bar; { // menu bar - menu_bar = gtk_menu_bar_new(); - GtkWidget* menu_view = gtk_menu_new(); - GtkWidget* view_item = (GtkWidget*)TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); + menu_bar = ui::Widget(gtk_menu_bar_new()); + ui::Widget menu_view = ui::Menu(); + auto view_item = TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item ); - GtkWidget* menu_tools = gtk_menu_new(); - GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); + ui::Widget menu_tools = ui::Menu(); + auto tools_item = TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item ); gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); gtk_widget_show( menu_bar ); } { // Texture TreeView - g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 ); // vertical only scrolling for treeview @@ -2052,7 +2044,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); } { // gl_widget scrollbar - GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) ); + ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) )); gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 ); gtk_widget_show( w ); g_TextureBrowser.m_texture_scroll = w; @@ -2063,11 +2055,11 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar ); } { // gl_widget - g_TextureBrowser.m_gl_widget = glwidget_new( FALSE ); - gtk_widget_ref( g_TextureBrowser.m_gl_widget ); + g_TextureBrowser.m_gl_widget = ui::Widget(glwidget_new( FALSE )); + g_object_ref( g_TextureBrowser.m_gl_widget ); gtk_widget_set_events( g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( g_TextureBrowser.m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( g_TextureBrowser.m_gl_widget, true ); gtk_table_attach_defaults( GTK_TABLE( table ), g_TextureBrowser.m_gl_widget, 1, 2, 1, 2 ); gtk_widget_show( g_TextureBrowser.m_gl_widget ); @@ -2092,13 +2084,13 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ TextureBrowser_buildTagList(); } { // tag menu bar - GtkWidget* menu_tags = gtk_menu_new(); - GtkWidget* tags_item = (GtkWidget*)TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); + ui::Widget menu_tags = ui::Menu(); + auto tags_item = TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item ); } { // Tag TreeView - g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 ); // vertical only scrolling for treeview @@ -2121,9 +2113,9 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_box_pack_end( GTK_BOX( vbox ), g_TextureBrowser.m_search_button, FALSE, FALSE, 0 ); } { // Tag frame - frame_table = gtk_table_new( 3, 3, FALSE ); + frame_table = ui::Table( 3, 3, FALSE ); - g_TextureBrowser.m_tag_frame = gtk_frame_new( "Tag assignment" ); + g_TextureBrowser.m_tag_frame = ui::Frame( "Tag assignment" ); gtk_frame_set_label_align( GTK_FRAME( g_TextureBrowser.m_tag_frame ), 0.5, 0.5 ); gtk_frame_set_shadow_type( GTK_FRAME( g_TextureBrowser.m_tag_frame ), GTK_SHADOW_NONE ); @@ -2134,7 +2126,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table ); } { // assigned tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -2143,9 +2135,9 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); - g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ); + g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) )); g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) ); g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE ); @@ -2153,7 +2145,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column ); gtk_widget_show( g_TextureBrowser.m_assigned_tree ); @@ -2163,7 +2155,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // available tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -2171,9 +2163,9 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); - g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ); + g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) )); g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) ); g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE ); @@ -2181,7 +2173,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column ); gtk_widget_show( g_TextureBrowser.m_available_tree ); @@ -2191,10 +2183,10 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // tag arrow buttons - GtkWidget* m_btn_left = gtk_button_new(); - GtkWidget* m_btn_right = gtk_button_new(); - GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ); - GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ); + ui::Widget m_btn_left = ui::Button(); + ui::Widget m_btn_right = ui::Button(); + ui::Widget m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + ui::Widget m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left ); gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right ); @@ -2214,8 +2206,8 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_widget_show( m_arrow_right ); } { // tag fram labels - GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" ); - GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" ); + ui::Widget m_lbl_assigned = ui::Label( "Assigned" ); + ui::Widget m_lbl_unassigned = ui::Label( "Available" ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); @@ -2240,7 +2232,7 @@ void TextureBrowser_destroyWindow(){ g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler ); - gtk_widget_unref( g_TextureBrowser.m_gl_widget ); + g_object_unref( g_TextureBrowser.m_gl_widget ); } const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){ @@ -2334,7 +2326,7 @@ void TextureBrowser_renameTag(){ } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for renaming." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for renaming." ); } } @@ -2345,9 +2337,9 @@ void TextureBrowser_deleteTag(){ gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected ); if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Are you sure you want to delete the selected tag?", "Delete Tag", eMB_YESNO, eMB_ICONQUESTION ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { GtkTreeIter iterSelected; gchar *rowTag; @@ -2374,7 +2366,7 @@ void TextureBrowser_deleteTag(){ } } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for deletion." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for deletion." ); } } @@ -2426,7 +2418,7 @@ void TextureBrowser_RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); UpdateAllWindows(); - GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree); + GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(GlobalTextureBrowser().m_treeViewTree)); GtkTreeModel* model = NULL; GtkTreeIter iter; if ( gtk_tree_selection_get_selected (selection, &model, &iter) ) @@ -2466,9 +2458,9 @@ void TextureBrowser_showAll(){ } void TextureBrowser_showUntagged(){ - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", eMB_YESNO, eMB_ICONWARNING ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { g_TextureBrowser.m_found_shaders.clear(); TagBuilder.GetUntagged( g_TextureBrowser.m_found_shaders ); std::set::iterator iter; diff --git a/radiant/texwindow.h b/radiant/texwindow.h index edc67b22..15ec907c 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -22,18 +22,16 @@ #if !defined( INCLUDED_TEXWINDOW_H ) #define INCLUDED_TEXWINDOW_H +#include #include "math/vector.h" #include "generic/callbackfwd.h" #include "signal/signalfwd.h" #include "xml/xmltextags.h" -typedef struct _GtkWidget GtkWidget; - class TextureBrowser; TextureBrowser& GlobalTextureBrowser(); -typedef struct _GtkWindow GtkWindow; -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ); +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ); void TextureBrowser_destroyWindow(); @@ -49,7 +47,7 @@ typedef Callback1 StringImportCallback; template class FreeCaller1; -extern GtkWidget* g_page_textures; +extern ui::Widget g_page_textures; void TextureBrowser_exportTitle( const StringImportCallback& importer ); typedef FreeCaller1 TextureBrowserExportTitleCaller; diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index d36e492a..9e1f20cf 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -24,9 +24,8 @@ #include "debugging/debugging.h" #include -#include -#include -#include +#include +#include #include "iscenegraph.h" #include "nameable.h" @@ -280,7 +279,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( std::size_t depth = ( *i ).first.get().size(); depth != 0; --depth ) { @@ -882,7 +881,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph; - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( GraphTreeNode* node = ( *graph_iterator_read_tree_iter( iter ) ).second; node != graph; node = node->m_parent ) { @@ -1369,7 +1368,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "0" ); + GtkTreePath* path = ui::TreePath( "0" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); @@ -1379,7 +1378,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "1" ); + GtkTreePath* path = ui::TreePath( "1" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); diff --git a/radiant/url.cpp b/radiant/url.cpp index b86702e7..ed33cb2f 100644 --- a/radiant/url.cpp +++ b/radiant/url.cpp @@ -28,7 +28,7 @@ #include #include bool open_url( const char* url ){ - return ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32; + return ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32; } #endif @@ -55,6 +55,6 @@ void OpenURL( const char *url ){ // let's put a little comment globalOutputStream() << "OpenURL: " << url << "\n"; if ( !open_url( url ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Failed to launch browser!" ); + MainFrame_getWindow().alert( "Failed to launch browser!" ); } } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index f3d1ae6f..7bbbf194 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -36,7 +36,7 @@ #include "watchbsp.h" #include -#include +#include #include "cmdlib.h" #include "convert.h" @@ -77,86 +77,87 @@ void message_print( message_info_t* self, const char* characters, std::size_t le #include +#include #include "xmlstuff.h" class CWatchBSP { private: -// a flag we have set to true when using an external BSP plugin -// the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop -// (in two seperate classes probably) -bool m_bBSPPlugin; - -// EIdle: we are not listening -// DoMonitoringLoop will change state to EBeginStep -// EBeginStep: the socket is up for listening, we are expecting incoming connection -// incoming connection will change state to EWatching -// EWatching: we have a connection, monitor it -// connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle) -enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState; -socket_t *m_pListenSocket; -socket_t *m_pInSocket; -netmessage_t msg; -GPtrArray *m_pCmd; -// used to timeout EBeginStep -GTimer *m_pTimer; -std::size_t m_iCurrentStep; -// name of the map so we can run the engine -char *m_sBSPName; -// buffer we use in push mode to receive data directly from the network -xmlParserInputBufferPtr m_xmlInputBuffer; -xmlParserInputPtr m_xmlInput; -xmlParserCtxtPtr m_xmlParserCtxt; -// call this to switch the set listening mode -bool SetupListening(); -// start a new EBeginStep -void DoEBeginStep(); -// the xml and sax parser state -char m_xmlBuf[MAX_NETMESSAGE]; -bool m_bNeedCtxtInit; -message_info_t m_message_info; + // a flag we have set to true when using an external BSP plugin + // the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop + // (in two seperate classes probably) + bool m_bBSPPlugin; + + // EIdle: we are not listening + // DoMonitoringLoop will change state to EBeginStep + // EBeginStep: the socket is up for listening, we are expecting incoming connection + // incoming connection will change state to EWatching + // EWatching: we have a connection, monitor it + // connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle) + enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState; + socket_t *m_pListenSocket; + socket_t *m_pInSocket; + netmessage_t msg; + GPtrArray *m_pCmd; + // used to timeout EBeginStep + GTimer *m_pTimer; + std::size_t m_iCurrentStep; + // name of the map so we can run the engine + char *m_sBSPName; + // buffer we use in push mode to receive data directly from the network + xmlParserInputBufferPtr m_xmlInputBuffer; + xmlParserInputPtr m_xmlInput; + xmlParserCtxtPtr m_xmlParserCtxt; + // call this to switch the set listening mode + bool SetupListening(); + // start a new EBeginStep + void DoEBeginStep(); + // the xml and sax parser state + char m_xmlBuf[MAX_NETMESSAGE]; + bool m_bNeedCtxtInit; + message_info_t m_message_info; public: -CWatchBSP(){ - m_pCmd = 0; - m_bBSPPlugin = false; - m_pListenSocket = NULL; - m_pInSocket = NULL; - m_eState = EIdle; - m_pTimer = g_timer_new(); - m_sBSPName = NULL; - m_xmlInputBuffer = NULL; - m_bNeedCtxtInit = true; -} -virtual ~CWatchBSP(){ - EndMonitoringLoop(); - Net_Shutdown(); - - g_timer_destroy( m_pTimer ); -} - -bool HasBSPPlugin() const -{ return m_bBSPPlugin; } + CWatchBSP(){ + m_pCmd = 0; + m_bBSPPlugin = false; + m_pListenSocket = NULL; + m_pInSocket = NULL; + m_eState = EIdle; + m_pTimer = g_timer_new(); + m_sBSPName = NULL; + m_xmlInputBuffer = NULL; + m_bNeedCtxtInit = true; + } + virtual ~CWatchBSP(){ + EndMonitoringLoop(); + Net_Shutdown(); -// called regularly to keep listening -void RoutineProcessing(); -// start a monitoring loop with the following steps -void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ); -void EndMonitoringLoop(){ - Reset(); - if ( m_sBSPName ) { - string_release( m_sBSPName, string_length( m_sBSPName ) ); - m_sBSPName = 0; + g_timer_destroy( m_pTimer ); } - if ( m_pCmd ) { - g_ptr_array_free( m_pCmd, TRUE ); - m_pCmd = 0; + + bool HasBSPPlugin() const + { return m_bBSPPlugin; } + + // called regularly to keep listening + void RoutineProcessing(); + // start a monitoring loop with the following steps + void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ); + void EndMonitoringLoop(){ + Reset(); + if ( m_sBSPName ) { + string_release( m_sBSPName, string_length( m_sBSPName ) ); + m_sBSPName = 0; + } + if ( m_pCmd ) { + g_ptr_array_free( m_pCmd, TRUE ); + m_pCmd = 0; + } } -} -// close everything - may be called from the outside to abort the process -void Reset(); -// start a listening loop for an external process, possibly a BSP plugin -void ExternalListen(); + // close everything - may be called from the outside to abort the process + void Reset(); + // start a listening loop for an external process, possibly a BSP plugin + void ExternalListen(); }; CWatchBSP* g_pWatchBSP; @@ -176,10 +177,10 @@ int g_WatchBSP_Timeout = 10; void Build_constructPreferences( PreferencesPage& page ){ - GtkWidget* monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); - GtkWidget* leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); - GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); - GtkWidget* sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); + ui::CheckButton monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); + ui::CheckButton leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); + ui::CheckButton runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); + ui::CheckButton sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); Widget_connectToggleDependency( leakstop, monitorbsp ); Widget_connectToggleDependency( runengine, monitorbsp ); Widget_connectToggleDependency( sleep, runengine ); @@ -359,29 +360,30 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){ class MessageOutputStream : public TextOutputStream { -message_info_t* m_data; + message_info_t* m_data; public: -MessageOutputStream( message_info_t* data ) : m_data( data ){ -} -std::size_t write( const char* buffer, std::size_t length ){ - if ( m_data->pGeometry != 0 ) { - m_data->pGeometry->saxCharacters( m_data, reinterpret_cast( buffer ), int(length) ); + MessageOutputStream( message_info_t* data ) : m_data( data ){ } - else - { - if ( m_data->ignore_depth == 0 ) { - // output the message using the level - message_print( m_data, buffer, length ); - // if this message has error level flag, we mark the depth to stop the compilation when we get out - // we don't set the msg level if we don't stop on leak - if ( m_data->msg_level == 3 ) { - m_data->stop_depth = m_data->recurse - 1; + + std::size_t write( const char* buffer, std::size_t length ){ + if ( m_data->pGeometry != 0 ) { + m_data->pGeometry->saxCharacters( m_data, reinterpret_cast( buffer ), int(length) ); + } + else + { + if ( m_data->ignore_depth == 0 ) { + // output the message using the level + message_print( m_data, buffer, length ); + // if this message has error level flag, we mark the depth to stop the compilation when we get out + // we don't set the msg level if we don't stop on leak + if ( m_data->msg_level == 3 ) { + m_data->stop_depth = m_data->recurse - 1; + } } } - } - return length; -} + return length; + } }; template @@ -488,7 +490,7 @@ void CWatchBSP::Reset(){ } m_eState = EIdle; if ( s_routine_id ) { - gtk_timeout_remove( s_routine_id ); + g_source_remove( s_routine_id ); } } @@ -514,7 +516,7 @@ void CWatchBSP::DoEBeginStep(){ if ( SetupListening() == false ) { const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n"; globalOutputStream() << msg; - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg, "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); return; } // set the timer for timeouts and step cancellation @@ -531,7 +533,7 @@ void CWatchBSP::DoEBeginStep(){ msg << reinterpret_cast( g_ptr_array_index( m_pCmd, m_iCurrentStep ) ); msg << "\nCheck that the file exists and that you don't run out of system resources.\n"; globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); return; } // re-initialise the debug window @@ -540,7 +542,7 @@ void CWatchBSP::DoEBeginStep(){ } } m_eState = EBeginStep; - s_routine_id = gtk_timeout_add( 25, watchbsp_routine, this ); + s_routine_id = g_timeout_add( 25, watchbsp_routine, this ); } @@ -560,15 +562,15 @@ void CWatchBSP::DoEBeginStep(){ class RunEngineConfiguration { public: -const char* executable; -const char* mp_executable; -bool do_sp_mp; - -RunEngineConfiguration() : - executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ), - mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){ - do_sp_mp = !string_empty( mp_executable ); -} + const char* executable; + const char* mp_executable; + bool do_sp_mp; + + RunEngineConfiguration() : + executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ), + mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){ + do_sp_mp = !string_empty( mp_executable ); + } }; inline void GlobalGameDescription_string_write_mapparameter( StringOutputStream& string, const char* mapname ){ @@ -611,7 +613,7 @@ void CWatchBSP::RoutineProcessing(){ case EBeginStep: // timeout: if we don't get an incoming connection fast enough, go back to idle if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", eMB_OK ); + MainFrame_getWindow().alert( "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK ); EndMonitoringLoop(); #if 0 if ( m_bBSPPlugin ) { @@ -744,7 +746,7 @@ void CWatchBSP::RoutineProcessing(){ StringOutputStream msg; msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str(); globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); } } EndMonitoringLoop(); @@ -772,8 +774,8 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){ if ( m_eState != EIdle ) { globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n"; // prompt the user, should we cancel the current process and go ahead? - if ( gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", - "Build process monitoring", eMB_YESNO ) == eIDYES ) { + if ( MainFrame_getWindow().alert( "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", + "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) { // disconnect and set EIdle state Reset(); } diff --git a/radiant/windowobservers.cpp b/radiant/windowobservers.cpp index 989c1196..d30d0e3c 100644 --- a/radiant/windowobservers.cpp +++ b/radiant/windowobservers.cpp @@ -22,7 +22,7 @@ #include "windowobservers.h" #include -#include +#include #include "generic/bitfield.h" namespace @@ -50,7 +50,7 @@ inline void WindowObservers_OnModifierUp( WindowObservers& observers, ModifierFl #include -gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_press( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { case GDK_Alt_L: @@ -72,7 +72,7 @@ gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, Wi return FALSE; } -gboolean selection_modifier_key_release( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_release( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { case GDK_Alt_L: @@ -109,21 +109,21 @@ void WindowObservers_UpdateModifiers( WindowObservers& observers, ModifierFlags WindowObservers_UpdateModifier( observers, modifiers, c_modifierControl ); } -gboolean modifiers_button_press( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_press( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_PRESS ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_button_release( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_release( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_RELEASE ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_motion( GtkWidget *widget, GdkEventMotion *event, WindowObservers* observers ){ +gboolean modifiers_motion( ui::Widget widget, GdkEventMotion *event, WindowObservers* observers ){ WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); return FALSE; } @@ -139,12 +139,12 @@ void GlobalWindowObservers_add( WindowObserver* observer ){ g_window_observers.push_back( observer ); } -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ){ +void GlobalWindowObservers_connectTopLevel( ui::Window window ){ g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers ); g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers ); } -void GlobalWindowObservers_connectWidget( GtkWidget* widget ){ +void GlobalWindowObservers_connectWidget( ui::Widget widget ){ g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers ); g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers ); g_signal_connect( G_OBJECT( widget ), "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers ); diff --git a/radiant/windowobservers.h b/radiant/windowobservers.h index eab5fe59..9785d9dc 100644 --- a/radiant/windowobservers.h +++ b/radiant/windowobservers.h @@ -24,16 +24,15 @@ #include "windowobserver.h" -#include +#include +#include #include "math/vector.h" class WindowObserver; void GlobalWindowObservers_add( WindowObserver* observer ); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void GlobalWindowObservers_connectWidget( GtkWidget* widget ); -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ); +void GlobalWindowObservers_connectWidget( ui::Widget widget ); +void GlobalWindowObservers_connectTopLevel( ui::Window window ); inline ButtonIdentifier button_for_button( unsigned int button ){ switch ( button ) diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index a30303f4..b51f3cd3 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -68,8 +68,7 @@ class IGL2DWindow; class ISAXHandler { public: -virtual void Release(){ -} +virtual void Release(){} virtual void saxStartElement( message_info_t* ctx, const xmlChar* name, const xmlChar** attrs ) = 0; virtual void saxEndElement( message_info_t* ctx, const xmlChar* name ) = 0; virtual void saxCharacters( message_info_t* ctx, const xmlChar* ch, int len ) = 0; diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index b094b774..18106075 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -39,8 +39,9 @@ #include "image.h" #include "gtkutil/messagebox.h" -#include -#include +#include +#include +#include #include "generic/callback.h" #include "string/string.h" @@ -548,7 +549,7 @@ void WXY_Print(){ unsigned char* img; const char* filename; - filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); + filename = ui::file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); if ( !filename ) { return; } @@ -705,12 +706,12 @@ bool XYWnd::chaseMouseMotion( int pointx, int pointy ){ Shader* XYWnd::m_state_selected = 0; void xy_update_xor_rectangle( XYWnd& self, rect_t area ){ - if ( GTK_WIDGET_VISIBLE( self.GetWidget() ) ) { + if ( gtk_widget_get_visible( self.GetWidget() ) ) { self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.Width(), self.Height() ) ); } } -gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_press( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_PRESS ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -721,7 +722,7 @@ gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xy return FALSE; } -gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_release( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_RELEASE ) { xywnd->XY_MouseUp( static_cast( event->x ), static_cast( event->y ), buttons_for_event_button( event ) ); @@ -730,7 +731,7 @@ gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* return FALSE; } -gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean xywnd_focus_in( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ if ( event->type == GDK_FOCUS_CHANGE ) { if ( event->in ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -746,7 +747,7 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->XY_MouseMoved( static_cast( x ), static_cast( y ), buttons_for_state( state ) ); } -gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){ +gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){ if ( event->direction == GDK_SCROLL_UP ) { XYWnd_ZoomIn( xywnd ); } @@ -756,7 +757,7 @@ gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xy return FALSE; } -gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){ +gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWnd* xywnd ){ xywnd->m_nWidth = allocation->width; xywnd->m_nHeight = allocation->height; xywnd->updateProjection(); @@ -764,7 +765,7 @@ gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWn return FALSE; } -gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){ +gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){ if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) { if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { GlobalOpenGL_debugAssertNoErrors(); @@ -826,10 +827,10 @@ XYWnd::XYWnd() : m_window_observer->setRectangleDrawCallback( ReferenceCaller1( *this ) ); m_window_observer->setView( m_view ); - gtk_widget_ref( m_gl_widget ); + g_object_ref( m_gl_widget ); gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( m_gl_widget, true ); m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( xywnd_size_allocate ), this ); m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( xywnd_expose ), this ); @@ -865,7 +866,7 @@ XYWnd::~XYWnd(){ g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler ); - gtk_widget_unref( m_gl_widget ); + g_object_unref( m_gl_widget ); m_window_observer->release(); } @@ -944,12 +945,12 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) { GdkCursor *cursor; cursor = gdk_cursor_new( GDK_CROSSHAIR ); - gdk_window_set_cursor( m_gl_widget->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor ); gdk_cursor_unref( cursor ); } else { - gdk_window_set_cursor( m_gl_widget->window, 0 ); + gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), 0 ); } } @@ -1058,15 +1059,15 @@ void XYWnd::NewBrushDrag( int x, int y ){ "textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) ); } -void entitycreate_activated( GtkWidget* item ){ +void entitycreate_activated( ui::Widget item ){ scene::Node* world_node = Map_FindWorldspawn( g_map ); - const char* entity_name = gtk_label_get_text( GTK_LABEL( GTK_BIN( item )->child ) ); + const char* entity_name = gtk_label_get_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( item )) ) ); if ( !( world_node && string_equal( entity_name, "worldspawn" ) ) ) { g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name ); } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( MainFrame_getWindow() ), "There's already a worldspawn in your map!" + GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!" "", "Info", eMB_OK, @@ -1075,7 +1076,7 @@ void entitycreate_activated( GtkWidget* item ){ } void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name ) ); + GtkMenuItem* item = ui::MenuItem( name ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item ); gtk_widget_show( GTK_WIDGET( item ) ); menu_add_item( menu, item ); @@ -1105,11 +1106,11 @@ void visit( EntityClass* e ){ m_previous = e->name(); } void pushMenu( const CopiedString& name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name.c_str() ) ); + GtkMenuItem* item = ui::MenuItem( name.c_str() ); gtk_widget_show( GTK_WIDGET( item ) ); container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) ); - GtkMenu* submenu = GTK_MENU( gtk_menu_new() ); + GtkMenu* submenu = ui::Menu(); gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) ); m_stack.push_back( MenuPair( submenu, name ) ); @@ -1152,7 +1153,7 @@ void XYWnd::OnContextMenu(){ } if ( m_mnuDrop == 0 ) { // first time, load it up - GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() ); + GtkMenu* menu = m_mnuDrop = ui::Menu(); EntityClassMenuInserter inserter( menu ); GlobalEntityClassManager().forEach( inserter ); @@ -1172,7 +1173,7 @@ void XYWnd_moveDelta( int x, int y, unsigned int state, void* data ){ reinterpret_cast( data )->Scroll( -x, y ); } -gboolean XYWnd_Move_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Move_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Move_End(); return FALSE; } @@ -1182,13 +1183,13 @@ void XYWnd::Move_Begin(){ Move_End(); } m_move_started = true; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); } void XYWnd::Move_End(){ m_move_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut ); } @@ -1217,7 +1218,7 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){ } } -gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Zoom_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Zoom_End(); return FALSE; } @@ -1228,13 +1229,13 @@ void XYWnd::Zoom_Begin(){ } m_zoom_started = true; g_dragZoom = 0; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); } void XYWnd::Zoom_End(){ m_zoom_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut ); } @@ -1255,7 +1256,7 @@ void XYWnd::SetViewType( VIEWTYPE viewType ){ m_viewType = viewType; updateModelview(); - if ( m_parent != 0 ) { + if ( m_parent ) { gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) ); } } @@ -1485,12 +1486,12 @@ void XYWnd::XY_DisableBackground( void ){ void WXY_BackgroundSelect( void ){ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0; if ( !brushesSelected ) { - gtk_MessageBox( 0, "You have to select some brushes to get the bounding box for.\n", - "No selection", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "You have to select some brushes to get the bounding box for.\n", + "No selection", ui::alert_type::OK, ui::alert_icon::Error ); return; } - const char *filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, "Background Image", NULL, NULL ); + const char *filename = MainFrame_getWindow().file_dialog( TRUE, "Background Image", NULL, NULL ); g_pParentWnd->ActiveXY()->XY_DisableBackground(); if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); @@ -2537,19 +2538,19 @@ void ToggleShowGrid(){ ToggleShown g_xy_top_shown( true ); -void XY_Top_Shown_Construct( GtkWindow* parent ){ +void XY_Top_Shown_Construct( ui::Window parent ){ g_xy_top_shown.connect( GTK_WIDGET( parent ) ); } ToggleShown g_yz_side_shown( false ); -void YZ_Side_Shown_Construct( GtkWindow* parent ){ +void YZ_Side_Shown_Construct( ui::Window parent ){ g_yz_side_shown.connect( GTK_WIDGET( parent ) ); } ToggleShown g_xz_front_shown( false ); -void XZ_Front_Shown_Construct( GtkWindow* parent ){ +void XZ_Front_Shown_Construct( ui::Window parent ){ g_xz_front_shown.connect( GTK_WIDGET( parent ) ); } @@ -2744,14 +2745,14 @@ void XYWindow_Construct(){ GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) ); GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) ); - GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_Delete ) ); - GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_Insert ) ); - GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KP_Home ) ); - GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KP_Page_Down ) ); - GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KP_End ) ); + GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_KEY_Delete ) ); + GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_KEY_Insert ) ); + GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KEY_KP_Home ) ); + GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KEY_KP_Page_Down ) ); + GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KEY_KP_End ) ); GlobalCommands_insert( "Zoom100", FreeCaller() ); - GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) ); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index cbf37b43..66709784 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -40,7 +40,6 @@ namespace scene { class Node; } -typedef struct _GtkWindow GtkWindow; typedef struct _GtkMenu GtkMenu; @@ -65,21 +64,21 @@ inline const char* ViewType_getTitle( VIEWTYPE viewtype ){ class XYWnd { -GtkWidget* m_gl_widget; +ui::Widget m_gl_widget; guint m_sizeHandler; guint m_exposeHandler; DeferredDraw m_deferredDraw; DeferredMotion m_deferred_motion; public: -GtkWindow* m_parent; +ui::Window m_parent; XYWnd(); ~XYWnd(); void queueDraw(){ m_deferredDraw.draw(); } -GtkWidget* GetWidget(){ +ui::Widget GetWidget(){ return m_gl_widget; } @@ -281,10 +280,9 @@ extern xywindow_globals_t g_xywindow_globals; VIEWTYPE GlobalXYWnd_getCurrentViewType(); -typedef struct _GtkWindow GtkWindow; -void XY_Top_Shown_Construct( GtkWindow* parent ); -void YZ_Side_Shown_Construct( GtkWindow* parent ); -void XZ_Front_Shown_Construct( GtkWindow* parent ); +void XY_Top_Shown_Construct( ui::Window parent ); +void YZ_Side_Shown_Construct( ui::Window parent ); +void XZ_Front_Shown_Construct( ui::Window parent ); void XYWindow_Construct(); void XYWindow_Destroy(); -- 2.39.2