]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Wrap GtkMenuItem
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 03:24:46 +0000 (14:24 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 03:24:46 +0000 (14:24 +1100)
contrib/prtview/ConfigDialog.cpp
libs/gtkutil/menu.cpp
libs/uilib/uilib.cpp
libs/uilib/uilib.h
plugins/textool/2DView.cpp
radiant/console.cpp
radiant/pluginmenu.cpp
radiant/texwindow.cpp
radiant/xywindow.cpp

index 97d55d27f4225e922a3d353c331c4929b5c4c271..f2295d14001d00e168e223fe38bbf74fd57287a8 100644 (file)
@@ -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 ) );
index cbb07df8fef5518fbee2238258c9c05cb9b1d451..8b9471f17f116bf90ae1428fa1be7a6d2e1163fe 100644 (file)
@@ -27,6 +27,7 @@
 #include <gtk/gtkradiomenuitem.h>
 #include <gtk/gtktearoffmenuitem.h>
 #include <gtk/gtkaccellabel.h>
+#include <uilib/uilib.h>
 
 #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;
index 54b4a3a35c46612914b6a0313c2ce6b7dfa82d6c..54b7f510b8dcbc41e5518ad30e15a54f91265277 100644 (file)
@@ -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)))
     { }
 
index 4d9d252a2b907139b9b8ffd8e3218ae14e520235..f3d7a5db21a7674ca6409f5a802e07be2770b014 100644 (file)
@@ -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();
index 4da3fab3b91d203a64daac3745e9e3ffbe170fd9..993bc13d70330df2f4dd19d239b8150f76f1d578 100644 (file)
@@ -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 );
index bbf99fc899f3b78df10e0f6216aa5d4ce8e95855..4530bc290ba339175ee67c036f40001d20e8231f 100644 (file)
@@ -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 );
index 56fcd61daa9f1048155b9e5c3a0a3dc0593ff892..06cf3de7556b896d47ef0ea6f979d287c0c8f82b 100644 (file)
@@ -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<gpointer>( static_cast<const void*>( menuCommand ) ) );
                                        g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) );
                                }
index fc3ab0b2a94edec0378c08a83c010870394991c1..b24f042297d769d47fa16a2a638c86c7c8aa0aef 100644 (file)
@@ -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 );
 
index 686b9bfcd31fdb5d8216a081212594ec8cd12123..18975120edcb9863ed8f6a4227be1e64422f2035 100644 (file)
@@ -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 ) );