+extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
+extern wxCursor g_globalCursor;
+
+
+
+//-----------------------------------------------------------------------------
+// Macro to tell which row the strings are in (1 if native checklist, 0 if not)
+//-----------------------------------------------------------------------------
+
+#if wxUSE_CHECKLISTBOX && wxUSE_NATIVEGTKCHECKLIST
+# define WXLISTBOX_DATACOLUMN_ARG(x) (x->m_hasCheckBoxes ? 1 : 0)
+#else
+# define WXLISTBOX_DATACOLUMN_ARG(x) (0)
+#endif // wxUSE_CHECKLISTBOX && wxUSE_NATIVEGTKCHECKLIST
+
+#define WXLISTBOX_DATACOLUMN WXLISTBOX_DATACOLUMN_ARG(this)
+
+//-----------------------------------------------------------------------------
+// "row-activated"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void
+gtk_listbox_row_activated_callback(GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *col,
+ wxListBox *listbox)
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (g_blockEventsOnDrag) return;
+ if (g_blockEventsOnScroll) return;
+
+ if (!listbox->m_hasVMT) return;
+
+ //Notes:
+ //1) This is triggered by either a double-click or a space press
+ //2) We handle both here because
+ //2a) in the case of a space/keypress we can't really know
+ // which item was pressed on because we can't get coords
+ // from a keyevent
+ //2b) It seems more correct
+
+ int sel = gtk_tree_path_get_indices(path)[0];
+
+ if(!listbox->m_spacePressed)
+ {
+ //Assume it was double-click
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
+ event.SetEventObject( listbox );
+
+ if(listbox->IsSelected(sel))
+ {
+ GtkTreeEntry* entry = listbox->GtkGetEntry(sel);
+
+ if(entry)
+ {
+ event.SetInt(sel);
+ event.SetString(wxConvUTF8.cMB2WX(gtk_tree_entry_get_label(entry)));
+
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject(
+ (wxClientData*) gtk_tree_entry_get_userdata(entry) );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( gtk_tree_entry_get_userdata(entry) );
+ g_object_unref(G_OBJECT(entry));
+ }
+ else
+ {
+ wxLogSysError(wxT("Internal error - could not get entry for double-click"));
+ event.SetInt(-1);
+ }
+ }
+ else
+ event.SetInt(-1);
+
+ listbox->GetEventHandler()->ProcessEvent( event );
+ }
+ else
+ {
+ listbox->m_spacePressed = false; //don't block selection behaviour anymore
+
+ //Space was pressed - toggle the appropriate checkbox and the selection
+#if wxUSE_CHECKLISTBOX //Do it for both native and non-native
+ if (listbox->m_hasCheckBoxes)
+ {
+ wxCheckListBox *clb = (wxCheckListBox *)listbox;
+
+ clb->Check( sel, !clb->IsChecked(sel) );
+
+ wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
+ new_event.SetEventObject( listbox );
+ new_event.SetInt( sel );
+ listbox->GetEventHandler()->ProcessEvent( new_event );
+ }
+#endif // wxUSE_CHECKLISTBOX
+
+ if( (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) ||
+ ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) )
+ {
+ //toggle the selection + send event
+ listbox->GtkSetSelection(sel, !listbox->IsSelected( sel ), false);
+ }
+ }
+}
+}