]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
Made wxDataViewCtrl sample use a real, expandabl data tree
[wxWidgets.git] / src / gtk / combobox.cpp
index 807fdf895be61f671d357d828a911e5317482486..56acb506408c11545cf31dde107ab14020a948ab 100644 (file)
@@ -132,12 +132,12 @@ gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUS
     // Quickly set the value of the combo box
     // as GTK+ does that only AFTER the event
     // is sent.
-    g_signal_handlers_disconnect_by_func (GTK_COMBO (combo->GetHandle())->entry,
-                                          (gpointer) gtkcombo_text_changed_callback,
-                                          combo);
+    GtkWidget* entry = GTK_COMBO(combo->GetHandle())->entry;
+    g_signal_handlers_block_by_func(
+        entry, (gpointer)gtkcombo_text_changed_callback, combo);
     combo->SetValue( combo->GetStringSelection() );
-    g_signal_connect_after (GTK_COMBO (combo->GetHandle())->entry, "changed",
-                            G_CALLBACK (gtkcombo_text_changed_callback), combo);
+    g_signal_handlers_unblock_by_func(
+        entry, (gpointer)gtkcombo_text_changed_callback, combo);
 
     // throw a SELECTED event only if the combobox popup is hidden (wxID_NONE)
     // because when combobox popup is shown, gtkcombo_combo_select_child_callback is
@@ -242,7 +242,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
                          const wxString& name )
 {
     m_ignoreNextUpdate = false;
-    m_needParent = true;
     m_prevSelection = 0;
 
     if (!PreCreation( parent, pos, size ) ||
@@ -947,7 +946,10 @@ void wxComboBox::SetValue( const wxString& value )
 
     wxString tmp;
     if (!value.IsNull()) tmp = value;
+    
+    DisableEvents();
     gtk_entry_set_text( entry, wxGTK_CONV( tmp ) );
+    EnableEvents();
 
     InvalidateBestSize();
 }
@@ -1115,12 +1117,14 @@ void wxComboBox::Replace( long from, long to, const wxString& value )
     if (value.IsNull()) return;
     gint pos = (gint)to;
 
-#if wxUSE_UNICODE
-    wxCharBuffer buffer = wxConvUTF8.cWX2MB( value );
-    gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos );
+    // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer
+#if wxUSE_UNICODE_UTF8
+    const char *utf8 = value.utf8_str();
 #else
-    gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos );
+    wxCharBuffer buffer(value.utf8_str());
+    const char *utf8 = buffer;
 #endif
+    gtk_editable_insert_text(GTK_EDITABLE(entry), utf8, strlen(utf8), &pos);
 }
 
 void wxComboBox::SetSelection( long from, long to )
@@ -1210,20 +1214,20 @@ void wxComboBox::DisableEvents()
 #ifdef __WXGTK24__
     if (!gtk_check_version(2,4,0))
     {
-        g_signal_handlers_disconnect_by_func (GTK_BIN(m_widget)->child,
-                (gpointer)gtkcombobox_text_changed_callback, this);
+        g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
 
-        g_signal_handlers_disconnect_by_func (m_widget,
-                (gpointer)gtkcombobox_changed_callback, this);
+        g_signal_handlers_block_by_func(m_widget,
+            (gpointer)gtkcombobox_changed_callback, this);
     }
     else
 #endif
     {
-        g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->list,
-                (gpointer) gtkcombo_combo_select_child_callback, this);
+        g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->list,
+            (gpointer) gtkcombo_combo_select_child_callback, this);
 
-        g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->entry,
-                (gpointer) gtkcombo_text_changed_callback, this);
+        g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->entry,
+            (gpointer) gtkcombo_text_changed_callback, this);
     }
 }
 
@@ -1232,21 +1236,20 @@ void wxComboBox::EnableEvents()
 #ifdef __WXGTK24__
     if (!gtk_check_version(2,4,0))
     {
-        g_signal_connect_after (GTK_BIN(m_widget)->child, "changed",
-                            G_CALLBACK (gtkcombobox_text_changed_callback), this);
+        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
 
-        g_signal_connect_after (m_widget, "changed",
-                            G_CALLBACK (gtkcombobox_changed_callback), this);
+        g_signal_handlers_unblock_by_func(m_widget,
+            (gpointer)gtkcombobox_changed_callback, this);
     }
     else
 #endif
     {
-        g_signal_connect_after (GTK_COMBO(m_widget)->list, "select-child",
-                            G_CALLBACK (gtkcombo_combo_select_child_callback),
-                            this);
-        g_signal_connect_after (GTK_COMBO(m_widget)->entry, "changed",
-                            G_CALLBACK (gtkcombo_text_changed_callback),
-                            this );
+        g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->list,
+            (gpointer) gtkcombo_combo_select_child_callback, this);
+
+        g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->entry,
+            (gpointer) gtkcombo_text_changed_callback, this);
     }
 }