From: TimePath Date: Wed, 17 Feb 2016 03:50:49 +0000 (+1100) Subject: Wrap GtkMenu X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7cd0bdef874f87aa50eea3202d06b75bb33fd818;p=xonotic%2Fnetradiant.git Wrap GtkMenu --- diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index a9f2d724..71cca931 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -337,7 +337,7 @@ void DoConfigDialog(){ gtk_widget_show( zlist ); gtk_box_pack_start( GTK_BOX( vbox2 ), zlist, TRUE, FALSE, 0 ); - menu = gtk_menu_new(); + menu = ui::Menu(); gtk_widget_show( menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU( zlist ), menu ); diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index 8b9471f1..5dfad4c1 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -60,7 +60,7 @@ GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){ GtkMenuItem* item = ui::MenuItem( mnemonic, true ); gtk_widget_show( GTK_WIDGET( item ) ); - GtkWidget* sub_menu = gtk_menu_new(); + GtkWidget* sub_menu = ui::Menu(); gtk_menu_item_set_submenu( item, sub_menu ); return item; diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 7e10501d..1e7cd9d5 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -103,6 +103,9 @@ namespace ui { Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label))) { } + Menu::Menu() : Menu(GTK_MENU(gtk_menu_new())) + { } + MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem(GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label))) { } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index bd287b71..4e4da415 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -10,6 +10,7 @@ using ui_checkbutton = struct _GtkCheckButton; using ui_evkey = struct _GdkEventKey; using ui_hbox = struct _GtkHBox; using ui_label = struct _GtkLabel; +using ui_menu = struct _GtkMenu; using ui_menuitem = struct _GtkMenuItem; using ui_modal = struct ModalDialog; using ui_scrolledwindow = struct _GtkScrolledWindow; @@ -128,6 +129,10 @@ namespace ui { Label(const char *label); ); + WRAP(Menu, Widget, ui_menu, + Menu(); + ); + WRAP(MenuItem, Widget, ui_menuitem, MenuItem(const char *label, bool mnemonic = false); ); diff --git a/plugins/textool/2DView.cpp b/plugins/textool/2DView.cpp index 993bc13d..4ad21fe9 100644 --- a/plugins/textool/2DView.cpp +++ b/plugins/textool/2DView.cpp @@ -114,7 +114,7 @@ bool C2DView::OnRButtonUp( int x, int y ){ if ( m_bPopup ) { GtkWidget *menu, *item; - menu = gtk_menu_new(); + menu = ui::Menu(); item = ui::MenuItem( "Validate (RETURN)" ); gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Validate ), NULL ); diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 06cf3de7..2f34e5e5 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -55,7 +55,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ std::size_t nCount = pPlugIn->getCommandCount(); if ( nCount > 0 ) { - menu = ui::Widget(gtk_menu_new()); + menu = ui::Menu(); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( GTK_MENU( menu ) ); } @@ -81,7 +81,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ gtk_widget_show( item ); gtk_container_add( GTK_CONTAINER( menu ), item ); - subMenu = ui::Widget(gtk_menu_new()); + subMenu = ui::Menu(); gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu ); menuStack.push( menu ); menu = subMenu; diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index b4b1180d..33568023 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1547,7 +1547,7 @@ void TextureBrowser_renameTag(); void TextureBrowser_deleteTag(); void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){ - ui::Widget menu = ui::Widget(gtk_menu_new()); + ui::Widget menu = ui::Menu(); ui::Widget menuitem = ui::MenuItem( "Add tag" ); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview ); @@ -1959,12 +1959,12 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ { // menu bar menu_bar = ui::Widget(gtk_menu_bar_new()); - ui::Widget menu_view = ui::Widget(gtk_menu_new()); + ui::Widget menu_view = ui::Menu(); auto view_item = TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); - ui::Widget menu_tools = ui::Widget(gtk_menu_new()); + ui::Widget menu_tools = ui::Menu(); auto tools_item = TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item ); @@ -2027,7 +2027,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ TextureBrowser_buildTagList(); } { // tag menu bar - ui::Widget menu_tags = ui::Widget(gtk_menu_new()); + ui::Widget menu_tags = ui::Menu(); auto tags_item = TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 18975120..4e59f9f7 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1111,7 +1111,7 @@ void pushMenu( const std::string& name ){ gtk_widget_show( GTK_WIDGET( item ) ); container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) ); - GtkMenu* submenu = GTK_MENU( gtk_menu_new() ); + GtkMenu* submenu = ui::Menu(); gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) ); m_stack.push_back( MenuPair( submenu, name ) ); @@ -1154,7 +1154,7 @@ void XYWnd::OnContextMenu(){ } if ( m_mnuDrop == 0 ) { // first time, load it up - GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() ); + GtkMenu* menu = m_mnuDrop = ui::Menu(); EntityClassMenuInserter inserter( menu ); GlobalEntityClassManager().forEach( inserter );