]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/menu.cpp
cleanup - reformatting; simplified OnPaint
[wxWidgets.git] / src / gtk / menu.cpp
index 01902dc5b3a9327e11cf3334569e09bd29c2ed00..28fa85d2fced15c3f6673af3a9e8e55f45dbebbf 100644 (file)
@@ -185,10 +185,8 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
     //     don't get it when the menu is dismissed by clicking outside the
     //     toolbar) so we connect to the global one, even if it means that we
     //     can't pass the menu which was closed in wxMenuEvent object
-    gtk_signal_connect( GTK_OBJECT(GTK_MENU_SHELL(m_menubar)),
-                        "deactivate",
-                        GTK_SIGNAL_FUNC(gtk_menu_close_callback),
-                        (gpointer)this );
+    g_signal_connect (m_menubar, "deactivate",
+                      G_CALLBACK (gtk_menu_close_callback), this);
 
 }
 
@@ -311,9 +309,9 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
     else
         gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );
 
-    gtk_signal_connect( GTK_OBJECT(menu->m_owner), "activate",
-                        GTK_SIGNAL_FUNC(gtk_menu_open_callback),
-                        (gpointer)menu );
+    g_signal_connect (menu->m_owner, "activate",
+                      G_CALLBACK (gtk_menu_open_callback),
+                      menu);
 
     // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
     // addings menu later on.
@@ -513,17 +511,7 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label )
     menu->SetTitle( str );
 
     if (menu->m_owner)
-    {
-        GtkLabel *glabel = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
-
-        /* set new text */
-        gtk_label_set( glabel, wxGTK_CONV( str ) );
-
-        /* reparse key accel */
-        (void)gtk_label_parse_uline (GTK_LABEL(glabel), wxGTK_CONV( str ) );
-        gtk_accel_label_refetch( GTK_ACCEL_LABEL(glabel) );
-    }
-
+        gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN(menu->m_owner)->child), wxGTK_CONV(str) );
 }
 
 //-----------------------------------------------------------------------------
@@ -877,7 +865,7 @@ void wxMenuItem::Check( bool check )
     {
         case wxITEM_CHECK:
         case wxITEM_RADIO:
-            gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check );
+            gtk_check_menu_item_set_active( (GtkCheckMenuItem*)m_menuItem, (gint)check );
             break;
 
         default:
@@ -926,7 +914,7 @@ void wxMenu::Init()
     {
         GtkWidget *tearoff = gtk_tearoff_menu_item_new();
 
-        gtk_menu_append(GTK_MENU(m_menu), tearoff);
+        gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), tearoff);
     }
 
     m_prevRadio = NULL;
@@ -1062,13 +1050,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
     {
         wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
 
-        gtk_signal_connect( GTK_OBJECT(menuItem), "select",
-                            GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
-                            (gpointer)this );
-
-        gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
-                            GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
-                            (gpointer)this );
+        g_signal_connect (menuItem, "select",
+                          G_CALLBACK (gtk_menu_hilight_callback), this);
+        g_signal_connect (menuItem, "deselect",
+                          G_CALLBACK (gtk_menu_nolight_callback), this);
 
         if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
         {
@@ -1084,9 +1069,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
         }
         else
         {
-            gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
-                                GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
-                                (gpointer)this );
+            g_signal_connect (menuItem, "activate",
+                              G_CALLBACK (gtk_menu_clicked_callback),
+                              this);
         }
     }
 
@@ -1426,13 +1411,13 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
 
 #if wxUSE_MENUS_NATIVE
 
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
 void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting  )
 {
     *is_waiting = FALSE;
 }
 
-void SetInvokingWindow( wxMenu *menu, wxWindow* win )
+WXDLLIMPEXP_CORE void SetInvokingWindow( wxMenu *menu, wxWindow* win )
 {
     menu->SetInvokingWindow( win );
 
@@ -1449,7 +1434,7 @@ void SetInvokingWindow( wxMenu *menu, wxWindow* win )
     }
 }
 
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
 void wxPopupMenuPositionCallback( GtkMenu *menu,
                                   gint *x, gint *y,
                                   gboolean * WXUNUSED(whatever),
@@ -1485,10 +1470,9 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
 
     bool is_waiting = true;
 
-    gulong handler = gtk_signal_connect( GTK_OBJECT(menu->m_menu),
-                                         "hide",
-                                         GTK_SIGNAL_FUNC(gtk_pop_hide_callback),
-                                         (gpointer)&is_waiting );
+    gulong handler = g_signal_connect (menu->m_menu, "hide",
+                                       G_CALLBACK (gtk_pop_hide_callback),
+                                       &is_waiting);
 
     wxPoint pos;
     gpointer userdata;
@@ -1524,7 +1508,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
         gtk_main_iteration();
     }
 
-    gtk_signal_disconnect(GTK_OBJECT(menu->m_menu), handler);
+    g_signal_handler_disconnect (menu->m_menu, handler);
 
     wxMenuEvent eventClose(wxEVT_MENU_CLOSE, -1, menu);
     DoCommonMenuCallbackCode(menu, eventClose);