]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
Fix program not shutting down when using Ubuntu app menu.
[wxWidgets.git] / src / gtk / combobox.cpp
index 35a5e0fec81560896a0fb2a21167b88f5a2f50d2..6f84ab0a8adf7533076ffe3b1d0791c8b1c15a8a 100644 (file)
@@ -33,8 +33,6 @@ extern "C" {
 static void
 gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
 {
-    if (!combo->m_hasVMT) return;
-
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
     event.SetString( combo->GetValue() );
     event.SetEventObject( combo );
@@ -87,6 +85,12 @@ BEGIN_EVENT_TABLE(wxComboBox, wxChoice)
     EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll)
 END_EVENT_TABLE()
 
+wxComboBox::~wxComboBox()
+{
+    if (m_entry)
+        GTKDisconnect(m_entry);
+}
+
 void wxComboBox::Init()
 {
     m_entry = NULL;
@@ -169,6 +173,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
         g_signal_connect_after (entry, "changed",
                                 G_CALLBACK (gtkcombobox_text_changed_callback), this);
 
+        GTKConnectInsertTextSignal(entry);
         GTKConnectClipboardSignals(GTK_WIDGET(entry));
     }
 
@@ -183,8 +188,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
                           G_CALLBACK (gtkcombobox_popupshown_callback), this);
     }
 
-    SetInitialSize(size); // need this too because this is a wxControlWithItems
-
     return true;
 }
 
@@ -288,9 +291,9 @@ wxVisualAttributes
 wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
 {
 #ifdef __WXGTK3__
-    return GetDefaultAttributesFromGTKWidget(gtk_combo_box_new_with_entry, true);
+    return GetDefaultAttributesFromGTKWidget(gtk_combo_box_new_with_entry(), true);
 #else
-    return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true);
+    return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new(), true);
 #endif
 }
 
@@ -402,4 +405,21 @@ void wxComboBox::Dismiss()
 {
     gtk_combo_box_popdown( GTK_COMBO_BOX(m_widget) );
 }
+
+wxSize wxComboBox::DoGetSizeFromTextSize(int xlen, int ylen) const
+{
+    wxSize tsize( wxChoice::DoGetSizeFromTextSize(xlen, ylen) );
+
+    GtkEntry* entry = GetEntry();
+    if (entry)
+    {
+        // Add the margins we have previously set, but only the horizontal border
+        // as vertical one has been taken account in the previous call.
+        // Also get other GTK+ margins.
+        tsize.IncBy(GTKGetEntryMargins(entry).x, 0);
+    }
+
+    return tsize;
+}
+
 #endif // wxUSE_COMBOBOX