From 04fe1ceba51db67b2b1743e383f146ea8d31a07e Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Jul 2017 01:24:45 +1000 Subject: [PATCH] Wrap gtkutil/menu --- libs/gtkutil/menu.cpp | 99 +++++++++++++++++++++--------------------- libs/gtkutil/menu.h | 37 +++++++--------- libs/uilib/uilib.h | 18 +++++++- radiant/brushmanip.cpp | 6 +-- radiant/brushmanip.h | 4 +- radiant/build.cpp | 10 ++--- radiant/build.h | 7 +-- radiant/camwindow.cpp | 2 +- radiant/camwindow.h | 3 +- radiant/console.cpp | 2 +- radiant/entity.cpp | 2 +- radiant/entity.h | 3 +- radiant/filters.cpp | 2 +- radiant/filters.h | 5 ++- radiant/grid.cpp | 2 +- radiant/grid.h | 4 +- radiant/gtkmisc.cpp | 4 +- radiant/gtkmisc.h | 4 +- radiant/help.cpp | 6 +-- radiant/help.h | 5 ++- radiant/mainframe.cpp | 54 +++++++++++------------ radiant/mru.cpp | 2 +- radiant/mru.h | 5 ++- radiant/patchmanip.cpp | 18 ++++---- radiant/patchmanip.h | 3 +- radiant/pluginmenu.cpp | 10 ++--- radiant/texwindow.cpp | 18 ++++---- radiant/xywindow.cpp | 32 +++++++------- radiant/xywindow.h | 2 +- 29 files changed, 191 insertions(+), 178 deletions(-) diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index f4191e76..9fafb175 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -33,55 +33,55 @@ #include "container.h" #include "pointer.h" -void menu_add_item( GtkMenu* menu, GtkMenuItem* item ){ +void menu_add_item( ui::Menu menu, ui::MenuItem item ){ gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); } -GtkMenuItem* menu_separator( GtkMenu* menu ){ - GtkMenuItem* menu_item = GTK_MENU_ITEM( gtk_menu_item_new() ); +ui::MenuItem menu_separator( ui::Menu menu ){ + auto menu_item = ui::MenuItem(GTK_MENU_ITEM( gtk_menu_item_new() )); container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) ); gtk_widget_set_sensitive( GTK_WIDGET( menu_item ), FALSE ); - gtk_widget_show( GTK_WIDGET( menu_item ) ); + menu_item.show(); return menu_item; } -GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ){ - GtkTearoffMenuItem* menu_item = GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() ); +ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){ + auto menu_item = ui::TearoffMenuItem(GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() )); container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) ); // gtk_widget_set_sensitive(GTK_WIDGET(menu_item), FALSE); -- controls whether menu is detachable - gtk_widget_show( GTK_WIDGET( menu_item ) ); + menu_item.show(); return menu_item; } -GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){ - GtkMenuItem* item = ui::MenuItem( mnemonic, true ); - gtk_widget_show( GTK_WIDGET( item ) ); +ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ){ + auto item = ui::MenuItem( mnemonic, true ); + item.show(); - GtkWidget* sub_menu = ui::Menu(); + auto sub_menu = ui::Menu(); gtk_menu_item_set_submenu( item, sub_menu ); return item; } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuShell* parent, const char* mnemonic ){ - GtkMenuItem* item = new_sub_menu_item_with_mnemonic( mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::MenuShell parent, const char* mnemonic ){ + auto item = new_sub_menu_item_with_mnemonic( mnemonic ); container_add_widget( GTK_CONTAINER( parent ), GTK_WIDGET( item ) ); - return GTK_MENU( gtk_menu_item_get_submenu( item ) ); + return ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( item ) )); } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( bar ), mnemonic ); +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 ); } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( parent ), 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 ); } -void activate_closure_callback( GtkWidget* widget, gpointer data ){ +void activate_closure_callback( ui::Widget widget, gpointer data ){ ( *reinterpret_cast( data ) )( ); } -guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){ +guint menu_item_connect_callback( ui::MenuItem item, const Callback& callback ){ #if 1 return g_signal_connect_swapped( G_OBJECT( item ), "activate", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -89,7 +89,7 @@ guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){ #endif } -guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& callback ){ +guint check_menu_item_connect_callback( ui::CheckMenuItem item, const Callback& callback ){ #if 1 guint handler = g_signal_connect_swapped( G_OBJECT( item ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -99,50 +99,50 @@ guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& return handler; } -GtkMenuItem* new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = ui::MenuItem( mnemonic, true ); - gtk_widget_show( GTK_WIDGET( item ) ); +ui::MenuItem new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ + auto item = ui::MenuItem( mnemonic, true ); + item.show(); menu_item_connect_callback( item, callback ); return item; } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = new_menu_item_with_mnemonic( mnemonic, callback ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const Callback& callback ){ + auto item = new_menu_item_with_mnemonic( mnemonic, callback ); container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); return item; } -GtkCheckMenuItem* new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback& callback ){ - GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) ); - gtk_widget_show( GTK_WIDGET( item ) ); +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 ) )); + item.show(); check_menu_item_connect_callback( item, callback ); return item; } -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ){ - GtkCheckMenuItem* item = new_check_menu_item_with_mnemonic( mnemonic, callback ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ){ + auto item = new_check_menu_item_with_mnemonic( mnemonic, callback ); container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); return item; } -GtkRadioMenuItem* new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){ - GtkRadioMenuItem* item = GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) ); +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 ) )); if ( *group == 0 ) { gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE ); } *group = gtk_radio_menu_item_get_group( item ); - gtk_widget_show( GTK_WIDGET( item ) ); - check_menu_item_connect_callback( GTK_CHECK_MENU_ITEM( item ), callback ); + item.show(); + check_menu_item_connect_callback( item, callback ); return item; } -GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback ){ - GtkRadioMenuItem* item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback ); +ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback& callback ){ + auto item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback ); container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); return item; } -void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active ){ +void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active ){ guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( item ), "handler" ) ); g_signal_handler_block( G_OBJECT( item ), handler_id ); gtk_check_menu_item_set_active( item, active ); @@ -151,7 +151,7 @@ void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean acti -void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active ){ +void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active ){ { for ( GSList* l = gtk_radio_menu_item_get_group( item ); l != 0; l = g_slist_next( l ) ) { @@ -168,7 +168,7 @@ void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean acti } -void menu_item_set_accelerator( GtkMenuItem* item, GClosure* closure ){ +void menu_item_set_accelerator( ui::MenuItem item, GClosure* closure ){ GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) ); gtk_accel_label_set_accel_closure( accel_label, closure ); } @@ -224,7 +224,7 @@ void accelerator_name( const Accelerator& accelerator, GString* gstring ){ } } -void menu_item_add_accelerator( GtkMenuItem* item, Accelerator accelerator ){ +void menu_item_add_accelerator( ui::MenuItem item, Accelerator accelerator ){ if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers )) { GClosure* closure = global_accel_group_find( accelerator ); ASSERT_NOTNULL(closure); @@ -232,20 +232,21 @@ void menu_item_add_accelerator( GtkMenuItem* item, Accelerator accelerator ){ } } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command ){ - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command ){ + auto item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback ); menu_item_add_accelerator( item, command.m_accelerator ); return item; } -void check_menu_item_set_active_callback( GtkCheckMenuItem& item, bool enabled ){ - check_menu_item_set_active_no_signal( &item, enabled ); +void check_menu_item_set_active_callback( GtkCheckMenuItem &item, bool enabled ){ + check_menu_item_set_active_no_signal( ui::CheckMenuItem(&item), enabled ); } typedef ReferenceCaller1 CheckMenuItemSetActiveCaller; -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle ){ - GtkCheckMenuItem* item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback ); - menu_item_add_accelerator( GTK_MENU_ITEM( item ), toggle.m_command.m_accelerator ); - toggle.m_exportCallback( CheckMenuItemSetActiveCaller( *item ) ); +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_ ) ); return item; } diff --git a/libs/gtkutil/menu.h b/libs/gtkutil/menu.h index a64291d4..9b040450 100644 --- a/libs/gtkutil/menu.h +++ b/libs/gtkutil/menu.h @@ -22,37 +22,30 @@ #if !defined( INCLUDED_GTKUTIL_MENU_H ) #define INCLUDED_GTKUTIL_MENU_H +#include #include "generic/callbackfwd.h" typedef int gint; typedef gint gboolean; typedef struct _GSList GSList; -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuBar GtkMenuBar; -typedef struct _GtkMenuItem GtkMenuItem; -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; -typedef struct _GtkRadioMenuItem GtkRadioMenuItem; -typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem; - -void menu_add_item( GtkMenu* menu, GtkMenuItem* item ); -GtkMenuItem* menu_separator( GtkMenu* menu ); -GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ); -GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ); -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic ); -GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic ); -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ); -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ); -GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback ); + +void menu_add_item( ui::Menu menu, ui::MenuItem item ); +ui::MenuItem menu_separator( ui::Menu menu ); +ui::TearoffMenuItem menu_tearoff( ui::Menu menu ); +ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ); +ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback& callback ); class Command; -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command ); class Toggle; -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle ); -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; -void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active ); -typedef struct _GtkRadioMenuItem GtkRadioMenuItem; -void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active ); +void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active ); +void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active ); #endif diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 72ec0ca4..39fd8006 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -14,6 +14,7 @@ struct _GtkCellEditable; struct _GtkCellRenderer; struct _GtkCellRendererText; struct _GtkCheckButton; +struct _GtkCheckMenuItem; struct _GtkComboBox; struct _GtkComboBoxText; struct _GtkContainer; @@ -29,12 +30,14 @@ struct _GtkItem; struct _GtkLabel; struct _GtkListStore; struct _GtkMenu; +struct _GtkMenuBar; struct _GtkMenuItem; struct _GtkMenuShell; struct _GtkMisc; struct _GtkObject; struct _GtkPaned; struct _GtkRadioButton; +struct _GtkRadioMenuItem; struct _GtkRadioToolButton; struct _GtkRange; struct _GtkScale; @@ -283,6 +286,15 @@ namespace ui { MenuItem(const char *label, bool mnemonic = false); , ); + + WRAP(CheckMenuItem, MenuItem, _GtkCheckMenuItem, (), + , + ); + + WRAP(RadioMenuItem, CheckMenuItem, _GtkRadioMenuItem, (), + , + ); + WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (), TearoffMenuItem(); , @@ -350,7 +362,11 @@ namespace ui { , ); - WRAP(Menu, Widget, _GtkMenu, (), + WRAP(MenuBar, MenuShell, _GtkMenuBar, (), + , + ); + + WRAP(Menu, MenuShell, _GtkMenu, (), Menu(); , ); diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index 3979f6a8..43dc0e73 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -1376,14 +1376,14 @@ void Brush_registerCommands(){ GlobalCommands_insert( "MakeStructural", FreeCaller(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); } -void Brush_constructMenu( GtkMenu* menu ){ +void Brush_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "Prism...", "BrushPrism" ); create_menu_item_with_mnemonic( menu, "Cone...", "BrushCone" ); create_menu_item_with_mnemonic( menu, "Sphere...", "BrushSphere" ); create_menu_item_with_mnemonic( menu, "Rock...", "BrushRock" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1393,7 +1393,7 @@ void Brush_constructMenu( GtkMenu* menu ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } diff --git a/radiant/brushmanip.h b/radiant/brushmanip.h index 06f67271..8795bf4e 100644 --- a/radiant/brushmanip.h +++ b/radiant/brushmanip.h @@ -23,6 +23,7 @@ #define INCLUDED_BRUSHWRAPPER_H #include +#include #include "string/stringfwd.h" #include "generic/callbackfwd.h" @@ -71,8 +72,7 @@ void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ); void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat ); -typedef struct _GtkMenu GtkMenu; -void Brush_constructMenu( GtkMenu* menu ); +void Brush_constructMenu( ui::Menu menu ); extern Callback g_texture_lock_status_changed; diff --git a/radiant/build.cpp b/radiant/build.cpp index a7500ef4..2b34fbc5 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -640,7 +640,7 @@ void build_commands_write( const char* filename ){ #include "gtkutil/window.h" #include "gtkdlgs.h" -void Build_refreshMenu( GtkMenu* menu ); +void Build_refreshMenu( ui::Menu menu ); void BSPCommandList_Construct( ui::ListStore store, Project& project ){ @@ -994,9 +994,9 @@ typedef std::list BuildMenuItems; BuildMenuItems g_BuildMenuItems; -GtkMenu* g_bsp_menu; +ui::Menu g_bsp_menu{nullptr}; -void Build_constructMenu( GtkMenu* menu ){ +void Build_constructMenu( ui::Menu menu ){ for ( Project::iterator i = g_build_project.begin(); i != g_build_project.end(); ++i ) { g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), 0 ) ); @@ -1011,10 +1011,10 @@ void Build_constructMenu( GtkMenu* menu ){ } -void Build_refreshMenu( GtkMenu* menu ){ +void Build_refreshMenu( ui::Menu menu ){ for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i ) { - gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( ( *i ).m_item ) ); + gtk_container_remove( menu, GTK_WIDGET( ( *i ).m_item ) ); } g_BuildMenuItems.clear(); diff --git a/radiant/build.h b/radiant/build.h index 32a39718..4e494146 100644 --- a/radiant/build.h +++ b/radiant/build.h @@ -18,6 +18,8 @@ along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_BUILD_H ) #define INCLUDED_BUILD_H @@ -36,9 +38,8 @@ void DoBuildMenu(); void BuildMenu_Construct(); void BuildMenu_Destroy(); -typedef struct _GtkMenu GtkMenu; -void Build_constructMenu( GtkMenu* menu ); -extern GtkMenu* g_bsp_menu; +void Build_constructMenu( ui::Menu menu ); +extern ui::Menu g_bsp_menu; #endif diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index d250f873..b047b8b5 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1602,7 +1602,7 @@ void CamWnd::BenchMark(){ } -void fill_view_camera_menu( GtkMenu* menu ){ +void fill_view_camera_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" ); } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index bfe449e5..5040e51c 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -39,8 +39,7 @@ void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); -typedef struct _GtkMenu GtkMenu; -void fill_view_camera_menu( GtkMenu* menu ); +void fill_view_camera_menu( ui::Menu menu ); typedef struct _GtkToolbar GtkToolbar; void CamWnd_constructToolbar( GtkToolbar* toolbar ); void CamWnd_registerShortcuts(); diff --git a/radiant/console.cpp b/radiant/console.cpp index b8968d0c..60154723 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -88,7 +88,7 @@ void console_clear(){ gtk_text_buffer_set_text( buffer, "", -1 ); } -void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){ +void console_populate_popup( GtkTextView* textview, ui::Menu menu, gpointer user_data ){ menu_separator( menu ); ui::Widget item(ui::MenuItem( "Clear" )); diff --git a/radiant/entity.cpp b/radiant/entity.cpp index 49ed045b..cf726aca 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -569,7 +569,7 @@ void Entity_registerPreferencesPage(){ -void Entity_constructMenu( GtkMenu* menu ){ +void Entity_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" ); create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" ); create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" ); diff --git a/radiant/entity.h b/radiant/entity.h index 752ff189..fca38f92 100644 --- a/radiant/entity.h +++ b/radiant/entity.h @@ -34,8 +34,7 @@ void Scene_EntitySetClassname_Selected( const char* classname ); const char* misc_model_dialog( ui::Widget parent ); -typedef struct _GtkMenu GtkMenu; -void Entity_constructMenu( GtkMenu* menu ); +void Entity_constructMenu( ui::Menu menu ); void Entity_Construct(); void Entity_Destroy(); diff --git a/radiant/filters.cpp b/radiant/filters.cpp index 3ff4ddd0..14eec0cd 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -171,7 +171,7 @@ void ResetFilters(){ } } -void Filters_constructMenu( GtkMenu* menu_in_menu ){ +void Filters_constructMenu( ui::Menu menu_in_menu ){ create_check_menu_item_with_mnemonic( menu_in_menu, "World", "FilterWorldBrushes" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Entities", "FilterEntities" ); if ( g_pGameDescription->mGameType == "doom3" ) { diff --git a/radiant/filters.h b/radiant/filters.h index 97766ab8..9779585a 100644 --- a/radiant/filters.h +++ b/radiant/filters.h @@ -19,10 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_FILTERS_H ) #define INCLUDED_FILTERS_H -typedef struct _GtkMenu GtkMenu; -void Filters_constructMenu( GtkMenu* menu_in_menu ); +void Filters_constructMenu( ui::Menu menu_in_menu ); #endif diff --git a/radiant/grid.cpp b/radiant/grid.cpp index 148fa4fa..8ede1a22 100644 --- a/radiant/grid.cpp +++ b/radiant/grid.cpp @@ -212,7 +212,7 @@ void Grid_registerCommands(){ } -void Grid_constructMenu( GtkMenu* menu ){ +void Grid_constructMenu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "Grid0.125", "SetGrid0.125" ); create_check_menu_item_with_mnemonic( menu, "Grid0.25", "SetGrid0.25" ); create_check_menu_item_with_mnemonic( menu, "Grid0.5", "SetGrid0.5" ); diff --git a/radiant/grid.h b/radiant/grid.h index 53b717c1..d3c28ec2 100644 --- a/radiant/grid.h +++ b/radiant/grid.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_GRID_H ) #define INCLUDED_GRID_H +#include #include "signal/signalfwd.h" float GetSnapGridSize(); @@ -31,8 +32,7 @@ int Grid_getPower(); void AddGridChangeCallback( const SignalHandler& handler ); void Grid_registerCommands(); -typedef struct _GtkMenu GtkMenu; -void Grid_constructMenu( GtkMenu* menu ); +void Grid_constructMenu( ui::Menu menu ); void Grid_registerShortcuts(); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index a38fde78..fc14013b 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -72,14 +72,14 @@ void toggle_remove_accelerator( const char* name ){ global_accel_group_disconnect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); } -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName ){ +GtkCheckMenuItem* create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 2 ); const Toggle& toggle = GlobalToggles_find( commandName ); global_accel_group_connect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); return create_check_menu_item_with_mnemonic( menu, mnemonic, toggle ); } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const char* commandName ){ +GtkMenuItem* create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 1 ); const Command& command = GlobalCommands_find( commandName ); global_accel_group_connect( command.m_accelerator, command.m_callback ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 867aaccb..3bdfff7a 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -51,9 +51,9 @@ typedef struct _GtkMenuItem GtkMenuItem; typedef struct _GtkCheckMenuItem GtkCheckMenuItem; // this also sets up the shortcut using command_connect_accelerator -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu *menu, const char *mnemonic, const char* commandName ); +GtkMenuItem* create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ); // this also sets up the shortcut using command_connect_accelerator -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName ); +GtkCheckMenuItem* create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ); typedef struct _GtkButton GtkButton; typedef struct _GtkToggleButton GtkToggleButton; diff --git a/radiant/help.cpp b/radiant/help.cpp index 07b51603..82e5f667 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -51,13 +51,13 @@ void HandleHelpCommand( CopiedString& str ){ OpenURL( str.c_str() ); } -void process_xlink( const char* filename, const char *menu_name, const char *base_url, GtkMenu *menu ){ +void process_xlink( const char* filename, const char *menu_name, const char *base_url, ui::Menu menu ){ if ( file_exists( filename ) ) { xmlDocPtr pDoc = xmlParseFile( filename ); if ( pDoc ) { globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; // create sub menu - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -113,7 +113,7 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas } } -void create_game_help_menu( GtkMenu *menu ){ +void create_game_help_menu( ui::Menu menu ){ StringOutputStream filename( 256 ); filename << AppPath_get() << "global.xlink"; process_xlink( filename.c_str(), "General", AppPath_get(), menu ); diff --git a/radiant/help.h b/radiant/help.h index d7e6263c..1e85100a 100644 --- a/radiant/help.h +++ b/radiant/help.h @@ -19,10 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_HELP_H ) #define INCLUDED_HELP_H -typedef struct _GtkMenu GtkMenu; -void create_game_help_menu( GtkMenu *menu ); +void create_game_help_menu( ui::Menu menu ); #endif diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 8d07e012..21493fff 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -902,12 +902,12 @@ ColoursMenu g_ColoursMenu; GtkMenuItem* create_colours_menu(){ GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); - GtkMenu* menu_in_menu = GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) ); + auto menu_in_menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } - GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" ); + auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_3 ); } @@ -1795,7 +1795,7 @@ LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" ); GtkMenuItem* create_file_menu(){ // File menu GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1835,7 +1835,7 @@ GtkMenuItem* create_file_menu(){ GtkMenuItem* create_edit_menu(){ // Edit menu GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1857,7 +1857,7 @@ GtkMenuItem* create_edit_menu(){ create_menu_item_with_mnemonic( menu, "Select i_nside", "SelectInside" ); create_menu_item_with_mnemonic( menu, "Select _touching", "SelectTouching" ); - GtkMenu* convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" ); + auto convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( convert_menu ); } @@ -1869,17 +1869,17 @@ GtkMenuItem* create_edit_menu(){ return edit_menu_item; } -void fill_view_xy_top_menu( GtkMenu* menu ){ +void fill_view_xy_top_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); } -void fill_view_yz_side_menu( GtkMenu* menu ){ +void fill_view_yz_side_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); } -void fill_view_xz_front_menu( GtkMenu* menu ){ +void fill_view_xz_front_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); } @@ -1892,7 +1892,7 @@ ui::Widget g_toggle_entitylist_item; GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ // View menu GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1917,7 +1917,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ menu_separator( menu ); { - GtkMenu* camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" ); + auto camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( camera_menu ); } @@ -1936,7 +1936,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" ); + auto orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( orthographic_menu ); } @@ -1956,7 +1956,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1971,7 +1971,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1979,7 +1979,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Hide/Show" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Hide/Show" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1988,7 +1988,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2006,13 +2006,13 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ GtkMenuItem* create_selection_menu(){ // Selection menu GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2024,7 +2024,7 @@ GtkMenuItem* create_selection_menu(){ menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2034,7 +2034,7 @@ GtkMenuItem* create_selection_menu(){ create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" ); } { - 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 ); } @@ -2043,7 +2043,7 @@ GtkMenuItem* create_selection_menu(){ create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2061,7 +2061,7 @@ GtkMenuItem* create_selection_menu(){ GtkMenuItem* create_bsp_menu(){ // BSP menu GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2081,7 +2081,7 @@ GtkMenuItem* create_bsp_menu(){ GtkMenuItem* create_grid_menu(){ // Grid menu GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2094,7 +2094,7 @@ GtkMenuItem* create_grid_menu(){ GtkMenuItem* create_misc_menu(){ // Misc menu GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2115,7 +2115,7 @@ GtkMenuItem* create_misc_menu(){ GtkMenuItem* create_entity_menu(){ // Brush menu GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2128,7 +2128,7 @@ GtkMenuItem* create_entity_menu(){ GtkMenuItem* create_brush_menu(){ // Brush menu GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2141,7 +2141,7 @@ GtkMenuItem* create_brush_menu(){ GtkMenuItem* create_patch_menu(){ // Curve menu GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2154,7 +2154,7 @@ GtkMenuItem* create_patch_menu(){ GtkMenuItem* create_help_menu(){ // Help menu GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 3198b924..085ca953 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -191,7 +191,7 @@ LoadMRU g_load_mru2( 2 ); LoadMRU g_load_mru3( 3 ); LoadMRU g_load_mru4( 4 ); -void MRU_constructMenu( GtkMenu* menu ){ +void MRU_constructMenu( ui::Menu menu ){ { GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) ); gtk_widget_set_sensitive( GTK_WIDGET( item ), FALSE ); diff --git a/radiant/mru.h b/radiant/mru.h index 273c97f1..33627d80 100644 --- a/radiant/mru.h +++ b/radiant/mru.h @@ -19,13 +19,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_MRU_H ) #define INCLUDED_MRU_H void MRU_AddFile( const char *str ); -typedef struct _GtkMenu GtkMenu; -void MRU_constructMenu( GtkMenu* menu ); +void MRU_constructMenu( ui::Menu menu ); void MRU_Construct(); void MRU_Destroy(); diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 7fa22082..851e384b 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -748,10 +748,10 @@ void Patch_constructToolbar( GtkToolbar* toolbar ){ toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" ); } -void Patch_constructMenu( GtkMenu* menu ){ +void Patch_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -764,7 +764,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" ); create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -781,7 +781,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -792,7 +792,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -804,18 +804,18 @@ void Patch_constructMenu( GtkMenu* menu ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" ); - GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" ); + auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_3 ); } create_menu_item_with_mnemonic( menu_3, "Rows", "RedisperseRows" ); create_menu_item_with_mnemonic( menu_3, "Columns", "RedisperseCols" ); - GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" ); + auto menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_4 ); } @@ -828,7 +828,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } diff --git a/radiant/patchmanip.h b/radiant/patchmanip.h index 47f7f224..5227fb10 100644 --- a/radiant/patchmanip.h +++ b/radiant/patchmanip.h @@ -22,13 +22,14 @@ #if !defined ( INCLUDED_PATCHMANIP_H ) #define INCLUDED_PATCHMANIP_H +#include #include "string/stringfwd.h" void Patch_registerCommands(); typedef struct _GtkToolbar GtkToolbar; typedef struct _GtkMenu GtkMenu; void Patch_constructToolbar( GtkToolbar* toolbar ); -void Patch_constructMenu( GtkMenu* menu ); +void Patch_constructMenu( ui::Menu menu ); namespace scene { diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index fb97825a..2fa46592 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -41,12 +41,12 @@ void plugin_activated( ui::Widget widget, gpointer data ){ } #include -typedef std::stack WidgetStack; void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ - ui::Widget menu, item, parent, subMenu; + ui::Widget item, parent; + ui::Menu menu{nullptr}, subMenu{nullptr}; const char *menuText, *menuCommand; - WidgetStack menuStack; + std::stack menuStack; parent = ui::MenuItem( pPlugIn->getMenuName() ); gtk_widget_show( parent ); @@ -56,7 +56,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ if ( nCount > 0 ) { menu = ui::Menu(); if ( g_Layout_enableDetachableMenus.m_value ) { - menu_tearoff( GTK_MENU( menu ) ); + menu_tearoff( menu ); } while ( nCount > 0 ) { @@ -157,7 +157,7 @@ void PluginsMenu_clear(){ GtkMenuItem* create_plugins_menu(){ // Plugins menu GtkMenuItem* plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 01f3c979..8226fa24 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1655,7 +1655,7 @@ void TextureBrowser_createTreeViewTags(){ TextureBrowser_constructTreeStoreTags(); } -ui::MenuItem TextureBrowser_constructViewMenu( GtkMenu* menu ){ +ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" )); if ( g_Layout_enableDetachableMenus.m_value ) { @@ -1704,7 +1704,7 @@ ui::MenuItem TextureBrowser_constructViewMenu( GtkMenu* menu ){ return textures_menu_item; } -ui::MenuItem TextureBrowser_constructToolsMenu( GtkMenu* menu ){ +ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" )); if ( g_Layout_enableDetachableMenus.m_value ) { @@ -1717,7 +1717,7 @@ ui::MenuItem TextureBrowser_constructToolsMenu( GtkMenu* menu ){ return textures_menu_item; } -ui::MenuItem TextureBrowser_constructTagsMenu( GtkMenu* menu ){ +ui::MenuItem TextureBrowser_constructTagsMenu( ui::Menu menu ){ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" )); if ( g_Layout_enableDetachableMenus.m_value ) { @@ -2016,13 +2016,13 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ { // menu bar menu_bar = ui::Widget(gtk_menu_bar_new()); - ui::Widget menu_view = ui::Menu(); - auto view_item = TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); + auto menu_view = ui::Menu(); + auto view_item = TextureBrowser_constructViewMenu( menu_view ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item ); - ui::Widget menu_tools = ui::Menu(); - auto tools_item = TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); + auto menu_tools = ui::Menu(); + auto tools_item = TextureBrowser_constructToolsMenu( menu_tools ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item ); @@ -2084,8 +2084,8 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ TextureBrowser_buildTagList(); } { // tag menu bar - ui::Widget menu_tags = ui::Menu(); - auto tags_item = TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); + auto menu_tags = ui::Menu(); + auto tags_item = TextureBrowser_constructTagsMenu( menu_tags ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item ); } diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 3e2b1fd3..1d77da5b 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -537,7 +537,7 @@ VIEWTYPE GlobalXYWnd_getCurrentViewType(){ bool g_bCrossHairs = false; -GtkMenu* XYWnd::m_mnuDrop = 0; +ui::Menu XYWnd::m_mnuDrop{nullptr}; // this is disabled, and broken // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 @@ -819,7 +819,7 @@ XYWnd::XYWnd() : m_entityCreate = false; - m_mnuDrop = 0; + m_mnuDrop = ui::Menu{nullptr}; GlobalWindowObservers_add( m_window_observer ); GlobalWindowObservers_connectWidget( m_gl_widget ); @@ -858,9 +858,9 @@ XYWnd::XYWnd() : XYWnd::~XYWnd(){ onDestroyed(); - if ( m_mnuDrop != 0 ) { + if ( m_mnuDrop ) { gtk_widget_destroy( GTK_WIDGET( m_mnuDrop ) ); - m_mnuDrop = 0; + m_mnuDrop = ui::Menu{nullptr}; } g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler ); @@ -1075,21 +1075,21 @@ void entitycreate_activated( ui::Widget item ){ } } -void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){ - GtkMenuItem* item = ui::MenuItem( name ); +void EntityClassMenu_addItem( ui::Menu menu, const char* name ){ + auto item = ui::MenuItem( name ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item ); - gtk_widget_show( GTK_WIDGET( item ) ); + item.show(); menu_add_item( menu, item ); } class EntityClassMenuInserter : public EntityClassVisitor { -typedef std::pair MenuPair; +typedef std::pair MenuPair; typedef std::vector MenuStack; MenuStack m_stack; CopiedString m_previous; public: -EntityClassMenuInserter( GtkMenu* menu ){ +EntityClassMenuInserter( ui::Menu menu ){ m_stack.reserve( 2 ); m_stack.push_back( MenuPair( menu, "" ) ); } @@ -1106,11 +1106,11 @@ void visit( EntityClass* e ){ m_previous = e->name(); } void pushMenu( const CopiedString& name ){ - GtkMenuItem* item = ui::MenuItem( name.c_str() ); - gtk_widget_show( GTK_WIDGET( item ) ); + auto item = ui::MenuItem( name.c_str() ); + item.show(); container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) ); - GtkMenu* submenu = ui::Menu(); + auto submenu = ui::Menu(); gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) ); m_stack.push_back( MenuPair( submenu, name ) ); @@ -1152,8 +1152,8 @@ void XYWnd::OnContextMenu(){ return; } - if ( m_mnuDrop == 0 ) { // first time, load it up - GtkMenu* menu = m_mnuDrop = ui::Menu(); + if ( !m_mnuDrop ) { // first time, load it up + auto menu = m_mnuDrop = ui::Menu(); EntityClassMenuInserter inserter( menu ); GlobalEntityClassManager().forEach( inserter ); @@ -2567,9 +2567,9 @@ void realise(){ } void unrealise(){ if ( ++m_unrealised == 1 ) { - if ( XYWnd::m_mnuDrop != 0 ) { + if ( XYWnd::m_mnuDrop ) { gtk_widget_destroy( GTK_WIDGET( XYWnd::m_mnuDrop ) ); - XYWnd::m_mnuDrop = 0; + XYWnd::m_mnuDrop = ui::Menu(nullptr); } } } diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 66709784..d95e1c3b 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -141,7 +141,7 @@ void DropClipPoint( int pointx, int pointy ); void SetViewType( VIEWTYPE n ); bool m_bActive; -static GtkMenu* m_mnuDrop; +static ui::Menu m_mnuDrop; int m_chasemouse_current_x, m_chasemouse_current_y; int m_chasemouse_delta_x, m_chasemouse_delta_y; -- 2.39.2