From: Thomas Debesse Date: Tue, 26 May 2020 13:46:36 +0000 (+0200) Subject: Merge commit 'c845c5cd8f427d39665d6a8b1f6eeff401370d80' into garux-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=87f4eea939309a5ea1972323e237d23afdf01104;p=xonotic%2Fnetradiant.git Merge commit 'c845c5cd8f427d39665d6a8b1f6eeff401370d80' into garux-merge --- 87f4eea939309a5ea1972323e237d23afdf01104 diff --cc contrib/bobtoolz/bobToolz-GTK.cpp index deb2ce5b,e11a6427..b012a4d5 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@@ -57,14 -59,14 +59,11 @@@ void BobToolz_destroy() } // plugin name -char* PLUGIN_NAME = "bobToolz"; +const char* PLUGIN_NAME = "bobToolz"; // commands in the menu -static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; - -// globals -GtkWidget *g_pRadiantWnd = NULL; +static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; - // globals - ui::Window g_pRadiantWnd{ui::null}; - static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n" "by digibob (digibob@splashdamage.com)\n" "http://www.splashdamage.com\n\n" diff --cc contrib/bobtoolz/bobToolz-GTK.h index 00000000,d10acc48..e7dcce25 mode 000000,100644..100644 --- a/contrib/bobtoolz/bobToolz-GTK.h +++ b/contrib/bobtoolz/bobToolz-GTK.h @@@ -1,0 -1,7 +1,8 @@@ - + #if !defined(INCLUDED_BOBTOOLZGTK_H) + #define INCLUDED_BOBTOOLZGTK_H + -extern GtkWidget *g_pRadiantWnd; ++#include ++ ++extern ui::Widget g_pRadiantWnd; + + #endif diff --cc contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 9329f306,a4a08b7a..ad444679 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@@ -209,11 -215,15 +211,12 @@@ EMessageBoxReturn DoMessageBox( const c EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); + gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); - gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); + gtk_window_set_title( window, lpCaption ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); @@@ -293,8 -311,8 +296,8 @@@ ret = eIDNO; } - gtk_window_set_position( window, GTK_WIN_POS_CENTER ); + gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT ); - gtk_widget_show( window ); + window.show(); gtk_grab_add( window ); while ( loop ) @@@ -403,13 -424,19 +406,14 @@@ EMessageBoxReturn DoPolygonBox( Polygon EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); + gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_window_set_title( window, "Polygon Builder" ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@@ -525,8 -552,9 +529,9 @@@ // ---- /vbox ---- - gtk_window_set_position( window, GTK_WIN_POS_CENTER ); + gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); - gtk_widget_show( window ); + window.show(); gtk_grab_add( window ); bool dialogError = TRUE; @@@ -1273,13 -1318,15 +1278,15 @@@ EMessageBoxReturn DoResetTextureBox( Re EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); + gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_window_set_title( window, "Texture Reset" ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@@ -1491,8 -1578,8 +1498,8 @@@ // ---- /vbox ---- - gtk_window_set_position( window, GTK_WIN_POS_CENTER ); + gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT ); - gtk_widget_show( window ); + window.show(); gtk_grab_add( window ); Update_TextureReseter(); diff --cc contrib/brushexport/interface.cpp index d464a02a,0342e246..ec661495 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@@ -7,43 -8,69 +8,44 @@@ #define GLADE_HOOKUP_OBJECT( component,widget,name ) \ g_object_set_data_full( G_OBJECT( component ), name, \ - gtk_widget_ref( widget ), (GDestroyNotify) gtk_widget_unref ) + g_object_ref( (void *) widget ), (GDestroyNotify) g_object_unref ) #define GLADE_HOOKUP_OBJECT_NO_REF( component,widget,name ) \ - g_object_set_data( G_OBJECT( component ), name, widget ) + g_object_set_data( G_OBJECT( component ), name, (void *) widget ) // created by glade -GtkWidget* -create_w_plugplug2( void ){ - GtkWidget *w_plugplug2; - GtkWidget *vbox1; - GtkWidget *hbox2; - GtkWidget *vbox4; - GtkWidget *r_collapse; +ui::Widget create_w_plugplug2( void ){ GSList *r_collapse_group = NULL; - GtkWidget *r_collapsebymaterial; - GtkWidget *r_nocollapse; - GtkWidget *vbox3; - GtkWidget *b_export; - GtkWidget *b_close; - GtkWidget *vbox2; - GtkWidget *label1; - GtkWidget *scrolledwindow1; - GtkWidget *t_materialist; - GtkWidget *ed_materialname; - GtkWidget *hbox1; - GtkWidget *b_addmaterial; - GtkWidget *b_removematerial; - GtkWidget *t_exportmaterials; - GtkWidget *t_limitmatnames; - GtkWidget *t_objects; - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new(); - - w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + + auto w_plugplug2 = ui::Window( ui::window_type::TOP ); gtk_widget_set_name( w_plugplug2, "w_plugplug2" ); - gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" ); + gtk_window_set_title( w_plugplug2, "BrushExport-Plugin 3.0 by namespace" ); - gtk_window_set_position( w_plugplug2, GTK_WIN_POS_CENTER ); + gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_transient_for( GTK_WINDOW( w_plugplug2 ), GTK_WINDOW( g_pRadiantWnd ) ); - gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE ); + gtk_window_set_destroy_with_parent( w_plugplug2, TRUE ); - vbox1 = gtk_vbox_new( FALSE, 0 ); + auto vbox1 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox1, "vbox1" ); - gtk_widget_show( vbox1 ); - gtk_container_add( GTK_CONTAINER( w_plugplug2 ), vbox1 ); + vbox1.show(); + w_plugplug2.add(vbox1); gtk_container_set_border_width( GTK_CONTAINER( vbox1 ), 5 ); - hbox2 = gtk_hbox_new( TRUE, 5 ); + auto hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_set_name( hbox2, "hbox2" ); - gtk_widget_show( hbox2 ); - gtk_box_pack_start( GTK_BOX( vbox1 ), hbox2, FALSE, FALSE, 0 ); + hbox2.show(); + vbox1.pack_start( hbox2, FALSE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 5 ); - vbox4 = gtk_vbox_new( TRUE, 0 ); + auto vbox4 = ui::VBox( TRUE, 0 ); gtk_widget_set_name( vbox4, "vbox4" ); - gtk_widget_show( vbox4 ); - gtk_box_pack_start( GTK_BOX( hbox2 ), vbox4, TRUE, FALSE, 0 ); + vbox4.show(); + hbox2.pack_start( vbox4, TRUE, FALSE, 0 ); - r_collapse = 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_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapse, "Collapse all brushes into a single group", "Collapse all brushes into a single group" ); - gtk_widget_show( r_collapse ); - gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapse, FALSE, FALSE, 0 ); + gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group"); + r_collapse.show(); + vbox4.pack_start( r_collapse, FALSE, FALSE, 0 ); 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 ) ); diff --cc contrib/brushexport/plugin.cpp index 2a221c71,58187871..77c54c7e --- a/contrib/brushexport/plugin.cpp +++ b/contrib/brushexport/plugin.cpp @@@ -47,13 -48,16 +47,16 @@@ void CreateWindow( void ) void DestroyWindow( void ); bool IsWindowOpen( void ); -GtkWidget *g_pRadiantWnd = NULL; ++ui::Widget g_pRadiantWnd{ui::null}; + namespace BrushExport { -GtkWindow* g_mainwnd; +ui::Window g_mainwnd{ui::null}; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = (GtkWindow*)pMainWidget; - g_pRadiantWnd = (GtkWidget*)pMainWidget; - ASSERT_NOTNULL( g_mainwnd ); + g_mainwnd = ui::Window::from(pMainWidget); ++ g_pRadiantWnd = ui::Window::from(pMainWidget); + ASSERT_TRUE( g_mainwnd ); return ""; } const char* getName(){ diff --cc contrib/brushexport/plugin.h index d924f647,a5e3f4c5..b0f4b058 --- a/contrib/brushexport/plugin.h +++ b/contrib/brushexport/plugin.h @@@ -22,4 -22,7 +22,8 @@@ #if !defined( INCLUDED_BRUSH_EXPORT_H ) #define INCLUDED_BRUSH_EXPORT_H -typedef struct _GtkWidget GtkWidget; -extern GtkWidget *g_pRadiantWnd; ++#include ++ ++extern ui::Widget g_pRadiantWnd; + #endif diff --cc contrib/gtkgensurf/plugin.cpp index 6acaa4b9,38a730da..928bd145 --- a/contrib/gtkgensurf/plugin.cpp +++ b/contrib/gtkgensurf/plugin.cpp @@@ -17,6 -17,6 +17,8 @@@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ++#include ++ #include "gensurf.h" // Global plugin FuncTable @@@ -32,7 -32,7 +34,7 @@@ bool g_bInitDone #include "iplugin.h" const char* QERPlug_Init( void* hApp, void* pMainWidget ){ -- g_pRadiantWnd = (GtkWidget*)pMainWidget; ++ g_pRadiantWnd = ui::Window::from(pMainWidget); return "GenSurf for Q3Radiant"; } diff --cc contrib/prtview/AboutDialog.cpp index f320de22,5713b162..2966d105 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@@ -46,48 -49,55 +46,51 @@@ static gint dialog_delete_callback( ui: } void DoAboutDlg(){ - GtkWidget *dlg, *hbox, *vbox, *button, *label; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window(ui::window_type::TOP); + gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE ); - gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); - g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); - g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - - hbox = gtk_hbox_new( FALSE, 10 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), hbox ); - gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 ); - - label = gtk_label_new( "Version 1.000\n\n" - "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n" - "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n" - "Built against NetRadiant " RADIANT_VERSION "\n" - __DATE__ - ); - gtk_widget_show( label ); - gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 ); - gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); - - vbox = gtk_vbox_new( FALSE, 0 ); - gtk_widget_show( vbox ); - gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 ); - - button = gtk_button_new_with_label( "OK" ); - gtk_widget_show( button ); - gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); - - gtk_grab_add( dlg ); - gtk_widget_show( dlg ); - - while ( loop ) + gtk_window_set_title(dlg, "About Portal Viewer"); + dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL); + dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL); + g_object_set_data(G_OBJECT(dlg), "loop", &loop); + g_object_set_data(G_OBJECT(dlg), "ret", &ret); + + auto hbox = ui::HBox(FALSE, 10); + hbox.show(); + dlg.add(hbox); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); + + char const *label_text = "Version 1.000\n\n" + "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n" + "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n" + "Built against NetRadiant " RADIANT_VERSION "\n" + __DATE__; + auto label = ui::Label(label_text); + label.show(); + hbox.pack_start( label, TRUE, TRUE, 0); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); + + auto vbox = ui::VBox(FALSE, 0); + vbox.show(); + hbox.pack_start( vbox, FALSE, FALSE, 0); + + auto button = ui::Button("OK"); + button.show(); + vbox.pack_start( button, FALSE, FALSE, 0); + button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK)); + button.dimensions(60, -1); + + gtk_grab_add(dlg); + dlg.show(); + + while (loop) gtk_main_iteration(); - gtk_grab_remove( dlg ); - gtk_widget_destroy( dlg ); + gtk_grab_remove(dlg); + dlg.destroy(); } diff --cc contrib/prtview/ConfigDialog.cpp index 1d7f2743,63080a2b..3b3e80c0 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@@ -50,23 -53,27 +50,27 @@@ static gint dialog_delete_callback( ui: // Color selection dialog static int DoColor( PackedColour *c ){ - GtkWidget* dlg; - double clr[4]; + GdkColor clr; int loop = 1, ret = IDCANCEL; - clr[0] = ( (double)GetRValue( *c ) ) / 255.0; - clr[1] = ( (double)GetGValue( *c ) ) / 255.0; - clr[2] = ( (double)GetBValue( *c ) ) / 255.0; + clr.red = (guint16) (GetRValue(*c) * (65535 / 255)); + clr.blue = (guint16) (GetGValue(*c) * (65535 / 255)); + clr.green = (guint16) (GetBValue(*c) * (65535 / 255)); + + auto dlg = ui::Widget::from(gtk_color_selection_dialog_new( "Choose Color" )); + - dlg = gtk_color_selection_dialog_new( "Choose Color" ); + gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE ); - gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); + dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); + + GtkWidget *ok_button, *cancel_button; + g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + + 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 ); @@@ -234,14 -241,23 +238,19 @@@ static void OnClip(ui::Widget widget, g } void DoConfigDialog(){ - GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame; - GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item; - GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck; - GtkWidget *transslider, *translabel, *clipslider, *cliplabel; - GtkWidget *show2check, *show3check, *portalcheck; int loop = 1, ret = IDCANCEL; - GtkObject *adj; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); ++ + gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE ); - gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); ++ + gtk_window_set_title( dlg, "Portal Viewer Configuration" ); + dlg.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); diff --cc contrib/prtview/LoadPortalFileDialog.cpp index 9ebcd69b,f2725838..2d6b4d75 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@@ -51,21 -54,51 +51,25 @@@ static gint dialog_delete_callback( ui: return TRUE; } -static void file_sel_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; - int *loop; - char **filename; - - parent = gtk_widget_get_toplevel( widget ); - loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); - filename = (char**)g_object_get_data( G_OBJECT( parent ), "filename" ); - - *loop = 0; - if ( gpointer_to_int( data ) == IDOK ) { - *filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( parent ) ) ); - } -} - -static void change_clicked( GtkWidget *widget, gpointer data ){ - GtkWidget* file_sel; +static void change_clicked(ui::Widget widget, gpointer data ){ char* filename = NULL; - int loop = 1; - file_sel = gtk_file_selection_new( "Locate portal (.prt) file" ); + 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)); + + gtk_window_set_transient_for( GTK_WINDOW( file_sel ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_position( GTK_WINDOW( file_sel ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( file_sel ), TRUE ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDCANCEL ) ); - gtk_signal_connect( GTK_OBJECT( file_sel ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION( file_sel ) ); - - g_object_set_data( G_OBJECT( file_sel ), "loop", &loop ); - g_object_set_data( G_OBJECT( file_sel ), "filename", &filename ); - gtk_file_selection_set_filename( GTK_FILE_SELECTION( file_sel ), portals.fn ); + - gtk_grab_add( file_sel ); - gtk_widget_show( file_sel ); - - while ( loop ) - gtk_main_iteration(); + gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn ); - gtk_grab_remove( file_sel ); - gtk_widget_destroy( file_sel ); + if (gtk_dialog_run (GTK_DIALOG (file_sel)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_sel)); + } + ui::Widget(file_sel).destroy(); if ( filename != NULL ) { strcpy( portals.fn, filename ); @@@ -75,14 -108,18 +79,19 @@@ } int DoLoadPortalFileDialog(){ - GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); ++ + gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE ); - gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); ++ + gtk_window_set_title( dlg, "Load .prt" ); + dlg.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); diff --cc contrib/prtview/prtview.cpp index 080af13a,2b3d9c04..fe6bf41a --- a/contrib/prtview/prtview.cpp +++ b/contrib/prtview/prtview.cpp @@@ -22,6 -22,6 +22,8 @@@ #include #include ++#include ++ #include "profile/profile.h" #include "qerplugin.h" @@@ -201,8 -201,10 +203,10 @@@ static const char *PLUGIN_COMMANDS Q3R_CMD_LOAD; -GtkWidget *g_pRadiantWnd = NULL; ++ui::Widget g_pRadiantWnd{ui::null}; const char* QERPlug_Init( void *hApp, void* pMainWidget ){ - g_pRadiantWnd = (GtkWidget*)pMainWidget; ++ g_pRadiantWnd = ui::Window::from(pMainWidget); return "Portal Viewer for Q3Radiant"; } diff --cc contrib/prtview/prtview.h index 6b048782,5b3734f5..96b77b5d --- a/contrib/prtview/prtview.h +++ b/contrib/prtview/prtview.h @@@ -20,16 -20,19 +20,19 @@@ #if !defined( INCLUDED_PRTVIEW_H ) #define INCLUDED_PRTVIEW_H ++#include ++ #define MSG_PREFIX "Portal Viewer plugin: " void InitInstance(); void SaveConfig(); -int INIGetInt( char *key, int def ); -void INISetInt( char *key, int val, char *comment = 0 ); - -typedef struct _GtkWidget GtkWidget; -extern GtkWidget *g_pRadiantWnd; +int INIGetInt( const char *key, int def ); +void INISetInt( const char *key, int val, const char *comment = 0 ); -#define IDOK 1 -#define IDCANCEL 2 ++extern ui::Widget g_pRadiantWnd; + +const int IDOK = 1; +const int IDCANCEL = 2; - #endif diff --cc radiant/camwindow.cpp index 358d1b51,45f59016..eafc1da0 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@@ -1911,32 -1954,33 +1955,33 @@@ void CameraSpeed_decrease() /// \brief Initialisation for things that have the same lifespan as this module. void CamWnd_Construct(){ - GlobalCommands_insert( "CenterView", FreeCaller(), Accelerator( GDK_End ) ); - GlobalCommands_insert( "CameraFocusOnSelected", FreeCaller(), Accelerator( GDK_Tab ) ); + GlobalCommands_insert( "CenterView", makeCallbackF(GlobalCamera_ResetAngles), Accelerator( GDK_KEY_End ) ); ++ GlobalCommands_insert( "CameraFocusOnSelected", makeCallbackF( GlobalCamera_FocusOnSelected ), Accelerator( GDK_Tab ) ); - GlobalToggles_insert( "ToggleCubicClip", FreeCaller(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "CubicClipZoomIn", FreeCaller(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "CubicClipZoomOut", FreeCaller(), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalToggles_insert( "ToggleCubicClip", makeCallbackF(Camera_ToggleFarClip), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CubicClipZoomIn", makeCallbackF(Camera_CubeIn), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CubicClipZoomOut", makeCallbackF(Camera_CubeOut), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "UpFloor", FreeCaller(), Accelerator( GDK_Prior ) ); - GlobalCommands_insert( "DownFloor", FreeCaller(), Accelerator( GDK_Next ) ); + GlobalCommands_insert( "UpFloor", makeCallbackF(Camera_ChangeFloorUp), Accelerator( GDK_KEY_Prior ) ); + GlobalCommands_insert( "DownFloor", makeCallbackF(Camera_ChangeFloorDown), Accelerator( GDK_KEY_Next ) ); GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); -// GlobalCommands_insert( "LookThroughSelected", FreeCaller() ); -// GlobalCommands_insert( "LookThroughCamera", FreeCaller() ); +// GlobalCommands_insert( "LookThroughSelected", makeCallbackF(GlobalCamera_LookThroughSelected) ); +// GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) ); if ( g_pGameDescription->mGameType == "doom3" ) { - GlobalCommands_insert( "TogglePreview", FreeCaller(), Accelerator( GDK_F3 ) ); + GlobalCommands_insert( "TogglePreview", makeCallbackF(CamWnd_TogglePreview), Accelerator( GDK_KEY_F3 ) ); } - GlobalCommands_insert( "CameraSpeedInc", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CameraSpeedDec", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedInc", makeCallbackF(CameraSpeed_increase), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedDec", makeCallbackF(CameraSpeed_decrease), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_Up ) ); - GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_Down ) ); - GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_Left ) ); - GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_Right ) ); - GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( 'D' ) ); - GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( 'A' ) ); + GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_KEY_Up ) ); + GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_KEY_Down ) ); + GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_KEY_Left ) ); + GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_KEY_Right ) ); + GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ) ); + GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ) ); GlobalShortcuts_insert( "CameraUp", accelerator_null() ); GlobalShortcuts_insert( "CameraDown", accelerator_null() ); diff --cc radiant/entity.cpp index d865161c,ff82b7ab..9f36b89c --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@@ -521,16 -512,7 +522,7 @@@ void Entity_setColour() g_entity_globals.color_entity = rgb; } } - - if ( g_pGameDescription->mGameType == "doom3" ) { - normalize = false; - } - - if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) { + if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) { - if ( normalize ) { - NormalizeColor( g_entity_globals.color_entity ); - } - char buffer[128]; sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], diff --cc radiant/mainframe.cpp index cf0525aa,8d07afe6..01399dfb --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -2208,9 -2060,12 +2209,12 @@@ ui::MenuItem create_selection_menu() create_menu_item_with_mnemonic( menu_in_menu, "Nudge Right", "SelectNudgeRight" ); create_menu_item_with_mnemonic( menu_in_menu, "Nudge Up", "SelectNudgeUp" ); create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" ); + menu_separator( menu_in_menu ); + create_menu_item_with_mnemonic( menu_in_menu, "Nudge +Z", "MoveSelectionUP" ); + create_menu_item_with_mnemonic( menu_in_menu, "Nudge -Z", "MoveSelectionDOWN" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@@ -2350,9 -2205,9 +2354,9 @@@ ui::MenuItem create_help_menu() // it will take care of hooking the Sys_OpenURL calls etc. create_game_help_menu( menu ); -// create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller() ); - create_menu_item_with_mnemonic( menu, "Shortcuts", FreeCaller() ); - create_menu_item_with_mnemonic( menu, "_About", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "Bug report", makeCallbackF(OpenBugReportURL) ); - create_menu_item_with_mnemonic( menu, "Shortcuts list", makeCallbackF(DoCommandListDlg) ); ++ create_menu_item_with_mnemonic( menu, "Shortcuts", makeCallbackF(DoCommandListDlg) ); + create_menu_item_with_mnemonic( menu, "_About", makeCallbackF(DoAbout) ); return help_menu_item; } @@@ -3532,80 -3358,78 +3536,80 @@@ void Maximize_View() #include "stringio.h" void MainFrame_Construct(){ - GlobalCommands_insert( "OpenManual", FreeCaller(), Accelerator( GDK_F1 ) ); - - GlobalCommands_insert( "Sleep", FreeCaller(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "NewMap", FreeCaller() ); - GlobalCommands_insert( "OpenMap", FreeCaller(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ImportMap", FreeCaller() ); - GlobalCommands_insert( "SaveMap", FreeCaller(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "SaveMapAs", FreeCaller() ); - GlobalCommands_insert( "SaveSelected", FreeCaller() ); - GlobalCommands_insert( "SaveRegion", FreeCaller() ); - GlobalCommands_insert( "RefreshReferences", FreeCaller() ); - GlobalCommands_insert( "ProjectSettings", FreeCaller() ); - GlobalCommands_insert( "CheckForUpdate", FreeCaller() ); - GlobalCommands_insert( "Exit", FreeCaller() ); - - GlobalCommands_insert( "Undo", FreeCaller(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Redo", FreeCaller(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Copy", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Paste", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PasteToCamera", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CloneSelection", FreeCaller(), Accelerator( GDK_space ) ); - GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) ); -// GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( GDK_BackSpace ) ); - GlobalCommands_insert( "DeleteSelection2", FreeCaller(), Accelerator( GDK_BackSpace ) ); - GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( 'Z' ) ); - GlobalCommands_insert( "ParentSelection", FreeCaller() ); -// GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( GDK_Escape ) ); - GlobalCommands_insert( "UnSelectSelection2", FreeCaller(), Accelerator( GDK_Escape ) ); - GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( 'C' ) ); - GlobalCommands_insert( "InvertSelection", FreeCaller(), Accelerator( 'I' ) ); - GlobalCommands_insert( "SelectInside", FreeCaller() ); - GlobalCommands_insert( "SelectTouching", FreeCaller() ); - GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "Preferences", FreeCaller(), Accelerator( 'P' ) ); - - GlobalCommands_insert( "ToggleConsole", FreeCaller(), Accelerator( 'O' ) ); - GlobalCommands_insert( "ToggleEntityInspector", FreeCaller(), Accelerator( 'N' ) ); - GlobalCommands_insert( "EntityList", FreeCaller(), Accelerator( 'L' ) ); - -// GlobalCommands_insert( "ShowHidden", FreeCaller(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); -// GlobalCommands_insert( "HideSelected", FreeCaller(), Accelerator( 'H' ) ); + GlobalCommands_insert( "OpenManual", makeCallbackF(OpenHelpURL), Accelerator( GDK_KEY_F1 ) ); + + GlobalCommands_insert( "Sleep", makeCallbackF(thunk_OnSleep), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "NewMap", makeCallbackF(NewMap) ); + GlobalCommands_insert( "OpenMap", makeCallbackF(OpenMap), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ImportMap", makeCallbackF(ImportMap) ); + GlobalCommands_insert( "SaveMap", makeCallbackF(SaveMap), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SaveMapAs", makeCallbackF(SaveMapAs) ); + GlobalCommands_insert( "ExportSelected", makeCallbackF(ExportMap) ); + GlobalCommands_insert( "SaveRegion", makeCallbackF(SaveRegion) ); + GlobalCommands_insert( "RefreshReferences", makeCallbackF(VFS_Refresh) ); + GlobalCommands_insert( "ProjectSettings", makeCallbackF(DoProjectSettings) ); + GlobalCommands_insert( "Exit", makeCallbackF(Exit) ); + + GlobalCommands_insert( "Undo", makeCallbackF(Undo), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Redo", makeCallbackF(Redo), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Copy", makeCallbackF(Copy), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Paste", makeCallbackF(Paste), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PasteToCamera", makeCallbackF(PasteToCamera), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "CloneSelection", makeCallbackF(Selection_Clone), Accelerator( GDK_KEY_space ) ); + GlobalCommands_insert( "CloneSelectionAndMakeUnique", makeCallbackF(Selection_Clone_MakeUnique), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) ); +// GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) ); + GlobalCommands_insert( "DeleteSelection2", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) ); + GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( 'Z' ) ); + GlobalCommands_insert( "ParentSelection", makeCallbackF(Scene_parentSelected) ); +// GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) ); + GlobalCommands_insert( "UnSelectSelection2", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) ); + GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( 'C' ) ); + GlobalCommands_insert( "InvertSelection", makeCallbackF(Select_Invert), Accelerator( 'I' ) ); + GlobalCommands_insert( "SelectInside", makeCallbackF(Select_Inside) ); + GlobalCommands_insert( "SelectTouching", makeCallbackF(Select_Touching) ); + GlobalCommands_insert( "ExpandSelectionToEntities", makeCallbackF(Scene_ExpandSelectionToEntities), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "Preferences", makeCallbackF(PreferencesDialog_showDialog), Accelerator( 'P' ) ); + + GlobalCommands_insert( "ToggleConsole", makeCallbackF(Console_ToggleShow), Accelerator( 'O' ) ); + GlobalCommands_insert( "ToggleEntityInspector", makeCallbackF(EntityInspector_ToggleShow), Accelerator( 'N' ) ); + GlobalCommands_insert( "EntityList", makeCallbackF(EntityList_toggleShown), Accelerator( 'L' ) ); + - // GlobalCommands_insert( "ShowHidden", FreeCaller(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); - // GlobalCommands_insert( "HideSelected", FreeCaller(), Accelerator( 'H' ) ); ++// GlobalCommands_insert( "ShowHidden", makeCallbackF( Select_ShowAllHidden ), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); ++// GlobalCommands_insert( "HideSelected", makeCallbackF( HideSelected ), Accelerator( 'H' ) ); + Select_registerCommands(); - GlobalToggles_insert( "DragVertices", FreeCaller(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) ); - GlobalToggles_insert( "DragEdges", FreeCaller(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) ); - GlobalToggles_insert( "DragFaces", FreeCaller(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) ); + GlobalToggles_insert( "DragVertices", makeCallbackF(SelectVertexMode), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) ); + GlobalToggles_insert( "DragEdges", makeCallbackF(SelectEdgeMode), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) ); + GlobalToggles_insert( "DragFaces", makeCallbackF(SelectFaceMode), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) ); - GlobalCommands_insert( "ArbitraryRotation", FreeCaller(), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "ArbitraryScale", FreeCaller(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "ArbitraryRotation", makeCallbackF(DoRotateDlg), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "ArbitraryScale", makeCallbackF(DoScaleDlg), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "BuildMenuCustomize", FreeCaller() ); - GlobalCommands_insert( "Build_runRecentExecutedBuild", FreeCaller(), Accelerator( GDK_F5 ) ); + GlobalCommands_insert( "BuildMenuCustomize", makeCallbackF(DoBuildMenu) ); + GlobalCommands_insert( "Build_runRecentExecutedBuild", makeCallbackF(Build_runRecentExecutedBuild), Accelerator( GDK_F5 ) ); - GlobalCommands_insert( "FindBrush", FreeCaller() ); + GlobalCommands_insert( "FindBrush", makeCallbackF(DoFind) ); - GlobalCommands_insert( "MapInfo", FreeCaller(), Accelerator( 'M' ) ); + GlobalCommands_insert( "MapInfo", makeCallbackF(DoMapInfo), Accelerator( 'M' ) ); - GlobalToggles_insert( "ToggleClipper", FreeCaller(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) ); + GlobalToggles_insert( "ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) ); - GlobalToggles_insert( "MouseTranslate", FreeCaller(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) ); - GlobalToggles_insert( "MouseRotate", FreeCaller(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) ); - GlobalToggles_insert( "MouseScale", FreeCaller(), ToggleItem::AddCallbackCaller( g_scalemode_button ) ); - GlobalToggles_insert( "MouseDrag", FreeCaller(), ToggleItem::AddCallbackCaller( g_dragmode_button ) ); - GlobalCommands_insert( "MouseRotateOrScale", FreeCaller() ); - GlobalCommands_insert( "MouseDragOrScale", FreeCaller(), Accelerator( 'Q' ) ); + GlobalToggles_insert( "MouseTranslate", makeCallbackF(TranslateMode), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) ); + GlobalToggles_insert( "MouseRotate", makeCallbackF(RotateMode), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) ); + GlobalToggles_insert( "MouseScale", makeCallbackF(ScaleMode), ToggleItem::AddCallbackCaller( g_scalemode_button ) ); + GlobalToggles_insert( "MouseDrag", makeCallbackF(DragMode), ToggleItem::AddCallbackCaller( g_dragmode_button ) ); + GlobalCommands_insert( "MouseRotateOrScale", makeCallbackF(ToggleRotateScaleModes) ); + GlobalCommands_insert( "MouseDragOrScale", makeCallbackF(ToggleDragScaleModes), Accelerator( 'Q' ) ); - GlobalCommands_insert( "gtkThemeDlg", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeQER", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller() ); +#ifndef GARUX_DISABLE_GTKTHEME + GlobalCommands_insert( "gtkThemeDlg", makeCallbackF(gtkThemeDlg) ); +#endif + GlobalCommands_insert( "ColorSchemeOriginal", makeCallbackF(ColorScheme_Original) ); + GlobalCommands_insert( "ColorSchemeQER", makeCallbackF(ColorScheme_QER) ); + GlobalCommands_insert( "ColorSchemeBlackAndGreen", makeCallbackF(ColorScheme_Black) ); + GlobalCommands_insert( "ColorSchemeYdnar", makeCallbackF(ColorScheme_Ydnar) ); GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) ); GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) ); GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) ); @@@ -3740,7 -3558,7 +3744,7 @@@ void MainFrame_Destroy() void GLWindow_Construct(){ - GlobalPreferenceSystem().registerPreference( "MouseButtons", make_property_string( g_glwindow_globals.m_nMouseType ) ); -// GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) ); ++// GlobalPreferenceSystem().registerPreference( "MouseButtons", make_property_string( g_glwindow_globals.m_nMouseType ) ); } void GLWindow_Destroy(){ diff --cc radiant/mainframe.h index ba9d94b1,1d9cfad7..296319cc --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@@ -144,8 -145,8 +144,8 @@@ bool FloatingGroupDialog() extern MainFrame* g_pParentWnd; -GtkWindow* MainFrame_getWindow(); +ui::Window MainFrame_getWindow(); - + /* enum EMouseButtonMode { ETwoButton = 0, @@@ -164,10 -165,11 +164,10 @@@ struct glwindow_globals_ void GLWindow_Construct(); void GLWindow_Destroy(); - extern glwindow_globals_t g_glwindow_globals; + //extern glwindow_globals_t g_glwindow_globals; template class LatchedValue; -typedef LatchedValue LatchedBool; -extern LatchedBool g_Layout_enableDetachableMenus; +extern LatchedValue g_Layout_enableDetachableMenus; void deleteSelection(); diff --cc radiant/xywindow.cpp index e573d656,0f785741..f1d3888a --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@@ -372,11 -368,9 +372,11 @@@ struct xywindow_globals_private_ show_blocks( false ), - m_bCamXYUpdate( true ), + // m_bCamXYUpdate( true ), m_bChaseMouse( true ), - m_bSizePaint( true ){ + m_bSizePaint( true ), + + g_bCrossHairs( false ){ } }; @@@ -1212,12 -1235,12 +1240,12 @@@ void addItem( const char* name, const c }; void XYWnd::OnContextMenu(){ - if ( g_xywindow_globals.m_bRightClick == false ) { - return; - } + // if ( g_xywindow_globals.m_bRightClick == false ) { + // return; + // } - if ( m_mnuDrop == 0 ) { // first time, load it up - GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() ); + if ( !m_mnuDrop ) { // first time, load it up + auto menu = m_mnuDrop = ui::Menu(ui::New); EntityClassMenuInserter inserter( menu ); GlobalEntityClassManager().forEach( inserter ); @@@ -3066,47 -3013,45 +3095,47 @@@ void XYWindow_Construct() GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) ); GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) ); - GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_Delete ) ); - GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_Insert ) ); - GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KP_Home ) ); - GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KP_Page_Down ) ); - GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KP_End ) ); - GlobalCommands_insert( "Zoom100", FreeCaller() ); - GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - - GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) ); - -// GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) ); - GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", BoolImportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ), BoolExportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ) ); - GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) ); - GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) ); - GlobalPreferenceSystem().registerPreference( "ShowCrosshair", BoolImportStringCaller( g_bCrossHairs ), BoolExportStringCaller( g_bCrossHairs ) ); - GlobalPreferenceSystem().registerPreference( "NoStipple", BoolImportStringCaller( g_xywindow_globals.m_bNoStipple ), BoolExportStringCaller( g_xywindow_globals.m_bNoStipple ) ); - GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) ); - GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) ); - GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) ); -// GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) ); - GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) ); - - GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) ); - GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", Vector3ImportStringCaller( g_xywindow_globals.AxisColorY ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorY ) ); - GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", Vector3ImportStringCaller( g_xywindow_globals.AxisColorZ ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorZ ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors1", Vector3ImportStringCaller( g_xywindow_globals.color_gridback ), Vector3ExportStringCaller( g_xywindow_globals.color_gridback ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors2", Vector3ImportStringCaller( g_xywindow_globals.color_gridminor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridminor ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors3", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors6", Vector3ImportStringCaller( g_xywindow_globals.color_gridblock ), Vector3ExportStringCaller( g_xywindow_globals.color_gridblock ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors7", Vector3ImportStringCaller( g_xywindow_globals.color_gridtext ), Vector3ExportStringCaller( g_xywindow_globals.color_gridtext ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors8", Vector3ImportStringCaller( g_xywindow_globals.color_brushes ), Vector3ExportStringCaller( g_xywindow_globals.color_brushes ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors9", Vector3ImportStringCaller( g_xywindow_globals.color_viewname ), Vector3ExportStringCaller( g_xywindow_globals.color_viewname ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors10", Vector3ImportStringCaller( g_xywindow_globals.color_clipper ), Vector3ExportStringCaller( g_xywindow_globals.color_clipper ) ); - GlobalPreferenceSystem().registerPreference( "SI_Colors11", Vector3ImportStringCaller( g_xywindow_globals.color_selbrushes ), Vector3ExportStringCaller( g_xywindow_globals.color_selbrushes ) ); - - - GlobalPreferenceSystem().registerPreference( "XZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_xz_front_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_xz_front_shown ) ) ); - GlobalPreferenceSystem().registerPreference( "YZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_yz_side_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_yz_side_shown ) ) ); + GlobalCommands_insert( "NextView", makeCallbackF(XY_Next), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); // fixme: doesn't show its shortcut + GlobalCommands_insert( "ZoomIn", makeCallbackF(XY_ZoomIn), Accelerator( GDK_KEY_Delete ) ); + GlobalCommands_insert( "ZoomOut", makeCallbackF(XY_ZoomOut), Accelerator( GDK_KEY_Insert ) ); + GlobalCommands_insert( "ViewTop", makeCallbackF(XY_Top), Accelerator( GDK_KEY_KP_Home ) ); + GlobalCommands_insert( "ViewSide", makeCallbackF(XY_Side), Accelerator( GDK_KEY_KP_Page_Down ) ); + GlobalCommands_insert( "ViewFront", makeCallbackF(XY_Front), Accelerator( GDK_KEY_KP_End ) ); + GlobalCommands_insert( "Zoom100", makeCallbackF(XY_Zoom100) ); + GlobalCommands_insert( "CenterXYView", makeCallbackF(XY_Focus), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + + GlobalPreferenceSystem().registerPreference( "ClipCaulk", make_property_string( g_clip_useCaulk ) ); + - GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) ); ++// GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) ); + GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", make_property_string( g_xywindow_globals.m_bImprovedWheelZoom ) ); + GlobalPreferenceSystem().registerPreference( "ChaseMouse", make_property_string( g_xywindow_globals_private.m_bChaseMouse ) ); + GlobalPreferenceSystem().registerPreference( "SizePainting", make_property_string( g_xywindow_globals_private.m_bSizePaint ) ); + GlobalPreferenceSystem().registerPreference( "ShowCrosshair", make_property_string( g_xywindow_globals_private.g_bCrossHairs ) ); + GlobalPreferenceSystem().registerPreference( "NoStipple", make_property_string( g_xywindow_globals.m_bNoStipple ) ); + GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", make_property_string( g_xywindow_globals_private.show_coordinates ) ); + GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", make_property_string( g_xywindow_globals_private.show_outline ) ); + GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", make_property_string( g_xywindow_globals_private.show_axis ) ); - GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) ); ++// GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) ); + GlobalPreferenceSystem().registerPreference( "ShowWorkzone", make_property_string( g_xywindow_globals_private.d_show_work ) ); + + GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", make_property_string( g_xywindow_globals.AxisColorX ) ); + GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", make_property_string( g_xywindow_globals.AxisColorY ) ); + GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", make_property_string( g_xywindow_globals.AxisColorZ ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors1", make_property_string( g_xywindow_globals.color_gridback ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors2", make_property_string( g_xywindow_globals.color_gridminor ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors3", make_property_string( g_xywindow_globals.color_gridmajor ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors6", make_property_string( g_xywindow_globals.color_gridblock ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors7", make_property_string( g_xywindow_globals.color_gridtext ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors8", make_property_string( g_xywindow_globals.color_brushes ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors9", make_property_string( g_xywindow_globals.color_viewname ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors10", make_property_string( g_xywindow_globals.color_clipper ) ); + GlobalPreferenceSystem().registerPreference( "SI_Colors11", make_property_string( g_xywindow_globals.color_selbrushes ) ); + + + + + GlobalPreferenceSystem().registerPreference( "XZVIS", make_property_string( g_xz_front_shown ) ); + GlobalPreferenceSystem().registerPreference( "YZVIS", make_property_string( g_yz_side_shown ) ); Orthographic_registerPreferencesPage(); Clipper_registerPreferencesPage();