]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/infobar.cpp
Fix deprecating warning introduced in r72446.
[wxWidgets.git] / src / gtk / infobar.cpp
index 275f0199a8e3e5e210b7b2c415e9cdf431fb1ca3..9963cdb51683aa82351491a1403071e1162fd744 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     wxInfoBar implementation for GTK
 // Author:      Vadim Zeitlin
 // Created:     2009-09-27
 // Purpose:     wxInfoBar implementation for GTK
 // Author:      Vadim Zeitlin
 // Created:     2009-09-27
-// RCS-ID:      $Id: wxhead.cpp,v 1.10 2009-06-29 10:23:04 zeitlin Exp $
+// RCS-ID:      $Id$
 // Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -31,6 +31,7 @@
 #endif // WX_PRECOMP
 
 #include "wx/vector.h"
 #endif // WX_PRECOMP
 
 #include "wx/vector.h"
+#include "wx/stockitem.h"
 
 #include "wx/gtk/private.h"
 #include "wx/gtk/private/messagetype.h"
 
 #include "wx/gtk/private.h"
 #include "wx/gtk/private/messagetype.h"
@@ -81,8 +82,12 @@ namespace
 
 inline bool UseNative()
 {
 
 inline bool UseNative()
 {
+#ifdef __WXGTK3__
+    return true;
+#else
     // native GtkInfoBar widget is only available in GTK+ 2.18 and later
     return gtk_check_version(2, 18, 0) == 0;
     // native GtkInfoBar widget is only available in GTK+ 2.18 and later
     return gtk_check_version(2, 18, 0) == 0;
+#endif
 }
 
 } // anonymous namespace
 }
 
 } // anonymous namespace
@@ -143,7 +148,7 @@ bool wxInfoBar::Create(wxWindow *parent, wxWindowID winid)
     GTKConnectWidget("response", G_CALLBACK(wxgtk_infobar_response));
     GTKConnectWidget("close", G_CALLBACK(wxgtk_infobar_close));
 
     GTKConnectWidget("response", G_CALLBACK(wxgtk_infobar_response));
     GTKConnectWidget("close", G_CALLBACK(wxgtk_infobar_close));
 
-    return false;
+    return true;
 }
 
 wxInfoBar::~wxInfoBar()
 }
 
 wxInfoBar::~wxInfoBar()
@@ -177,17 +182,26 @@ void wxInfoBar::ShowMessage(const wxString& msg, int flags)
     UpdateParent();
 }
 
     UpdateParent();
 }
 
+void wxInfoBar::Dismiss()
+{
+    if ( !UseNative() )
+    {
+        wxInfoBarGeneric::Dismiss();
+        return;
+    }
+
+    Hide();
+
+    UpdateParent();
+}
+
 void wxInfoBar::GTKResponse(int btnid)
 {
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, btnid);
     event.SetEventObject(this);
 
     if ( !HandleWindowEvent(event) )
 void wxInfoBar::GTKResponse(int btnid)
 {
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, btnid);
     event.SetEventObject(this);
 
     if ( !HandleWindowEvent(event) )
-    {
-        Hide();
-
-        UpdateParent();
-    }
+        Dismiss();
 }
 
 GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)
 }
 
 GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)
@@ -199,9 +213,9 @@ GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)
     GtkWidget *button = gtk_info_bar_add_button
                         (
                             GTK_INFO_BAR(m_widget),
     GtkWidget *button = gtk_info_bar_add_button
                         (
                             GTK_INFO_BAR(m_widget),
-                            label.empty()
+                            (label.empty()
                                 ? GTKConvertMnemonics(wxGetStockGtkID(btnid))
                                 ? GTKConvertMnemonics(wxGetStockGtkID(btnid))
-                                : label,
+                                : label).utf8_str(),
                             btnid
                         );
 
                             btnid
                         );
 
@@ -245,16 +259,27 @@ void wxInfoBar::RemoveButton(wxWindowID btnid)
           i != buttons.rend();
           ++i )
     {
           i != buttons.rend();
           ++i )
     {
-        gtk_widget_destroy(i->button);
-        buttons.erase(i.base());
+        if (i->id == btnid)
+        {
+            gtk_widget_destroy(i->button);
+            buttons.erase(i.base());
 
 
-        // see comment in GTKAddButton()
-        InvalidateBestSize();
+            // see comment in GTKAddButton()
+            InvalidateBestSize();
 
 
-        return;
+            return;
+        }
     }
 
     wxFAIL_MSG( wxString::Format("button with id %d not found", btnid) );
 }
 
     }
 
     wxFAIL_MSG( wxString::Format("button with id %d not found", btnid) );
 }
 
+void wxInfoBar::DoApplyWidgetStyle(GtkRcStyle *style)
+{
+    wxInfoBarGeneric::DoApplyWidgetStyle(style);
+
+    if ( UseNative() )
+        GTKApplyStyle(m_impl->m_label, style);
+}
+
 #endif // wxUSE_INFOBAR
 #endif // wxUSE_INFOBAR