X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3281dbc1c102de5b2dc081392d1a315e0739b6a..5778dedc92f6d31435aa1cda6846979a0e9ad35b:/src/gtk/combobox.cpp?ds=sidebyside diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 7b0fe35ba7..1743505cac 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -44,6 +44,20 @@ gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { combo->SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED); } + +static void +gtkcombobox_popupshown_callback(GObject *WXUNUSED(gobject), + GParamSpec *WXUNUSED(param_spec), + wxComboBox *combo) +{ + gboolean isShown; + g_object_get( combo->m_widget, "popup-shown", &isShown, NULL ); + wxCommandEvent event( isShown ? wxEVT_COMMAND_COMBOBOX_DROPDOWN + : wxEVT_COMMAND_COMBOBOX_CLOSEUP, + combo->GetId() ); + event.SetEventObject( combo ); + combo->HandleWindowEvent( event ); +} } //----------------------------------------------------------------------------- @@ -158,6 +172,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, g_signal_connect_after (m_widget, "changed", G_CALLBACK (gtkcombobox_changed_callback), this); + if ( !gtk_check_version(2,10,0) ) + { + g_signal_connect (m_widget, "notify::popup-shown", + G_CALLBACK (gtkcombobox_popupshown_callback), this); + } + SetInitialSize(size); // need this too because this is a wxControlWithItems return true; @@ -202,7 +222,7 @@ void wxComboBox::OnChar( wxKeyEvent &event ) event.Skip(); } -void wxComboBox::DisableEvents() +void wxComboBox::GTKDisableEvents() { if ( GetEntry() ) g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child, @@ -210,9 +230,11 @@ void wxComboBox::DisableEvents() g_signal_handlers_block_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); + g_signal_handlers_block_by_func(m_widget, + (gpointer)gtkcombobox_popupshown_callback, this); } -void wxComboBox::EnableEvents() +void wxComboBox::GTKEnableEvents() { if ( GetEntry() ) g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child, @@ -220,6 +242,8 @@ void wxComboBox::EnableEvents() g_signal_handlers_unblock_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); + g_signal_handlers_unblock_by_func(m_widget, + (gpointer)gtkcombobox_popupshown_callback, this); } GtkWidget* wxComboBox::GetConnectWidget() @@ -227,10 +251,8 @@ GtkWidget* wxComboBox::GetConnectWidget() return GTK_WIDGET( GetEntry() ); } -GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const +GdkWindow* wxComboBox::GTKGetWindow(wxArrayGdkWindows& /* windows */) const { - wxUnusedVar(windows); - return GetEntry()->text_area; } @@ -315,4 +337,13 @@ void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event) event.Enable(!wxTextEntry::IsEmpty()); } +void wxComboBox::Popup() +{ + gtk_combo_box_popup( GTK_COMBO_BOX(m_widget) ); +} + +void wxComboBox::Dismiss() +{ + gtk_combo_box_popdown( GTK_COMBO_BOX(m_widget) ); +} #endif // wxUSE_COMBOBOX