From: TimePath Date: Wed, 3 Jan 2018 10:28:05 +0000 (+1100) Subject: Wrap more GTK X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0203ac024e9396ebc180d9721da40b90b7c33dc6;p=xonotic%2Fnetradiant.git Wrap more GTK --- diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index b00da471..9329f306 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -51,7 +51,7 @@ dlg_texReset_t dlgTexReset; void Update_TextureReseter(); -static void dialog_button_callback_texreset_update( GtkWidget *widget, gpointer data ){ +static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){ Update_TextureReseter(); } @@ -97,11 +97,11 @@ static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer return TRUE; } -static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){ +static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){ TwinWidget* tw = (TwinWidget*)data; - GtkEntry* entry = GTK_ENTRY( tw->one ); - auto* combo = GTK_BIN(tw->two); + auto entry = ui::Entry::from( tw->one ); + auto combo = tw->two; const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo))); gtk_entry_set_text( entry, tex ); @@ -227,7 +227,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); w.show(); - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 2 ); w.show(); @@ -332,15 +332,15 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ // ---- vbox ---- - auto radio1 = ui::Widget(gtk_radio_button_new_with_label( NULL, "Use Whole Map" )); + auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" )); vbox.pack_start( radio1, FALSE, FALSE, 2 ); radio1.show(); - auto radio2 = ui::Widget(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" )); + auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" )); vbox.pack_start( radio2, FALSE, FALSE, 2 ); radio2.show(); - auto hsep = ui::Widget(gtk_hseparator_new()); + auto hsep = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( hsep, FALSE, FALSE, 2 ); hsep.show(); @@ -444,7 +444,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // ---- hbox2 ---- auto text1 = ui::Entry( 256 ); - gtk_entry_set_text( (GtkEntry*)text1, "3" ); + gtk_entry_set_text( text1, "3" ); hbox2.pack_start( text1, FALSE, FALSE, 2 ); text1.show(); @@ -462,7 +462,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // ---- hbox2 ---- auto text2 = ui::Entry( 256 ); - gtk_entry_set_text( (GtkEntry*)text2, "8" ); + gtk_entry_set_text( text2, "8" ); hbox2.pack_start( text2, FALSE, FALSE, 2 ); text2.show(); @@ -543,12 +543,12 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false; rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false; - if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) { + if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) { dialogError = TRUE; } if ( rs->bUseBorder ) { - if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) { + if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) { dialogError = TRUE; } } @@ -599,7 +599,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ... w.show(); - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); @@ -640,25 +640,25 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // djbob: actually it looks very nice :), slightly better than the way i did it // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh - auto radioNorth = ui::Widget(gtk_radio_button_new_with_label( NULL, "North" )); + auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" )); hbox.pack_start( radioNorth, FALSE, FALSE, 3 ); radioNorth.show(); radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) ); - auto radioSouth = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "South" )); + auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" )); hbox.pack_start( radioSouth, FALSE, FALSE, 2 ); radioSouth.show(); radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) ); - auto radioEast = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "East" )); + auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" )); hbox.pack_start( radioEast, FALSE, FALSE, 1 ); radioEast.show(); radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) ); - auto radioWest = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "West" )); + auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" )); hbox.pack_start( radioWest, FALSE, FALSE, 0 ); radioWest.show(); @@ -678,19 +678,19 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ vbox.pack_start( hbox, FALSE, FALSE, 0 ); hbox.show(); - auto radioOldStyle = ui::Widget(gtk_radio_button_new_with_label( NULL, "Original" )); + auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" )); hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 ); radioOldStyle.show(); radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) ); - auto radioBobStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" )); + auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" )); hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 ); radioBobStyle.show(); radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) ); - auto radioCornerStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Corner Style" )); + auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" )); hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 ); radioCornerStyle.show(); @@ -735,7 +735,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ w.show(); // -------------------------- // - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); @@ -774,8 +774,8 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ if ( ret == eIDOK ) { rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false; - strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) ); - strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) ); + strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) ); + strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) ); if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) { rs->direction = MOVE_NORTH; @@ -790,7 +790,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ rs->direction = MOVE_WEST; } - if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) { + if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) { dialogError = TRUE; } @@ -836,8 +836,8 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_widget_realize( window ); char buffer[256]; - ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING )); + auto listTrimTextures = ui::ListStore::from(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 ); @@ -915,7 +915,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ // djbob: lists added - auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listMainTextures))); + auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures)); gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); hbox.pack_start( comboMain, FALSE, FALSE, 0 ); comboMain.show(); @@ -934,7 +934,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ vbox.pack_start( hbox, FALSE, FALSE, 0 ); hbox.show(); - auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listTrimTextures))); + auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures)); gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); hbox.pack_start( comboTrim, FALSE, FALSE, 0 ); comboTrim.show(); @@ -958,19 +958,19 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ w.show(); // argh more radio buttons! - auto radioNS = ui::Widget(gtk_radio_button_new_with_label( NULL, "North - South" )); + auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" )); hbox.pack_start( radioNS, FALSE, FALSE, 0 ); radioNS.show(); radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) ); - auto radioEW = ui::Widget(gtk_radio_button_new_with_label( radioOrientation, "East - West" )); + auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" )); hbox.pack_start( radioEW, FALSE, FALSE, 0 ); radioEW.show(); // ----------------- // - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); @@ -1111,7 +1111,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ // ---- /hbox ---- - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); @@ -1128,7 +1128,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ // ----------------- // - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); @@ -1832,7 +1832,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ hbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); - w = ui::Widget(gtk_hseparator_new()); + w = ui::Widget::from(gtk_hseparator_new()); vbox.pack_start( w, FALSE, FALSE, 0 ); w.show(); diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index 86943c27..1e7dbb2a 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -51,8 +51,8 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ // collapse mode collapsemode mode = COLLAPSE_NONE; - GtkWidget* radio = lookup_widget( button , "r_collapse" ); - ASSERT_NOTNULL( radio ); + auto radio = lookup_widget( button , "r_collapse" ); + ASSERT_TRUE( radio ); if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) { mode = COLLAPSE_ALL; @@ -60,22 +60,22 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ else { radio = lookup_widget( button , "r_collapsebymaterial" ); - ASSERT_NOTNULL( radio ); + ASSERT_TRUE( radio ); if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) { mode = COLLAPSE_BY_MATERIAL; } else { radio = lookup_widget( button , "r_nocollapse" ); - ASSERT_NOTNULL( radio ); + ASSERT_TRUE( radio ); ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); mode = COLLAPSE_NONE; } } // export materials? - GtkWidget* toggle = lookup_widget( button , "t_exportmaterials" ); - ASSERT_NOTNULL( toggle ); + auto toggle = lookup_widget( button , "t_exportmaterials" ); + ASSERT_TRUE( toggle ); bool exportmat = FALSE; @@ -85,7 +85,7 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ // limit material names? toggle = lookup_widget( button , "t_limitmatnames" ); - ASSERT_NOTNULL( toggle ); + ASSERT_TRUE( toggle ); bool limitMatNames = FALSE; @@ -95,7 +95,7 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ // create objects instead of groups? toggle = lookup_widget( button , "t_objects" ); - ASSERT_NOTNULL( toggle ); + ASSERT_TRUE( toggle ); bool objects = FALSE; @@ -108,8 +108,8 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ } void OnAddMaterial( ui::Button button, gpointer user_data ){ - GtkEntry* edit = GTK_ENTRY( lookup_widget( button , "ed_materialname" ) ); - ASSERT_NOTNULL( edit ); + auto edit = ui::Entry::from( lookup_widget( button , "ed_materialname" ) ); + ASSERT_TRUE( edit ); const gchar* name = gtk_entry_get_text( edit ); if ( g_utf8_strlen( name, -1 ) > 0 ) { @@ -120,9 +120,9 @@ void OnAddMaterial( ui::Button button, gpointer user_data ){ } void OnRemoveMaterial( ui::Button button, gpointer user_data ){ - GtkTreeView* view = ui::TreeView::from(lookup_widget(button, "t_materialist")); + ui::TreeView view = ui::TreeView::from(lookup_widget(button, "t_materialist")); ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) ); - GtkTreeSelection* sel = gtk_tree_view_get_selection( view ); + auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection( view )); GtkTreeIter iter; if ( gtk_tree_selection_get_selected( sel, 0, &iter ) ) { @@ -131,8 +131,8 @@ void OnRemoveMaterial( ui::Button button, gpointer user_data ){ } void OnExportMatClicked( ui::Button button, gpointer user_data ){ - GtkWidget* toggleLimit = lookup_widget( button , "t_limitmatnames" ); - GtkWidget* toggleObject = lookup_widget( button , "t_objects" ); + ui::Widget toggleLimit = lookup_widget( button , "t_limitmatnames" ); + ui::Widget toggleObject = lookup_widget( button , "t_objects" ); if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) ) ) { gtk_widget_set_sensitive( toggleLimit , TRUE ); diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index a4e8d732..d464a02a 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -13,8 +13,7 @@ g_object_set_data( G_OBJECT( component ), name, (void *) widget ) // created by glade -GtkWidget* -create_w_plugplug2( void ){ +ui::Widget create_w_plugplug2( void ){ GSList *r_collapse_group = NULL; auto w_plugplug2 = ui::Window( ui::window_type::TOP ); @@ -40,7 +39,7 @@ create_w_plugplug2( void ){ vbox4.show(); hbox2.pack_start( vbox4, TRUE, FALSE, 0 ); - auto r_collapse = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" )); + auto r_collapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" )); gtk_widget_set_name( r_collapse, "r_collapse" ); gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group"); r_collapse.show(); @@ -48,7 +47,7 @@ create_w_plugplug2( void ){ gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapse ), r_collapse_group ); r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapse ) ); - auto r_collapsebymaterial = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" )); + auto r_collapsebymaterial = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" )); gtk_widget_set_name( r_collapsebymaterial, "r_collapsebymaterial" ); gtk_widget_set_tooltip_text(r_collapsebymaterial, "Collapse into groups by material"); r_collapsebymaterial.show(); @@ -56,7 +55,7 @@ create_w_plugplug2( void ){ gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapsebymaterial ), r_collapse_group ); r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapsebymaterial ) ); - auto r_nocollapse = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" )); + auto r_nocollapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" )); gtk_widget_set_name( r_nocollapse, "r_nocollapse" ); gtk_widget_set_tooltip_text(r_nocollapse, "Every brush is stored in its own group"); r_nocollapse.show(); @@ -69,13 +68,13 @@ create_w_plugplug2( void ){ vbox3.show(); hbox2.pack_start( vbox3, FALSE, FALSE, 0 ); - auto b_export = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-save" ))); + auto b_export = ui::Button::from(gtk_button_new_from_stock( "gtk-save" )); gtk_widget_set_name( b_export, "b_export" ); b_export.show(); vbox3.pack_start( b_export, TRUE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( b_export ), 5 ); - auto b_close = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-cancel" ))); + auto b_close = ui::Button::from(gtk_button_new_from_stock( "gtk-cancel" )); gtk_widget_set_name( b_close, "b_close" ); b_close.show(); vbox3.pack_start( b_close, TRUE, FALSE, 0 ); @@ -116,27 +115,27 @@ create_w_plugplug2( void ){ hbox1.show(); vbox2.pack_start( hbox1, FALSE, FALSE, 0 ); - auto b_addmaterial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-add" ))); + auto b_addmaterial = ui::Button::from(gtk_button_new_from_stock( "gtk-add" )); gtk_widget_set_name( b_addmaterial, "b_addmaterial" ); b_addmaterial.show(); hbox1.pack_start( b_addmaterial, FALSE, FALSE, 0 ); - auto b_removematerial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-remove" ))); + auto b_removematerial = ui::Button::from(gtk_button_new_from_stock( "gtk-remove" )); gtk_widget_set_name( b_removematerial, "b_removematerial" ); b_removematerial.show(); hbox1.pack_start( b_removematerial, FALSE, FALSE, 0 ); - auto t_limitmatnames = ui::Widget(gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" )); + auto t_limitmatnames = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" )); gtk_widget_set_name( t_limitmatnames, "t_limitmatnames" ); t_limitmatnames.show(); vbox2.pack_end( t_limitmatnames, FALSE, FALSE, 0 ); - auto t_objects = ui::Widget(gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" )); + auto t_objects = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" )); gtk_widget_set_name( t_objects, "t_objects" ); t_objects.show(); vbox2.pack_end(t_objects, FALSE, FALSE, 0); - auto t_exportmaterials = ui::CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" ))); + auto t_exportmaterials = ui::CheckButton::from(gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" )); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( t_exportmaterials ), true ); gtk_widget_set_name( t_exportmaterials, "t_exportmaterials" ); t_exportmaterials.show(); @@ -178,16 +177,16 @@ create_w_plugplug2( void ){ } // global main window, is 0 when not created -GtkWidget* g_brushexp_window = 0; +ui::Widget g_brushexp_window{ui::null}; // spawn plugin window (and make sure it got destroyed first or never created) void CreateWindow( void ){ ASSERT_TRUE( !g_brushexp_window ); - GtkWidget* wnd = create_w_plugplug2(); + ui::Widget wnd = create_w_plugplug2(); // column & renderer - GtkTreeViewColumn* col = gtk_tree_view_column_new(); + auto col = ui::TreeViewColumn::from(gtk_tree_view_column_new()); gtk_tree_view_column_set_title( col, "materials" ); auto view = ui::TreeView::from(lookup_widget(wnd, "t_materialist")); gtk_tree_view_append_column(view, col ); @@ -195,7 +194,7 @@ void CreateWindow( void ){ gtk_tree_view_insert_column_with_attributes(view, -1, "", renderer, "text", 0, NULL ); // list store - ui::ListStore ignorelist = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + auto ignorelist = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING )); gtk_tree_view_set_model(view, ignorelist ); ignorelist.unref(); @@ -203,12 +202,12 @@ void CreateWindow( void ){ g_brushexp_window = wnd; } -void DestroyWindow( void ){ - ASSERT_NOTNULL( g_brushexp_window ); +void DestroyWindow(){ + ASSERT_TRUE( g_brushexp_window ); ui::Widget(g_brushexp_window).destroy(); - g_brushexp_window = 0; + g_brushexp_window = ui::Widget(ui::null); } -bool IsWindowOpen( void ){ - return g_brushexp_window != 0; +bool IsWindowOpen(){ + return g_brushexp_window; } diff --git a/contrib/brushexport/support.cpp b/contrib/brushexport/support.cpp index 768f213a..b2586177 100644 --- a/contrib/brushexport/support.cpp +++ b/contrib/brushexport/support.cpp @@ -4,20 +4,20 @@ #include "support.h" ui::Widget -lookup_widget( GtkWidget *widget, +lookup_widget(ui::Widget widget, const gchar *widget_name ){ - GtkWidget *parent, *found_widget; + ui::Widget parent{ui::null}; for (;; ) { if ( GTK_IS_MENU( widget ) ) { - parent = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); + parent = ui::Widget::from(gtk_menu_get_attach_widget( GTK_MENU( widget ) )); } else{ - parent = gtk_widget_get_parent(widget); + parent = ui::Widget::from(gtk_widget_get_parent(widget)); } if ( !parent ) { - parent = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), "GladeParentKey" ); + parent = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), "GladeParentKey" )); } if ( parent == NULL ) { break; @@ -25,10 +25,9 @@ lookup_widget( GtkWidget *widget, widget = parent; } - found_widget = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), - widget_name ); + auto found_widget = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), widget_name )); if ( !found_widget ) { g_warning( "Widget not found: %s", widget_name ); } - return ui::Widget(found_widget); + return found_widget; } diff --git a/contrib/brushexport/support.h b/contrib/brushexport/support.h index 1cf6099e..20116a13 100644 --- a/contrib/brushexport/support.h +++ b/contrib/brushexport/support.h @@ -18,5 +18,5 @@ * or alternatively any widget in the component, and the name of the widget * you want returned. */ -ui::Widget lookup_widget( GtkWidget *widget, +ui::Widget lookup_widget(ui::Widget widget, const gchar *widget_name ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 0d3a3920..1d7f2743 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -57,7 +57,7 @@ static int DoColor( PackedColour *c ){ clr.blue = (guint16) (GetGValue(*c) * (65535 / 255)); clr.green = (guint16) (GetBValue(*c) * (65535 / 255)); - auto dlg = ui::Widget(gtk_color_selection_dialog_new( "Choose Color" )); + auto dlg = ui::Widget::from(gtk_color_selection_dialog_new( "Choose Color" )); gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -65,8 +65,8 @@ static int DoColor( PackedColour *c ){ GtkWidget *ok_button, *cancel_button; g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); - ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + ui::Widget::from(cancel_button).connect( "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 ); @@ -88,7 +88,7 @@ static int DoColor( PackedColour *c ){ return ret; } -static void Set2DText( GtkWidget* label ){ +static void Set2DText(ui::Widget label ){ char s[40]; sprintf( s, "Line Width = %6.3f", portals.width_2d * 0.5f ); @@ -96,7 +96,7 @@ static void Set2DText( GtkWidget* label ){ gtk_label_set_text( GTK_LABEL( label ), s ); } -static void Set3DText( GtkWidget* label ){ +static void Set3DText(ui::Widget label ){ char s[40]; sprintf( s, "Line Width = %6.3f", portals.width_3d * 0.5f ); @@ -104,7 +104,7 @@ static void Set3DText( GtkWidget* label ){ gtk_label_set_text( GTK_LABEL( label ), s ); } -static void Set3DTransText( GtkWidget* label ){ +static void Set3DTransText(ui::Widget label ){ char s[40]; sprintf( s, "Polygon transparency = %d%%", (int)portals.trans_3d ); @@ -112,7 +112,7 @@ static void Set3DTransText( GtkWidget* label ){ gtk_label_set_text( GTK_LABEL( label ), s ); } -static void SetClipText( GtkWidget* label ){ +static void SetClipText(ui::Widget label ){ char s[40]; sprintf( s, "Cubic clip range = %d", (int)portals.clip_range * 64 ); @@ -120,7 +120,7 @@ static void SetClipText( GtkWidget* label ){ gtk_label_set_text( GTK_LABEL( label ), s ); } -static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ +static void OnScroll2d(ui::Adjustment adj, gpointer data ){ portals.width_2d = static_cast( gtk_adjustment_get_value(adj) ); Set2DText( ui::Widget::from(data) ); @@ -128,28 +128,28 @@ static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ SceneChangeNotify(); } -static void OnScroll3d( GtkAdjustment *adj, gpointer data ){ +static void OnScroll3d(ui::Adjustment adj, gpointer data ){ portals.width_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DText( ui::Widget::from( data ) ); SceneChangeNotify(); } -static void OnScrollTrans( GtkAdjustment *adj, gpointer data ){ +static void OnScrollTrans(ui::Adjustment adj, gpointer data ){ portals.trans_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DTransText( ui::Widget::from( data ) ); SceneChangeNotify(); } -static void OnScrollClip( GtkAdjustment *adj, gpointer data ){ +static void OnScrollClip(ui::Adjustment adj, gpointer data ){ portals.clip_range = static_cast( gtk_adjustment_get_value(adj) ); SetClipText( ui::Widget::from( data ) ); SceneChangeNotify(); } -static void OnAntiAlias2d( GtkWidget *widget, gpointer data ){ +static void OnAntiAlias2d(ui::Widget widget, gpointer data ){ portals.aa_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; Portals_shadersChanged(); @@ -157,13 +157,13 @@ static void OnAntiAlias2d( GtkWidget *widget, gpointer data ){ SceneChangeNotify(); } -static void OnConfig2d( GtkWidget *widget, gpointer data ){ +static void OnConfig2d(ui::Widget widget, gpointer data ){ portals.show_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; SceneChangeNotify(); } -static void OnColor2d( GtkWidget *widget, gpointer data ){ +static void OnColor2d(ui::Widget widget, gpointer data ){ if ( DoColor( &portals.color_2d ) == IDOK ) { Portals_shadersChanged(); @@ -171,21 +171,21 @@ static void OnColor2d( GtkWidget *widget, gpointer data ){ } } -static void OnConfig3d( GtkWidget *widget, gpointer data ){ +static void OnConfig3d(ui::Widget widget, gpointer data ){ portals.show_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; SceneChangeNotify(); } -static void OnAntiAlias3d( GtkWidget *widget, gpointer data ){ +static void OnAntiAlias3d(ui::Widget widget, gpointer data ){ portals.aa_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; Portals_shadersChanged(); SceneChangeNotify(); } -static void OnColor3d( GtkWidget *widget, gpointer data ){ +static void OnColor3d(ui::Widget widget, gpointer data ){ if ( DoColor( &portals.color_3d ) == IDOK ) { Portals_shadersChanged(); @@ -193,7 +193,7 @@ static void OnColor3d( GtkWidget *widget, gpointer data ){ } } -static void OnColorFog( GtkWidget *widget, gpointer data ){ +static void OnColorFog(ui::Widget widget, gpointer data ){ if ( DoColor( &portals.color_fog ) == IDOK ) { Portals_shadersChanged(); @@ -201,33 +201,33 @@ static void OnColorFog( GtkWidget *widget, gpointer data ){ } } -static void OnFog( GtkWidget *widget, gpointer data ){ +static void OnFog(ui::Widget widget, gpointer data ){ portals.fog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; Portals_shadersChanged(); SceneChangeNotify(); } -static void OnSelchangeZbuffer( GtkWidget *widget, gpointer data ){ +static void OnSelchangeZbuffer(ui::Widget widget, gpointer data ){ portals.zbuffer = gpointer_to_int( data ); Portals_shadersChanged(); SceneChangeNotify(); } -static void OnPoly( GtkWidget *widget, gpointer data ){ +static void OnPoly(ui::Widget widget, gpointer data ){ portals.polygons = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ); SceneChangeNotify(); } -static void OnLines( GtkWidget *widget, gpointer data ){ +static void OnLines(ui::Widget widget, gpointer data ){ portals.lines = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ); SceneChangeNotify(); } -static void OnClip( GtkWidget *widget, gpointer data ){ +static void OnClip(ui::Widget widget, gpointer data ){ portals.clip = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false; SceneChangeNotify(); diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index 890658e1..9ebcd69b 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -51,14 +51,13 @@ static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer return TRUE; } -static void change_clicked( GtkWidget *widget, gpointer data ){ - GtkWidget* file_sel; +static void change_clicked(ui::Widget widget, gpointer data ){ char* filename = NULL; - file_sel = gtk_file_chooser_dialog_new ( "Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, + auto file_sel = ui::Widget::from(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); + nullptr)); gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn ); diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 25ba558a..ac8233d1 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -73,7 +73,7 @@ char* itoa( int value, char* result, int base ){ #endif typedef struct _mapcoord_setting_packet { - GtkSpinButton *spinner1, *spinner2, *spinner3, *spinner4; + ui::SpinButton spinner1{ui::null}, spinner2{ui::null}, spinner3{ui::null}, spinner4{ui::null}; Entity* worldspawn; } mapcoord_setting_packet; @@ -114,7 +114,7 @@ Entity* Scene_FindEntityByClass( const char* name ){ // ** GTK callback functions ** // ************************** -static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){ +static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){ /* If you return FALSE in the "delete_event" signal handler, * GTK will emit the "destroy" signal. Returning TRUE means * you don't want the window to be destroyed. @@ -135,7 +135,7 @@ static void close_window( ui::Widget widget, gpointer data ){ } // callback function to assign the optimal mapcoords to the spinboxes -static void input_optimal( GtkWidget *widget, gpointer data ){ +static void input_optimal(ui::Widget widget, gpointer data ){ gtk_spin_button_set_value( msp.spinner1, minX ); gtk_spin_button_set_value( msp.spinner2, maxY ); gtk_spin_button_set_value( msp.spinner3, maxX ); @@ -143,7 +143,7 @@ static void input_optimal( GtkWidget *widget, gpointer data ){ } // Spinner return value function -gint grab_int_value( GtkSpinButton *a_spinner, gpointer user_data ) { +gint grab_int_value(ui::SpinButton a_spinner, gpointer user_data ) { return gtk_spin_button_get_value_as_int( a_spinner ); } @@ -372,7 +372,7 @@ void MapCoordinator(){ button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function vbox.pack_start( button, FALSE, FALSE, 2 ); // insert button into vbox - vbox.pack_start( ui::Widget(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox + vbox.pack_start( ui::Widget::from(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox auto table = ui::Table( 4, 3, TRUE ); // create table gtk_table_set_row_spacings(table, 8); // set row spacings diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index ea233fe7..39a983b6 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -32,7 +32,7 @@ * This is useful for popping up 'are you sure you want to quit?' * type dialogs. */ -static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){ +static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){ return FALSE; } diff --git a/libs/eclasslib.h b/libs/eclasslib.h index d2730d62..2a92fcdb 100644 --- a/libs/eclasslib.h +++ b/libs/eclasslib.h @@ -38,8 +38,8 @@ typedef Vector3 Colour3; class ListAttributeType { -typedef std::pair ListItem; -typedef std::vector ListItems; +using ListItem = std::pair; +using ListItems = std::vector; ListItems m_items; public: diff --git a/libs/gtkutil/accelerator.cpp b/libs/gtkutil/accelerator.cpp index 6b66288f..414a8eac 100644 --- a/libs/gtkutil/accelerator.cpp +++ b/libs/gtkutil/accelerator.cpp @@ -186,8 +186,8 @@ bool global_accel_enabled(){ } -GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback& callback ); -void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator ); +GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback& callback ); +void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator ); AcceleratorMap g_queuedAcceleratorsAdd; AcceleratorSet g_queuedAcceleratorsRemove; @@ -284,21 +284,21 @@ struct PressedButtons } }; -gboolean PressedButtons_button_press( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){ +gboolean PressedButtons_button_press(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){ if ( event->type == GDK_BUTTON_PRESS ) { return Buttons_press( pressed->buttons, event->button, event->state ); } return FALSE; } -gboolean PressedButtons_button_release( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){ +gboolean PressedButtons_button_release(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){ if ( event->type == GDK_BUTTON_RELEASE ) { return Buttons_release( pressed->buttons, event->button, event->state ); } return FALSE; } -gboolean PressedButtons_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedButtons* pressed ){ +gboolean PressedButtons_focus_out(ui::Widget widget, GdkEventFocus* event, PressedButtons* pressed ){ Buttons_releaseAll( pressed->buttons ); return FALSE; } @@ -350,22 +350,22 @@ void Keys_releaseAll( PressedKeys::Keys& keys, guint state ){ keys.clear(); } -gboolean PressedKeys_key_press( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){ +gboolean PressedKeys_key_press(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){ //globalOutputStream() << "pressed: " << event->keyval << "\n"; return event->state == 0 && Keys_press( pressedKeys->keys, event->keyval ); } -gboolean PressedKeys_key_release( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){ +gboolean PressedKeys_key_release(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){ //globalOutputStream() << "released: " << event->keyval << "\n"; return Keys_release( pressedKeys->keys, event->keyval ); } -gboolean PressedKeys_focus_in( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){ +gboolean PressedKeys_focus_in(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){ ++pressedKeys->refcount; return FALSE; } -gboolean PressedKeys_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){ +gboolean PressedKeys_focus_out(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){ if ( --pressedKeys->refcount == 0 ) { Keys_releaseAll( pressedKeys->keys, 0 ); } @@ -438,12 +438,12 @@ void keyup_accelerators_remove( Accelerator accelerator ){ } -gboolean accel_closure_callback( GtkAccelGroup* group, GtkWidget* widget, guint key, GdkModifierType modifiers, gpointer data ){ +gboolean accel_closure_callback(ui::AccelGroup group, ui::Widget widget, guint key, GdkModifierType modifiers, gpointer data ){ ( *reinterpret_cast*>( data ) )( ); return TRUE; } -GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback& callback ){ +GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback& callback ){ if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) { //globalOutputStream() << "global_accel_connect: " << makeQuoted(accelerator) << "\n"; GClosure* closure = create_cclosure( G_CALLBACK( accel_closure_callback ), callback ); @@ -457,7 +457,7 @@ GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator acceler } } -void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator ){ +void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator ){ if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) { //globalOutputStream() << "global_accel_disconnect: " << makeQuoted(accelerator) << "\n"; gtk_accel_group_disconnect_key( group, accelerator.key, accelerator.modifiers ); diff --git a/libs/gtkutil/button.cpp b/libs/gtkutil/button.cpp index 929a62a0..9f40f9e9 100644 --- a/libs/gtkutil/button.cpp +++ b/libs/gtkutil/button.cpp @@ -105,9 +105,9 @@ void radio_button_print_state( ui::RadioButton button ){ globalOutputStream() << "\n"; } -GtkToggleButton* radio_button_get_nth( ui::RadioButton radio, int index ){ +ui::ToggleButton radio_button_get_nth( ui::RadioButton radio, int index ){ GSList *group = gtk_radio_button_get_group( radio ); - return GTK_TOGGLE_BUTTON( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) ); + return ui::ToggleButton::from( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) ); } void radio_button_set_active( ui::RadioButton radio, int index ){ diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index baee2f69..fddf060e 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -183,7 +183,7 @@ RadioHBox RadioHBox_new( StringArrayRange names ){ auto radio = ui::RadioButton(ui::null); for ( StringArrayRange::Iterator i = names.first; i != names.last; ++i ) { - radio = ui::RadioButton(GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) )); + radio = ui::RadioButton::from( gtk_radio_button_new_with_label( group, *i ) ); radio.show(); hbox.pack_start( radio, FALSE, FALSE, 0 ); diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 20a82f30..52cec49c 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -276,7 +276,7 @@ bool glwidget_enable_gl(ui::GLArea self, ui::Widget root, gpointer data) ui::GLArea glwidget_new(bool zbuffer) { - auto self = ui::GLArea(GTK_DRAWING_AREA(gtk_drawing_area_new())); + auto self = ui::GLArea::from(gtk_drawing_area_new()); g_object_set_data(G_OBJECT(self), "zbuffer", gint_to_pointer(zbuffer)); diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index 4164f031..210b055c 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -53,18 +53,18 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ ui::Image image_new_from_file_with_mask( const char* filename ){ GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename ); if ( rgba == 0 ) { - return ui::Image(0); + return ui::Image(ui::null); } else { - auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) )); + auto image = ui::Image::from( gtk_image_new_from_pixbuf( rgba ) ); g_object_unref( rgba ); return image; } } ui::Image image_new_missing(){ - return ui::Image(GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) )); + return ui::Image::from( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); } ui::Image new_image( const char* filename ){ diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index 9d47642e..2a8c55fb 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -38,7 +38,7 @@ void menu_add_item( ui::Menu menu, ui::MenuItem item ){ } ui::MenuItem menu_separator( ui::Menu menu ){ - auto menu_item = ui::MenuItem(GTK_MENU_ITEM( gtk_menu_item_new() )); + auto menu_item = ui::MenuItem::from( gtk_menu_item_new() ); menu.add(menu_item); gtk_widget_set_sensitive( menu_item , FALSE ); menu_item.show(); @@ -46,7 +46,7 @@ ui::MenuItem menu_separator( ui::Menu menu ){ } ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){ - auto menu_item = ui::TearoffMenuItem(GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() )); + auto menu_item = ui::TearoffMenuItem::from( gtk_tearoff_menu_item_new() ); menu.add(menu_item); // gtk_widget_set_sensitive(menu_item, FALSE); -- controls whether menu is detachable menu_item.show(); @@ -66,15 +66,15 @@ ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ){ ui::Menu create_sub_menu_with_mnemonic( ui::MenuShell parent, const char* mnemonic ){ auto item = new_sub_menu_item_with_mnemonic( mnemonic ); parent.add(item); - return ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( item ) )); + return ui::Menu::from( gtk_menu_item_get_submenu( item ) ); } ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( ui::MenuShell(GTK_MENU_SHELL( bar )), mnemonic ); + return create_sub_menu_with_mnemonic( ui::MenuShell::from( bar._handle ), mnemonic ); } ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( ui::MenuShell(GTK_MENU_SHELL( parent )), mnemonic ); + return create_sub_menu_with_mnemonic( ui::MenuShell::from( parent._handle ), mnemonic ); } void activate_closure_callback( ui::Widget widget, gpointer data ){ @@ -113,7 +113,7 @@ ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic } ui::CheckMenuItem new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback& callback ){ - auto item = ui::CheckMenuItem(GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) )); + auto item = ui::CheckMenuItem::from( gtk_check_menu_item_new_with_mnemonic( mnemonic ) ); item.show(); check_menu_item_connect_callback( item, callback ); return item; @@ -126,7 +126,7 @@ ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const cha } ui::RadioMenuItem new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){ - auto item = ui::RadioMenuItem(GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) )); + auto item = ui::RadioMenuItem::from( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) ); if ( *group == 0 ) { gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE ); } @@ -238,15 +238,14 @@ ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic return item; } -void check_menu_item_set_active_callback( GtkCheckMenuItem &item, bool enabled ){ - check_menu_item_set_active_no_signal( ui::CheckMenuItem(&item), enabled ); +void check_menu_item_set_active_callback(void *it, bool enabled ){ + auto item = ui::CheckMenuItem::from(it); + check_menu_item_set_active_no_signal( item, enabled ); } -typedef ReferenceCaller CheckMenuItemSetActiveCaller; ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle ){ auto item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback ); menu_item_add_accelerator( item, toggle.m_command.m_accelerator ); - GtkCheckMenuItem *item_ = item; - toggle.m_exportCallback( CheckMenuItemSetActiveCaller( *item_ ) ); + toggle.m_exportCallback( PointerCaller( item._handle ) ); return item; } diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 56b40131..82d6dfe4 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -80,7 +80,7 @@ EMessageBoxReturn gtk_MessageBox( ui::Window parentWindow, const char* text, con auto iconBox = create_dialog_hbox( 16, 0 ); hboxDummy.pack_start( iconBox, FALSE, FALSE, 0 ); - auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) )); + auto image = ui::Image::from( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) ); image.show(); iconBox.pack_start( image, FALSE, FALSE, 0 ); diff --git a/libs/gtkutil/nonmodal.cpp b/libs/gtkutil/nonmodal.cpp index 049c62c0..f9da2dbf 100644 --- a/libs/gtkutil/nonmodal.cpp +++ b/libs/gtkutil/nonmodal.cpp @@ -96,7 +96,7 @@ gboolean NonModalSpinner::escape(ui::SpinButton spin, GdkEventKey *event, NonMod void NonModalSpinner::connect(ui::SpinButton spin) { - auto adj = ui::Adjustment(gtk_spin_button_get_adjustment(spin)); + auto adj = ui::Adjustment::from(gtk_spin_button_get_adjustment(spin)); guint handler = adj.connect("value_changed", G_CALLBACK(changed), this); g_object_set_data(G_OBJECT(spin), "handler", gint_to_pointer(handler)); spin.connect("key_press_event", G_CALLBACK(enter), this); @@ -107,6 +107,6 @@ void NonModalRadio::connect(ui::RadioButton radio) { GSList *group = gtk_radio_button_get_group(radio); for (; group != 0; group = g_slist_next(group)) { - toggle_button_connect_callback(ui::ToggleButton(GTK_TOGGLE_BUTTON(group->data)), m_changed); + toggle_button_connect_callback(ui::ToggleButton::from(group->data), m_changed); } } diff --git a/libs/gtkutil/paned.cpp b/libs/gtkutil/paned.cpp index 1aeec45c..4f724eef 100644 --- a/libs/gtkutil/paned.cpp +++ b/libs/gtkutil/paned.cpp @@ -34,7 +34,7 @@ float position; int size; }; -gboolean hpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){ +gboolean hpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){ if ( paned->size != allocation->width ) { paned->size = allocation->width; gtk_paned_set_position( GTK_PANED( widget ), static_cast( paned->size * paned->position ) ); @@ -42,7 +42,7 @@ gboolean hpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedSta return FALSE; } -gboolean vpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){ +gboolean vpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){ if ( paned->size != allocation->height ) { paned->size = allocation->height; gtk_paned_set_position( GTK_PANED( widget ), static_cast( paned->size * paned->position ) ); @@ -50,7 +50,7 @@ gboolean vpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedSta return FALSE; } -gboolean paned_position( GtkWidget* widget, gpointer dummy, PanedState* paned ){ +gboolean paned_position(ui::Widget widget, gpointer dummy, PanedState* paned ){ if ( paned->size != -1 ) { paned->position = gtk_paned_get_position( GTK_PANED( widget ) ) / static_cast( paned->size ); } diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 87651466..7ff7f9a8 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -38,14 +38,14 @@ void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* descr } ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ - auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(new_local_image(icon), nullptr))); + auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr)); button_connect_callback(button, callback); toolbar_append(toolbar, button, description); return button; } ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ - auto button = ui::ToggleToolButton(GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new())); + auto button = ui::ToggleToolButton::from(gtk_toggle_tool_button_new()); toggle_button_connect_callback(button, callback); gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), new_local_image(icon)); gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description); @@ -57,14 +57,13 @@ ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* descripti return toolbar_append_button( toolbar, description, icon, command.m_callback ); } -void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){ - toggle_button_set_active_no_signal( ui::ToggleToolButton(&button), active ); +void toggle_button_set_active_callback(ui::ToggleToolButton& button, bool active ){ + toggle_button_set_active_no_signal( button, active ); } -using ToggleButtonSetActiveCaller = ReferenceCaller; +using ToggleButtonSetActiveCaller = ReferenceCaller; ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ){ auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback ); - GtkToggleToolButton *button_ = button; - toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button_ ) ); + toggle.m_exportCallback( ToggleButtonSetActiveCaller( button ) ); return button; } diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index 52b7d9c4..28395b35 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -70,7 +70,7 @@ public: ToggleItem m_item; ToggleShown(bool shown) - : m_shownDeferred(shown), m_widget(0), m_item(ActiveCaller(*this)) + : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this)) { } diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index e4fb3d32..1b192291 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -39,7 +39,7 @@ namespace ui { Widget root{ui::null}; #define IMPL(T, F) template<> _IMPL(T, F) -#define _IMPL(T, F) struct verify { using self = T; static self test(self it) { return self(F(it)); } } +#define _IMPL(T, F) struct verify { using self = T; static self test(self it) { return self::from(F(it)); } } template struct verify; @@ -196,7 +196,7 @@ namespace ui { delete data; }; auto func = [](_GtkWidget *widget, GdkEventKey *event, user_data *args) -> bool { - return args->f(Widget(widget), event, args->extra); + return args->f(Widget::from(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); @@ -448,6 +448,16 @@ namespace ui { // Custom +#if GTK_TARGET == 3 + + IMPL(GLArea, (void *)); + +#elif GTK_TARGET == 2 + + IMPL(GLArea, GTK_DRAWING_AREA); + +#endif + guint IGLArea::on_render(GCallback pFunction, void *data) { #if GTK_TARGET == 3 diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index f873939f..7409913b 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -212,9 +212,12 @@ namespace ui { public: \ using self = name *; \ using native = T *; \ + protected: \ explicit name(native h) : super(reinterpret_cast(h)) {} \ + public: \ explicit name(Null n) : name((native) nullptr) {} \ explicit name(New_t); \ + static name from(native h) { return name(h); } \ static name from(void *ptr) { return name((native) ptr); } \ ctors \ }; \ @@ -613,7 +616,7 @@ namespace ui { GtkCallback cb = [](_GtkWidget *widget, void *data) -> void { using Function = typename std::decay::type; Function *f = static_cast(data); - (*f)(Widget(widget)); + (*f)(Widget::from(widget)); }; gtk_container_foreach(this, cb, &lambda); } diff --git a/radiant/build.cpp b/radiant/build.cpp index 47d8fff4..6462e382 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -657,7 +657,7 @@ ProjectList( Project& project ) : m_project( project ), m_changed( false ){ } }; -gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){ +gboolean project_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){ Project& project = projectList->m_project; auto path = ui::TreePath( path_string ); @@ -699,7 +699,7 @@ gboolean project_key_press( ui::TreeView widget, GdkEventKey* event, ProjectList Project& project = projectList->m_project; if ( event->keyval == GDK_KEY_Delete ) { - auto selection = ui::TreeSelection(gtk_tree_view_get_selection(widget)); + auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(widget)); GtkTreeIter iter; GtkTreeModel* model; if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) { @@ -757,7 +757,7 @@ gboolean project_selection_changed( ui::TreeSelection selection, ui::ListStore s return FALSE; } -gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ui::ListStore store ){ +gboolean commands_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ui::ListStore store ){ if ( g_current_build == 0 ) { return FALSE; } @@ -838,8 +838,8 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi vbox.pack_start( button, FALSE, FALSE, 0 ); } } - auto buildViewStore = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - auto buildView = ui::TreeView( ui::TreeModel( buildViewStore )); + auto buildViewStore = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING )); + auto buildView = ui::TreeView( ui::TreeModel::from( buildViewStore._handle )); { auto frame = create_dialog_frame( "Build menu" ); table1.attach(frame, {0, 1, 0, 1}); @@ -881,9 +881,9 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi frame.add(scr); { - auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + auto store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING )); - auto view = ui::TreeView(ui::TreeModel( store )); + auto view = ui::TreeView(ui::TreeModel::from( store._handle )); gtk_tree_view_set_headers_visible(view, FALSE ); auto renderer = ui::CellRendererText(ui::New); @@ -904,7 +904,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store ); - auto sel = ui::TreeSelection(gtk_tree_view_get_selection(buildView )); + auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(buildView )); sel.connect( "changed", G_CALLBACK( project_selection_changed ), store ); } } diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 93823894..f5148e09 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -161,7 +161,7 @@ void connect_accelerator( const char *name ){ struct command_list_dialog_t : public ModalDialog { command_list_dialog_t() - : m_close_button( *this, eIDCANCEL ), m_list( NULL ), m_command_iter(), m_model( NULL ), m_waiting_for_key( false ){ + : m_close_button( *this, eIDCANCEL ), m_list( ui::null ), m_command_iter(), m_model( ui::null ), m_waiting_for_key( false ){ } ModalDialogButton m_close_button; @@ -220,7 +220,7 @@ void accelerator_edit_button_clicked( ui::Button btn, gpointer dialogptr ){ return; } dialog.m_command_iter = iter; - dialog.m_model = ui::TreeModel(model); + dialog.m_model = ui::TreeModel::from(model); // 2. disallow changing the row //gtk_widget_set_sensitive(dialog.m_list, false); @@ -403,9 +403,9 @@ void DoCommandListDlg(){ hbox.pack_start( scr, TRUE, TRUE, 0 ); { - ui::ListStore store = ui::ListStore(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT )); + auto store = ui::ListStore::from(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT )); - auto view = ui::TreeView(ui::TreeModel(store)); + auto view = ui::TreeView(ui::TreeModel::from(store._handle)); dialog.m_list = view; gtk_tree_view_set_enable_search(view, false ); // annoying diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index e32f81c8..1c628ff1 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -264,13 +264,13 @@ void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property< struct Wrapper { static void Export(const native &self, const Callback &returnz) { native *p = &const_cast(self); - auto widget = Self(p); + auto widget = Self::from(p); Widget::Get::thunk_(widget, returnz); } static void Import(native &self, T value) { native *p = &self; - auto widget = Self(p); + auto widget = Self::from(p); Widget::Set::thunk_(widget, value); } }; @@ -288,7 +288,7 @@ void AddData(DialogDataList &self, typename Widget::Type widget, D &data) { // ============================================================================= // Dialog class -Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){ +Dialog::Dialog() : m_window( ui::null ), m_parent( ui::null ){ } Dialog::~Dialog(){ @@ -553,7 +553,7 @@ void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange ic image.show(); table.attach(image, {pos, pos + 1, 0, 1}, {0, 0}); - radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group ))); + radio = ui::RadioButton::from(gtk_radio_button_new( group )); radio.show(); table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0}); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 65b69327..b91d14cc 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -660,7 +660,7 @@ const ListAttributeType& m_type; public: ListAttribute( const char* key, const ListAttributeType& type ) : m_key( key ), - m_combo( 0 ), + m_combo( ui::null ), m_nonModal( ApplyCaller( *this ) ), m_type( type ){ auto combo = ui::ComboBoxText(ui::New); @@ -858,12 +858,12 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - auto widget = ui::CheckButton(g_entitySpawnflagsCheck[i]); - auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))); + auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i]); + auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget))); label.text(" "); widget.hide(); widget.ref(); - ui::Container(GTK_CONTAINER(g_spawnflagsTable)).remove(widget); + g_spawnflagsTable.remove(widget); } } @@ -872,7 +872,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for (unsigned int i = 0; (int) i < g_spawnflag_count; ++i) { - auto widget = ui::CheckButton(g_entitySpawnflagsCheck[i] ); + auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i] ); widget.show(); StringOutputStream str( 16 ); @@ -881,7 +881,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ g_spawnflagsTable.attach(widget, {i % 4, i % 4 + 1, i / 4, i / 4 + 1}, {GTK_FILL, GTK_FILL}); widget.unref(); - auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)) )); + auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)) ); label.text(str.c_str()); } } @@ -987,14 +987,14 @@ void EntityInspector_updateSpawnflags(){ { int v = !!( f & ( 1 << spawn_table[i] ) ); - toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), v ); + toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), v ); } } { // take care of the remaining ones for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i ) { - toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), FALSE ); + toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), FALSE ); } } } @@ -1314,9 +1314,9 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); + ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); - auto view = ui::TreeView( ui::TreeModel(store )); + auto view = ui::TreeView( ui::TreeModel::from( store._handle )); gtk_tree_view_set_enable_search(view, FALSE ); gtk_tree_view_set_headers_visible( view, FALSE ); view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 ); @@ -1329,7 +1329,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ } { - auto selection = ui::TreeSelection(gtk_tree_view_get_selection( view )); + auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection( view )); selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 ); } @@ -1398,9 +1398,9 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); + ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - auto view = ui::TreeView(ui::TreeModel(store )); + auto view = ui::TreeView(ui::TreeModel::from(store._handle)); gtk_tree_view_set_enable_search(view, FALSE ); gtk_tree_view_set_headers_visible(view, FALSE ); @@ -1417,7 +1417,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ } { - auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view )); + auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view)); selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 ); } @@ -1497,7 +1497,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ scr.show(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - auto viewport = ui::Container(GTK_CONTAINER(gtk_viewport_new( 0, 0 ))); + auto viewport = ui::Container::from(gtk_viewport_new( 0, 0 )); viewport.show(); gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE ); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 877eba23..0230fe6d 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -67,7 +67,7 @@ bool m_selection_disabled; EntityList() : m_dirty( EntityList::eDefault ), m_idleDraw( RedrawEntityListCaller() ), - m_window( 0 ), + m_window( ui::null ), m_selection_disabled( false ){ } @@ -107,7 +107,7 @@ inline void gtk_tree_model_get_pointer( ui::TreeModel model, GtkTreeIter* iter, -void entitylist_treeviewcolumn_celldatafunc( ui::TreeViewColumn column, GtkCellRenderer* renderer, ui::TreeModel model, GtkTreeIter* iter, gpointer data ){ +void entitylist_treeviewcolumn_celldatafunc( ui::TreeViewColumn column, ui::CellRenderer renderer, ui::TreeModel model, GtkTreeIter* iter, gpointer data ){ scene::Node* node; gtk_tree_model_get_pointer( model, iter, 0, &node ); scene::Instance* instance; @@ -177,7 +177,7 @@ void EntityList_DisconnectSignals( ui::TreeView view ){ gboolean treemodel_update_selection( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, gpointer data ){ - auto view = reinterpret_cast( data ); + auto view = ui::TreeView::from( data ); scene::Instance* instance; gtk_tree_model_get_pointer( model, iter, 1, &instance ); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 7dc70d98..33f6552b 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -298,9 +298,9 @@ ui::Window CDbgDlg::BuildDialog(){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING )); - auto view = ui::TreeView(ui::TreeModel(store )); + auto view = ui::TreeView(ui::TreeModel::from(store._handle)); gtk_tree_view_set_headers_visible(view, FALSE ); { @@ -310,7 +310,7 @@ ui::Window CDbgDlg::BuildDialog(){ } { - auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view )); + auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view )); gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE ); selection.connect( "changed", G_CALLBACK( feedback_selection_changed ), NULL ); } diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index f6847dd9..1be74bf7 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -87,7 +87,7 @@ static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_nu return FALSE; } -GroupDlg::GroupDlg() : m_window( 0 ){ +GroupDlg::GroupDlg() : m_window( ui::null ){ m_position_tracker.setPosition( c_default_window_pos ); } @@ -112,7 +112,7 @@ void GroupDlg::Create( ui::Window parent ){ m_position_tracker.connect( window ); { - ui::Widget notebook = ui::Widget(gtk_notebook_new()); + ui::Widget notebook = ui::Widget::from(gtk_notebook_new()); notebook.show(); window.add(notebook); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); @@ -126,7 +126,7 @@ void GroupDlg::Create( ui::Window parent ){ ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback &)>& title ){ ui::Widget w = ui::Label( tabLabel ); w.show(); - 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 ) )); + auto page = ui::Widget::from(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; @@ -161,7 +161,7 @@ void GroupDialog_show(){ } ui::Widget GroupDialog_getPage(){ - return ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) )); + return ui::Widget::from(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) )); } void GroupDialog_setPage( ui::Widget page ){ diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index d88431bd..1bb44cf1 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -353,13 +353,13 @@ void DoProjectSettings(){ void DoSides( int type, int axis ){ ModalDialog dialog; - GtkEntry* sides_entry; auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); auto accel = ui::AccelGroup(ui::New); window.add_accel_group( accel ); + auto sides_entry = ui::Entry(ui::New); { auto hbox = create_dialog_hbox( 4, 4 ); window.add(hbox); @@ -369,10 +369,9 @@ void DoSides( int type, int axis ){ hbox.pack_start( label, FALSE, FALSE, 0 ); } { - auto entry = ui::Entry(ui::New); + auto entry = sides_entry; entry.show(); hbox.pack_start( entry, FALSE, FALSE, 0 ); - sides_entry = entry; gtk_widget_grab_focus( entry ); } { @@ -883,7 +882,6 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){ ModalDialog dialog; - GtkEntry* textentry; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); @@ -892,6 +890,7 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){ auto accel_group = ui::AccelGroup(ui::New); window.add_accel_group( accel_group ); + auto textentry = ui::Entry(ui::New); { auto hbox = create_dialog_hbox( 4, 4 ); window.add(hbox); @@ -905,13 +904,11 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){ vbox.pack_start( label, FALSE, FALSE, 0 ); } { - auto entry = ui::Entry(ui::New); + auto entry = textentry; entry.show(); vbox.pack_start( entry, TRUE, TRUE, 0 ); gtk_widget_grab_focus( entry ); - - textentry = entry; } } { diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index aa334a1c..85554502 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -106,8 +106,8 @@ bool color_dialog( ui::Window parent, Vector3& color, const char* title ){ dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); GtkWidget *ok_button, *cancel_button; g_object_get(G_OBJECT(dlg), "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); - ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); - ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); + ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); + ui::Widget::from(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); if ( parent ) { gtk_window_set_transient_for( dlg, parent ); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index a569ea75..39db3b90 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -889,7 +889,7 @@ ColoursMenu g_ColoursMenu; ui::MenuItem create_colours_menu(){ auto colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); - auto menu_in_menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) )); + auto menu_in_menu = ui::Menu::from( gtk_menu_item_get_submenu( colours_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1782,7 +1782,7 @@ LatchedValue g_Layout_enablePluginToolbar( true, "Plugin Toolbar" ); ui::MenuItem create_file_menu(){ // File menu auto file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( file_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1822,7 +1822,7 @@ ui::MenuItem create_file_menu(){ ui::MenuItem create_edit_menu(){ // Edit menu auto edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( edit_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1879,7 +1879,7 @@ ui::Widget g_toggle_entitylist_item{ui::null}; ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){ // View menu auto view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( view_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1993,7 +1993,7 @@ ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){ ui::MenuItem create_selection_menu(){ // Selection menu auto selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( selection_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2048,7 +2048,7 @@ ui::MenuItem create_selection_menu(){ ui::MenuItem create_bsp_menu(){ // BSP menu auto bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( bsp_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2068,7 +2068,7 @@ ui::MenuItem create_bsp_menu(){ ui::MenuItem create_grid_menu(){ // Grid menu auto grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( grid_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2081,7 +2081,7 @@ ui::MenuItem create_grid_menu(){ ui::MenuItem create_misc_menu(){ // Misc menu auto misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( misc_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2102,7 +2102,7 @@ ui::MenuItem create_misc_menu(){ ui::MenuItem create_entity_menu(){ // Brush menu auto entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( entity_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2115,7 +2115,7 @@ ui::MenuItem create_entity_menu(){ ui::MenuItem create_brush_menu(){ // Brush menu auto brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( brush_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2128,7 +2128,7 @@ ui::MenuItem create_brush_menu(){ ui::MenuItem create_patch_menu(){ // Curve menu auto patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( patch_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2141,7 +2141,7 @@ ui::MenuItem create_patch_menu(){ ui::MenuItem create_help_menu(){ // Help menu auto help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( help_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2160,7 +2160,7 @@ ui::MenuItem create_help_menu(){ } ui::MenuBar create_main_menu( MainFrame::EViewStyle style ){ - auto menu_bar = ui::MenuBar(GTK_MENU_BAR( gtk_menu_bar_new() )); + auto menu_bar = ui::MenuBar::from( gtk_menu_bar_new() ); menu_bar.show(); menu_bar.add(create_file_menu()); @@ -2307,14 +2307,14 @@ void Manipulators_constructToolbar( ui::Toolbar toolbar ){ } ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){ - auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() )); + auto toolbar = ui::Toolbar::from( gtk_toolbar_new() ); gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); toolbar.show(); auto space = [&]() { - auto btn = ui::ToolItem(gtk_separator_tool_item_new()); + auto btn = ui::ToolItem::from(gtk_separator_tool_item_new()); btn.show(); toolbar.add(btn); }; diff --git a/radiant/map.cpp b/radiant/map.cpp index 3275184b..30364b27 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -833,9 +833,9 @@ void DoMapInfo(){ vbox.pack_start( scr, TRUE, TRUE, 0 ); { - ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); + auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - auto view = ui::TreeView(ui::TreeModel(store )); + auto view = ui::TreeView(ui::TreeModel::from(store._handle)); gtk_tree_view_set_headers_clickable(view, TRUE ); { diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 9a4a1d75..37fd9a17 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -120,8 +120,8 @@ void MRU_AddFile( const char *str ){ MRU_SetText( i, MRU_GetText( i - 1 ) ); MRU_SetText( 0, str ); - gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]) , TRUE ); - ui::MenuItem(MRU_items[MRU_used - 1] ).show(); + gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE ); + ui::MenuItem::from(MRU_items[MRU_used - 1] ).show(); } void MRU_Init(){ @@ -135,8 +135,8 @@ void MRU_AddWidget( ui::MenuItem widget, std::size_t pos ){ MRU_items[pos] = widget; if ( pos < MRU_used ) { MRU_updateWidget( pos, MRU_GetText( pos ) ); - gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]) , TRUE ); - ui::MenuItem(MRU_items[pos]).show(); + gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE ); + ui::MenuItem::from(MRU_items[pos]).show(); } } } @@ -159,13 +159,13 @@ void MRU_Activate( std::size_t index ){ MRU_SetText( i, MRU_GetText( i + 1 ) ); if ( MRU_used == 0 ) { - auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) )); + auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) ); label.text("Recent Files"); - gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]), FALSE ); + gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]), FALSE ); } else { - ui::MenuItem(MRU_items[MRU_used]).hide(); + ui::MenuItem::from(MRU_items[MRU_used]).hide(); } } } diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 6fbbe3e7..906c4708 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -151,7 +151,7 @@ public: ui::CheckButton m_enabled; ui::Entry m_horizontal; ui::Entry m_vertical; -Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( ui::null ), m_vertical( ui::null ){ +Subdivisions() : m_enabled( ui::null ), m_horizontal( ui::null ), m_vertical( ui::null ){ } void update(){ PatchFixedSubdivisions subdivisions; @@ -406,7 +406,7 @@ static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){ Patch_AutoCapTexture(); } -static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ +static void OnSpinChanged(ui::Adjustment adj, gpointer data ){ texdef_t td; td.rotate = 0; @@ -673,7 +673,7 @@ ui::Window PatchInspector::BuildDialog(){ table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); } { - auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() )); + auto check = ui::CheckButton::from( gtk_check_button_new() ); check.show(); table.attach(check, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); m_subdivisions.m_enabled = check; diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 60ee490f..bd9d378b 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -750,14 +750,13 @@ void Patch_constructMenu( ui::Menu menu ){ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols ){ ModalDialog dialog; - GtkComboBox* width; - GtkComboBox* height; ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog ); auto accel = ui::AccelGroup(ui::New); window.add_accel_group( accel ); - + auto width = ui::ComboBoxText(ui::New); + auto height = ui::ComboBoxText(ui::New); { auto hbox = create_dialog_hbox( 4, 4 ); window.add(hbox); @@ -778,7 +777,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, } { - auto combo = ui::ComboBoxText(ui::New); + auto combo = width; #define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, #x ) D_ITEM( 3 ); D_ITEM( 5 ); @@ -798,11 +797,9 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, #undef D_ITEM combo.show(); table.attach(combo, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); - - width = combo; } { - auto combo = ui::ComboBoxText(ui::New); + auto combo = height; #define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, #x ) D_ITEM( 3 ); D_ITEM( 5 ); @@ -822,8 +819,6 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, #undef D_ITEM combo.show(); table.attach(combo, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); - - height = combo; } } @@ -921,7 +916,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GSList* group = 0; { - ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" )); + ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Bevel" )); button.show(); table.attach(button, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0}); group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); @@ -929,7 +924,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ bevel = button; } { - ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" )); + ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Endcap" )); button.show(); table.attach(button, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0}); group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); @@ -937,7 +932,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ endcap = button; } { - ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" )); + ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Bevel" )); button.show(); table.attach(button, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}); group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); @@ -945,7 +940,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ibevel = button; } { - ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" )); + ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Endcap" )); button.show(); table.attach(button, {1, 2, 3, 4}, {GTK_FILL | GTK_EXPAND, 0}); group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); @@ -953,7 +948,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ iendcap = button; } { - ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" )); + ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Cylinder" )); button.show(); table.attach(button, {1, 2, 4, 5}, {GTK_FILL | GTK_EXPAND, 0}); group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 5d9dd652..8155d0a9 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -65,7 +65,7 @@ void PlugInMenu_Add( ui::Menu plugin_menu, IPlugIn* pPlugIn ){ if ( menuText != 0 && strlen( menuText ) > 0 ) { if ( !strcmp( menuText, "-" ) ) { - item = ui::Widget(gtk_menu_item_new()); + item = ui::Widget::from(gtk_menu_item_new()); gtk_widget_set_sensitive( item, FALSE ); } else if ( !strcmp( menuText, ">" ) ) { @@ -157,7 +157,7 @@ void PluginsMenu_clear(){ ui::MenuItem create_plugins_menu(){ // Plugins menu auto plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); - auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) )); + auto menu = ui::Menu::from( gtk_menu_item_get_submenu( plugins_menu_item ) ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } diff --git a/radiant/plugintoolbar.cpp b/radiant/plugintoolbar.cpp index a43fe989..aea1b321 100644 --- a/radiant/plugintoolbar.cpp +++ b/radiant/plugintoolbar.cpp @@ -57,13 +57,13 @@ ui::Image new_plugin_image( const char* filename ){ void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){ if (type == IToolbarButton::eSpace) { - auto it = ui::ToolItem(gtk_separator_tool_item_new()); + auto it = ui::ToolItem::from(gtk_separator_tool_item_new()); it.show(); toolbar.add(it); return; } if (type == IToolbarButton::eButton) { - auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(new_plugin_image(icon), text))); + auto button = ui::ToolButton::from(gtk_tool_button_new(new_plugin_image(icon), text)); gtk_widget_set_tooltip_text(button, tooltip); gtk_widget_show_all(button); button.connect("clicked", G_CALLBACK(handler), data); @@ -71,7 +71,7 @@ void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, co return; } if (type == IToolbarButton::eToggleButton) { - auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_toggle_tool_button_new())); + auto button = ui::ToolButton::from(gtk_toggle_tool_button_new()); gtk_tool_button_set_icon_widget(button, new_plugin_image(icon)); gtk_tool_button_set_label(button, text); gtk_widget_set_tooltip_text(button, tooltip); @@ -120,7 +120,7 @@ void PluginToolbar_clear(){ ui::Toolbar create_plugin_toolbar(){ - auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() )); + auto toolbar = ui::Toolbar::from( gtk_toolbar_new() ); gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); toolbar.show(); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index ea993de5..4c3e0e15 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -716,7 +716,7 @@ ui::Window PrefsDlg::BuildDialog(){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN ); // prefs pages notebook - m_notebook = ui::Widget(gtk_notebook_new()); + m_notebook = ui::Widget::from(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 ); hbox.pack_start( m_notebook, TRUE, TRUE, 0 ); @@ -724,9 +724,9 @@ ui::Window PrefsDlg::BuildDialog(){ { - auto store = ui::TreeStore(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); + auto store = ui::TreeStore::from(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); - auto view = ui::TreeView(ui::TreeModel(store)); + auto view = ui::TreeView(ui::TreeModel::from(store._handle)); gtk_tree_view_set_headers_visible(view, FALSE ); { @@ -736,7 +736,7 @@ ui::Window PrefsDlg::BuildDialog(){ } { - auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view )); + auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view)); selection.connect( "changed", G_CALLBACK( treeSelection ), this ); } diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 26389044..f4471578 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -122,7 +122,7 @@ float& m_f; public: ui::SpinButton m_spin; ui::Entry m_entry; -Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( ui::null ){ +Increment( float& f ) : m_f( f ), m_spin( ui::null ), m_entry( ui::null ){ } void cancel(){ entry_set_float( m_entry, m_f ); @@ -933,7 +933,7 @@ ui::Window SurfaceInspector::BuildDialog(){ } // not allowed to modify detail flag using Surface Inspector - gtk_widget_set_sensitive( ui::CheckButton(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE ); + gtk_widget_set_sensitive( ui::CheckButton::from(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE ); } } } @@ -1098,12 +1098,12 @@ void SurfaceInspector::Update(){ for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p ) { - toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); } for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p ) { - toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); } } } diff --git a/radiant/textureentry.cpp b/radiant/textureentry.cpp index 07fb0235..04512f6f 100644 --- a/radiant/textureentry.cpp +++ b/radiant/textureentry.cpp @@ -27,14 +27,14 @@ template void EntryCompletion::connect(ui::Entry entry) { if (!m_store) { - m_store = ui::ListStore(gtk_list_store_new(1, G_TYPE_STRING)); + m_store = ui::ListStore::from(gtk_list_store_new(1, G_TYPE_STRING)); fill(); StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate)); } - auto completion = ui::EntryCompletion(gtk_entry_completion_new()); + auto completion = ui::EntryCompletion::from(gtk_entry_completion_new()); gtk_entry_set_completion(entry, completion); gtk_entry_completion_set_model(completion, m_store); gtk_entry_completion_set_text_column(completion, 0); diff --git a/radiant/textureentry.h b/radiant/textureentry.h index a09ae154..ed2f9f5a 100644 --- a/radiant/textureentry.h +++ b/radiant/textureentry.h @@ -35,7 +35,7 @@ class EntryCompletion { ui::ListStore m_store; IdleDraw m_idleUpdate; public: - EntryCompletion() : m_store(0), m_idleUpdate(UpdateCaller(*this)) + EntryCompletion() : m_store(ui::null), m_idleUpdate(UpdateCaller(*this)) { } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 8a760e03..34a9f926 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -206,7 +206,7 @@ void value_changed( gdouble value ){ m_handler = g_idle_add( deferred_value_changed, this ); } } -static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){ +static void adjustment_value_changed(ui::Adjustment adjustment, DeferredAdjustment* self ){ self->value_changed( gtk_adjustment_get_value(adjustment) ); } }; @@ -347,7 +347,7 @@ int getTextureHeight( qtexture_t* tex ){ } TextureBrowser() : - m_texture_scroll( 0 ), + m_texture_scroll( ui::null ), m_hideunused_item( TextureBrowserHideUnusedExport() ), m_hidenotex_item( TextureBrowserFilterFallbackExport() ), m_showshaders_item( TextureBrowserShowShadersExport() ), @@ -1421,7 +1421,7 @@ void TextureBrowser_scrollChanged( void* data, gdouble value ){ TextureBrowser_setOriginY( *reinterpret_cast( data ), -(int)value ); } -static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){ +static void TextureBrowser_verticalScroll(ui::Adjustment adjustment, TextureBrowser* textureBrowser ){ textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) ); } @@ -1542,7 +1542,7 @@ TextureGroups TextureGroups_constructTreeView(){ void TextureBrowser_constructTreeStore(){ TextureGroups groups = TextureGroups_constructTreeView(); - auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING )); + auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING )); TextureGroups_constructTreeModel( groups, store ); gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTree, store); @@ -1552,7 +1552,7 @@ void TextureBrowser_constructTreeStore(){ void TextureBrowser_constructTreeStoreTags(){ TextureGroups groups; - auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING )); + auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING )); auto model = g_TextureBrowser.m_all_tags_list; gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTags, model ); @@ -1560,7 +1560,7 @@ void TextureBrowser_constructTreeStoreTags(){ g_object_unref( G_OBJECT( store ) ); } -void TreeView_onRowActivated( ui::TreeView treeview, GtkTreePath* path, ui::TreeViewColumn col, gpointer userdata ){ +void TreeView_onRowActivated( ui::TreeView treeview, ui::TreePath path, ui::TreeViewColumn col, gpointer userdata ){ GtkTreeIter iter; auto model = gtk_tree_view_get_model(treeview ); @@ -1734,7 +1734,7 @@ ui::MenuItem TextureBrowser_constructTagsMenu( ui::Menu menu ){ return textures_menu_item; } -gboolean TextureBrowser_tagMoveHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, GSList** selected ){ +gboolean TextureBrowser_tagMoveHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter iter, GSList** selected ){ g_assert( selected != NULL ); auto rowref = gtk_tree_row_reference_new( model, path ); @@ -1922,7 +1922,7 @@ void TextureBrowser_toggleSearchButton(){ } void TextureBrowser_constructTagNotebook(){ - g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new()); + g_TextureBrowser.m_tag_notebook = ui::Widget::from(gtk_notebook_new()); ui::Widget labelTags = ui::Label( "Tags" ); ui::Widget labelTextures = ui::Label( "Textures" ); @@ -1935,7 +1935,7 @@ void TextureBrowser_constructTagNotebook(){ } void TextureBrowser_constructSearchButton(){ - ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR )); + auto image = ui::Widget::from(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR )); g_TextureBrowser.m_search_button = ui::Button(ui::New); g_TextureBrowser.m_search_button.connect( "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags"); @@ -2011,7 +2011,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ ui::Widget menu_bar{ui::null}; { // menu bar - menu_bar = ui::Widget(gtk_menu_bar_new()); + menu_bar = ui::Widget::from(gtk_menu_bar_new()); auto menu_view = ui::Menu(ui::New); auto view_item = TextureBrowser_constructViewMenu( menu_view ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); @@ -2040,12 +2040,12 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ g_TextureBrowser.m_treeViewTree.show(); } { // gl_widget scrollbar - ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) )); + auto w = ui::Widget::from(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) )); table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL}); w.show(); g_TextureBrowser.m_texture_scroll = w; - auto vadjustment = ui::Adjustment(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) )); + auto vadjustment = ui::Adjustment::from(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) )); vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser ); g_TextureBrowser.m_texture_scroll.visible(g_TextureBrowser.m_showTextureScrollbar); @@ -2072,7 +2072,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ // tag stuff if ( g_TextureBrowser.m_tags ) { { // fill tag GtkListStore - g_TextureBrowser.m_all_tags_list = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); + g_TextureBrowser.m_all_tags_list = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); @@ -2126,14 +2126,14 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ 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 ); - g_TextureBrowser.m_assigned_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); + g_TextureBrowser.m_assigned_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_assigned_store )); + g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_assigned_store._handle)); g_TextureBrowser.m_assigned_store.unref(); g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); gtk_tree_view_set_headers_visible(g_TextureBrowser.m_assigned_tree, FALSE ); @@ -2155,13 +2155,13 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ 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 ); - g_TextureBrowser.m_available_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); + g_TextureBrowser.m_available_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_available_store )); + g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_available_store._handle)); g_TextureBrowser.m_available_store.unref(); g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); gtk_tree_view_set_headers_visible(g_TextureBrowser.m_available_tree, FALSE ); @@ -2181,8 +2181,8 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ { // tag arrow buttons auto m_btn_left = ui::Button(ui::New); auto m_btn_right = ui::Button(ui::New); - auto m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); - auto m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); + auto m_arrow_left = ui::Widget::from(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + auto m_arrow_right = ui::Widget::from(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); m_btn_left.add(m_arrow_left); m_btn_right.add(m_arrow_right); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 582d7105..bff13b36 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -792,7 +792,7 @@ XYWnd::XYWnd() : m_gl_widget( glwidget_new( FALSE ) ), m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ), m_deferred_motion( xywnd_motion, this ), - m_parent( 0 ), + m_parent( ui::null ), m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), m_chasemouse_handler( 0 ){