From 6e5f6c7c609dd0b478b95df672af4093a7a5b3ac Mon Sep 17 00:00:00 2001
From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= <vslavik@fastmail.fm>
Date: Wed, 30 May 2007 13:50:36 +0000
Subject: [PATCH] changed wxWindow::ApplyToolTip to take UTF8-encoded char*
 instead of wxChar* to avoid unnecessary conversions

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46248 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/gtk/listbox.h  |  2 +-
 include/wx/gtk/radiobox.h |  2 +-
 include/wx/gtk/tooltip.h  |  2 +-
 include/wx/gtk/window.h   |  3 ++-
 src/gtk/listbox.cpp       |  4 ++--
 src/gtk/radiobox.cpp      |  5 ++---
 src/gtk/tooltip.cpp       |  6 +++---
 src/gtk/window.cpp        | 12 ++----------
 8 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h
index 245e537752..c855e3d688 100644
--- a/include/wx/gtk/listbox.h
+++ b/include/wx/gtk/listbox.h
@@ -85,7 +85,7 @@ public:
     GtkWidget *GetConnectWidget();
 
 #if wxUSE_TOOLTIPS
-    void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
+    void ApplyToolTip( GtkTooltips *tips, const gchar *tip );
 #endif // wxUSE_TOOLTIPS
 
     struct _GtkTreeView   *m_treeview;
diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h
index 77bbb3a066..563ebb5612 100644
--- a/include/wx/gtk/radiobox.h
+++ b/include/wx/gtk/radiobox.h
@@ -132,7 +132,7 @@ public:
     void GtkDisableEvents();
     void GtkEnableEvents();
 #if wxUSE_TOOLTIPS
-    void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
+    void ApplyToolTip( GtkTooltips *tips, const gchar *tip );
 #endif // wxUSE_TOOLTIPS
 
     virtual void OnInternalIdle();
diff --git a/include/wx/gtk/tooltip.h b/include/wx/gtk/tooltip.h
index ad476e5ecb..c2ed58bfe4 100644
--- a/include/wx/gtk/tooltip.h
+++ b/include/wx/gtk/tooltip.h
@@ -50,7 +50,7 @@ public:
     // this just sets the given tooltip for the specified widget
     //
     // tip must be already UTF-8 encoded
-    static void Apply(GtkWidget *w, const wxCharBuffer& tip);
+    static void Apply(GtkWidget *w, const gchar *tip);
 
 private:
     wxString     m_text;
diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h
index 962e33bc67..b98ee769da 100644
--- a/include/wx/gtk/window.h
+++ b/include/wx/gtk/window.h
@@ -209,7 +209,8 @@ public:
     PangoContext   *GtkGetPangoDefaultContext();
 
 #if wxUSE_TOOLTIPS
-    virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
+    // applies tooltip to the widget (tip must be UTF-8 encoded)
+    virtual void ApplyToolTip( GtkTooltips *tips, const gchar *tip );
 #endif // wxUSE_TOOLTIPS
 
     // Called when a window should delay showing itself
diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp
index c244394fcd..15c70a351d 100644
--- a/src/gtk/listbox.cpp
+++ b/src/gtk/listbox.cpp
@@ -886,10 +886,10 @@ int wxListBox::DoListHitTest(const wxPoint& point) const
 // ----------------------------------------------------------------------------
 
 #if wxUSE_TOOLTIPS
-void wxListBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
+void wxListBox::ApplyToolTip( GtkTooltips *tips, const gchar *tip )
 {
     // RN: Is this needed anymore?
-    gtk_tooltips_set_tip( tips, GTK_WIDGET( m_treeview ), wxGTK_CONV(tip), (gchar*) NULL );
+    gtk_tooltips_set_tip( tips, GTK_WIDGET( m_treeview ), tip, (gchar*) NULL );
 }
 #endif // wxUSE_TOOLTIPS
 
diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp
index 027b8d05ee..e5bb933d2b 100644
--- a/src/gtk/radiobox.cpp
+++ b/src/gtk/radiobox.cpp
@@ -601,7 +601,7 @@ void wxRadioBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
 }
 
 #if wxUSE_TOOLTIPS
-void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const wxChar *tip)
+void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const gchar *tip)
 {
     // set this tooltip for all radiobuttons which don't have their own tips
     unsigned n = 0;
@@ -611,8 +611,7 @@ void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const wxChar *tip)
     {
         if ( !GetItemToolTip(n) )
         {
-            wxToolTip::Apply(GTK_WIDGET(node->GetData()->button),
-                             wxConvCurrent->cWX2MB(tip));
+            wxToolTip::Apply(GTK_WIDGET(node->GetData()->button), tip);
         }
     }
 }
diff --git a/src/gtk/tooltip.cpp b/src/gtk/tooltip.cpp
index c46b6f9190..a02aedd620 100644
--- a/src/gtk/tooltip.cpp
+++ b/src/gtk/tooltip.cpp
@@ -55,13 +55,13 @@ void wxToolTip::Apply( wxWindow *win )
     m_window = win;
 
     if (m_text.empty())
-        m_window->ApplyToolTip( gs_tooltips, (wxChar*) NULL );
+        m_window->ApplyToolTip( gs_tooltips, NULL );
     else
-        m_window->ApplyToolTip( gs_tooltips, m_text );
+        m_window->ApplyToolTip( gs_tooltips, wxGTK_CONV_SYS(m_text) );
 }
 
 /* static */
-void wxToolTip::Apply(GtkWidget *w, const wxCharBuffer& tip)
+void wxToolTip::Apply(GtkWidget *w, const gchar *tip)
 {
     if ( !gs_tooltips )
         gs_tooltips = gtk_tooltips_new();
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index 0eb815a39d..cbc1486f6b 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -3812,17 +3812,9 @@ void wxWindowGTK::DoSetToolTip( wxToolTip *tip )
         m_tooltip->Apply( (wxWindow *)this );
 }
 
-void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
+void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const gchar *tip )
 {
-    if (tip)
-    {
-        wxString tmp( tip );
-        gtk_tooltips_set_tip( tips, GetConnectWidget(), wxGTK_CONV(tmp), (gchar*) NULL );
-    }
-    else
-    {
-        gtk_tooltips_set_tip( tips, GetConnectWidget(), NULL, NULL);
-    }
+    gtk_tooltips_set_tip(tips, GetConnectWidget(), tip, NULL);
 }
 #endif // wxUSE_TOOLTIPS
 
-- 
2.47.2