Re: Major changes happening at the get_headers method of TnyMsgFolderIface



On Tue, 2006-05-30 at 03:53 +0200, Philip Van Hoof wrote:
> On Tue, 2006-05-30 at 01:56 +0200, Philip Van Hoof wrote:
> > The API would change from the current one to something like this:
> > 
> > void tny_msg_folder_iface_get_headers (TnyMsgFolderIface *self,
> > 	 TnyListIface *headers, gboolean refresh);
> > 
> > And in a Gtk+ context it would be used like this:
> > 
> > TnyListIface *model = tny_msg_header_list_model_new ();
> > tny_msg_folder_iface_get_headers (folder, model, TRUE);
> > gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (model));
> 
> It's implemented in Subversion. There's one reference count wrong which
> will be fixed tomorrow.

The reference counting bug is fixed. The new API is now fully
functional. And a lot more simple an obvious than the old one:

This is how to assign the list as a model using a sorter:

#define MDL(o) TNY_MSG_HEADER_LIST_MODEL(o)
GtkTreeView *header_view = ...
GtkTreeModel *header_model, *sortable, *oldsortable;

TnyListIface *model = TNY_LIST_IFACE (
	tny_msg_header_list_model_new ());

tny_msg_folder_iface_get_headers (folder, model, FALSE);
header_model = GTK_TREE_MODEL (model);

tny_msg_header_list_model_set_folder (MDL (model), folder);
oldsortable = gtk_tree_view_get_model (header_view);

if (oldsortable && GTK_IS_TREE_MODEL_SORT (oldsortable))
{
	GtkTreeModel *oldmodel = gtk_tree_model_sort_get_model 
		(GTK_TREE_MODEL_SORT (oldsortable));
	if (oldmodel)
		g_object_unref (G_OBJECT (oldmodel));
	g_object_unref (G_OBJECT (oldsortable));
}

sortable = gtk_tree_model_sort_new_with_model (header_model);
gtk_tree_view_set_model (header_view, sortable);



-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]