static gint gtk_listbox_sort_callback(GtkTreeModel * WXUNUSED(model), GtkTreeIter *a, GtkTreeIter *b, wxListBox *listbox) { GtkTreeEntry* entry; GtkTreeEntry* entry2; gtk_tree_model_get(GTK_TREE_MODEL(listbox->m_liststore), a, WXLISTBOX_DATACOLUMN_ARG(listbox), &entry, -1); gtk_tree_model_get(GTK_TREE_MODEL(listbox->m_liststore), b, WXLISTBOX_DATACOLUMN_ARG(listbox), &entry2, -1); wxCHECK_MSG(entry, 0, wxT("Could not get entry")); wxCHECK_MSG(entry2, 0, wxT("Could not get entry2")); //We compare collate keys here instead of calling g_utf8_collate //as it is rather slow (and even the docs reccommend this) int ret = strcmp(gtk_tree_entry_get_collate_key(entry), gtk_tree_entry_get_collate_key(entry2)); g_object_unref (entry); g_object_unref (entry2); return ret; }
static gint gtk_listbox_sort_callback(GtkTreeModel * WXUNUSED(model), GtkTreeIter *a, GtkTreeIter *b, wxListBox *listbox) { wxGtkObject<GtkTreeEntry> entry1(GetEntry(listbox->m_liststore, a, listbox)); wxCHECK_MSG(entry1, 0, wxT("Could not get first entry")); wxGtkObject<GtkTreeEntry> entry2(GetEntry(listbox->m_liststore, b, listbox)); wxCHECK_MSG(entry2, 0, wxT("Could not get second entry")); //We compare collate keys here instead of calling g_utf8_collate //as it is rather slow (and even the docs recommend this) return strcmp(gtk_tree_entry_get_collate_key(entry1), gtk_tree_entry_get_collate_key(entry2)) >= 0; }
static gboolean gtk_listbox_searchequal_callback(GtkTreeModel * WXUNUSED(model), gint WXUNUSED(column), const gchar* key, GtkTreeIter* iter, wxListBox* listbox) { wxGtkObject<GtkTreeEntry> entry(GetEntry(listbox->m_liststore, iter, listbox)); wxCHECK_MSG(entry, 0, wxT("Could not get entry")); wxGtkString keycollatekey(g_utf8_collate_key(key, -1)); return strcmp(keycollatekey, gtk_tree_entry_get_collate_key(entry)) != 0; }
static gboolean gtk_listbox_searchequal_callback(GtkTreeModel * WXUNUSED(model), gint WXUNUSED(column), const gchar* key, GtkTreeIter* iter, wxListBox* listbox) { GtkTreeEntry* entry; gtk_tree_model_get(GTK_TREE_MODEL(listbox->m_liststore), iter, WXLISTBOX_DATACOLUMN_ARG(listbox), &entry, -1); wxCHECK_MSG(entry, 0, wxT("Could not get entry")); wxGtkString keycollatekey(g_utf8_collate_key(key, -1)); int ret = strcmp(keycollatekey, gtk_tree_entry_get_collate_key(entry)); g_object_unref (entry); return ret != 0; }