From: TimePath Date: Wed, 17 Feb 2016 03:24:46 +0000 (+1100) Subject: Wrap GtkMenuItem X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d3034f02cb5cfbb42aa03874a94680d01dd13a71;p=xonotic%2Fnetradiant.git Wrap GtkMenuItem --- diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 97d55d27..f2295d14 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -341,19 +341,19 @@ void DoConfigDialog(){ gtk_widget_show( menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU( zlist ), menu ); - item = gtk_menu_item_new_with_label( "Z-Buffer Test and Write (recommended for solid or no polygons)" ); + item = ui::MenuItem( "Z-Buffer Test and Write (recommended for solid or no polygons)" ); gtk_widget_show( item ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 0 ) ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Z-Buffer Test Only (recommended for transparent polygons)" ); + item = ui::MenuItem( "Z-Buffer Test Only (recommended for transparent polygons)" ); gtk_widget_show( item ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 1 ) ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Z-Buffer Off" ); + item = ui::MenuItem( "Z-Buffer Off" ); gtk_widget_show( item ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 2 ) ); diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index cbb07df8..8b9471f1 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "generic/callback.h" @@ -56,7 +57,7 @@ GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ){ } GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); + GtkMenuItem* item = ui::MenuItem( mnemonic, true ); gtk_widget_show( GTK_WIDGET( item ) ); GtkWidget* sub_menu = gtk_menu_new(); @@ -102,7 +103,7 @@ guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& } GtkMenuItem* new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); + GtkMenuItem* item = ui::MenuItem( mnemonic, true ); gtk_widget_show( GTK_WIDGET( item ) ); menu_item_connect_callback( item, callback ); return item; diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 54b4a3a3..54b7f510 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -100,6 +100,9 @@ namespace ui { Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label))) { } + MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem(GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label))) + { } + TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model))) { } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 4d9d252a..f3d7a5db 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -117,7 +117,9 @@ namespace ui { Label(const char *label); ); - WRAP(MenuItem, ui_menuitem,); + WRAP(MenuItem, ui_menuitem, + MenuItem(const char *label, bool mnemonic = false); + ); WRAP(ScrolledWindow, ui_scrolledwindow, ScrolledWindow(); diff --git a/plugins/textool/2DView.cpp b/plugins/textool/2DView.cpp index 4da3fab3..993bc13d 100644 --- a/plugins/textool/2DView.cpp +++ b/plugins/textool/2DView.cpp @@ -116,22 +116,22 @@ bool C2DView::OnRButtonUp( int x, int y ){ menu = gtk_menu_new(); - item = gtk_menu_item_new_with_label( "Validate (RETURN)" ); + item = ui::MenuItem( "Validate (RETURN)" ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Validate ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom in (INSERT)" ); + item = ui::MenuItem( "Zoom in (INSERT)" ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomIn ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom out (DELETE)" ); + item = ui::MenuItem( "Zoom out (DELETE)" ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomOut ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Cancel (ESC)" ); + item = ui::MenuItem( "Cancel (ESC)" ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Cancel ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); diff --git a/radiant/console.cpp b/radiant/console.cpp index bbf99fc8..4530bc29 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -96,7 +96,7 @@ void console_clear(){ void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){ menu_separator( menu ); - ui::Widget item(gtk_menu_item_new_with_label( "Clear" )); + ui::Widget item(ui::MenuItem( "Clear" )); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 ); gtk_widget_show( item ); container_add_widget( GTK_CONTAINER( menu ), item ); diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 56fcd61d..06cf3de7 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -49,7 +49,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ const char *menuText, *menuCommand; WidgetStack menuStack; - parent = ui::Widget(gtk_menu_item_new_with_label( pPlugIn->getMenuName() )); + parent = ui::MenuItem( pPlugIn->getMenuName() ); gtk_widget_show( parent ); gtk_container_add( GTK_CONTAINER( plugin_menu ), parent ); @@ -77,7 +77,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ continue; } - item = ui::Widget(gtk_menu_item_new_with_label( menuText )); + item = ui::MenuItem( menuText ); gtk_widget_show( item ); gtk_container_add( GTK_CONTAINER( menu ), item ); @@ -100,7 +100,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } else { - item = ui::Widget(gtk_menu_item_new_with_label( menuText )); + item = ui::MenuItem( menuText ); g_object_set_data( G_OBJECT( item ),"command", const_cast( static_cast( menuCommand ) ) ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index fc3ab0b2..b24f0422 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1549,15 +1549,15 @@ void TextureBrowser_deleteTag(); void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){ ui::Widget menu = ui::Widget(gtk_menu_new()); - ui::Widget menuitem = ui::Widget(gtk_menu_item_new_with_label( "Add tag" )); + ui::Widget menuitem = ui::MenuItem( "Add tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = ui::Widget(gtk_menu_item_new_with_label( "Rename tag" )); + menuitem = ui::MenuItem( "Rename tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = ui::Widget(gtk_menu_item_new_with_label( "Delete tag" )); + menuitem = ui::MenuItem( "Delete tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 686b9bfc..18975120 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1077,7 +1077,7 @@ void entitycreate_activated( ui::Widget item ){ } void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name ) ); + GtkMenuItem* item = ui::MenuItem( name ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item ); gtk_widget_show( GTK_WIDGET( item ) ); menu_add_item( menu, item ); @@ -1107,7 +1107,7 @@ void visit( EntityClass* e ){ m_previous = e->name(); } void pushMenu( const std::string& name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name.c_str() ) ); + GtkMenuItem* item = ui::MenuItem( name.c_str() ); gtk_widget_show( GTK_WIDGET( item ) ); container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) );