GNOME Bugzilla – Bug 604150
subclassing GtkTreeModelFilter
Last modified: 2010-05-04 01:55:19 UTC
Created attachment 149411 [details] [review] implementation As it stands, GtkTreeModelFilter doesn't provide its visible and modify functions as vcalls you can implement in a subclass. If you want to provide a class with some filtering options, you have to set the function in init(), which makes it possible for someone to accidentally replace the filtering function, and break your subclass. This patch exposes the visible() and modify() methods as vcalls in the class structure, allowing them to be implemented by a subclass. The subclass can then choose whether or not to chain-up the parent implementation (e.g. for additional custom filtering). Here is an example from the upcoming Telepathy-Gtk, where the user can set the show_hidden property (more properties to come in the future) and then still add additional custom filtering if she wishes: static gboolean tp_gtk_roster_model_filter_visible (GtkTreeModelFilter *self, GtkTreeModel *child_model, GtkTreeIter *iter) { TpGtkRosterModelFilterPrivate *priv = GET_PRIVATE (self); TpGtkRosterModelColumnType type; TpConnectionPresenceType state; gboolean v; gtk_tree_model_get (child_model, iter, TP_GTK_ROSTER_MODEL_CONTACT, &type, TP_GTK_ROSTER_MODEL_STATE, &state, -1); v = (priv->show_hidden || type == TP_GTK_ROSTER_MODEL_COLUMN_TYPE_GROUP || (state != TP_CONNECTION_PRESENCE_TYPE_UNSET && state != TP_CONNECTION_PRESENCE_TYPE_OFFLINE && state != TP_CONNECTION_PRESENCE_TYPE_UNKNOWN && state != TP_CONNECTION_PRESENCE_TYPE_ERROR)); return v && GTK_TREE_MODEL_FILTER_CLASS (tp_gtk_roster_model_filter_parent_class)->visible (self, child_model, iter); } http://git.collabora.co.uk/?p=user/danni/gtk%2B.git;a=commitdiff;h=850f2681cdf632d5afa616538d4403c2b9e40854
Patch seems fine, but please make sure the test suite for the filter model still passes. See also my mail to gtk-devel-list.
Danielle, Did you verify that the test suite for the filter model still passes?
Comment on attachment 149411 [details] [review] implementation I tried the patch here and all gtk/tests/filtermodel tests are paseed. But the patch introduces some compilation warnings that would be great get fixed
For reference, this is the kris mail: http://mail.gnome.org/archives/gtk-devel-list/2009-December/msg00048.html
Comment on attachment 149411 [details] [review] implementation commit 227d59c19015d488eda2895c1022b95ac1463d2a
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.