[Glade-users] liststore with GObjects

Alexey Kurochkin alexey.kurochkin at pathfinderlwd.com
Thu Aug 20 12:51:47 EDT 2009


On Thu, 2009-08-20 at 12:04 -0400, Tristan Van Berkom wrote:
> On Thu, Aug 20, 2009 at 11:54 AM, Alexey
> Kurochkin<alexey.kurochkin at pathfinderlwd.com> wrote:
> [...]
> >> Yes, note that GObjects in the liststore are be passed by
> >> reference (i.e. the value of an object column is the id/name
> >> of the referred object in the file... the same object can show
> >> up in multiple rows and columns...).
> >
> > If you mean replacing <col id="0" /> which Glade generates for GObject
> > column with something like this:
> >
> > <col id="0">adjustment1</col>
> >
> > then it does not work. It segfaults... :(
> >
> 
> Does it ? try manually placing the adjustment definition /before/ the
> liststore definition.
> 
> As a liststore can refer to many different types I doubt its a good
> policy to force all
> reffered objects to be before the liststore, so, if the above formula
> successfully
> works around the segfault, I would call it a bug in GTK+ (that the
> liststore does
> not wait for the "finished" signal to resolve referred objects by id).

Nope, the same result. If you care to look, attached is a simple test. 

By the way, I have gtk+2.14.5 source here and do not see liststore
implementing anything called "finished", only custom_tag_start and
custom_tag_end.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.ui
Type: application/x-designer
Size: 604 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/glade-users/attachments/20090820/08fa1c93/attachment.bin 
-------------- next part --------------
#include <gtk/gtk.h>

int main (int argc, char **argv)
{
	GtkBuilder *builder;
	GObject *mylist;
	GObject *myadj;
	GtkTreeIter iter;

	gtk_init (&argc, &argv);
	builder = gtk_builder_new();
	gtk_builder_add_from_file(builder, "list.ui", NULL);
	mylist = gtk_builder_get_object(builder,"liststore1");
	myadj = gtk_builder_get_object(builder,"adjustment1");
	g_object_ref (mylist);
	g_object_ref (myadj);
	g_object_unref (builder);

	if (GTK_IS_LIST_STORE (mylist))
	{
		g_message ("List created successfully");
		if (GTK_IS_ADJUSTMENT (myadj))
			g_message ("Adjustment created successfully");
		else
			g_warning ("Adjustment was not created");
		if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (mylist), &iter))
		{
			GObject *myobj;
			gchar *mytext;

			do
			{
				gtk_tree_model_get (GTK_TREE_MODEL (mylist), &iter,
					0, &myobj,
					1, &mytext,
					-1);
				if (myobj)
				{
					g_message ("Object described as %s is %s", mytext, GTK_IS_ADJUSTMENT (myobj) ? "indeed adjustment" : "actually nonsense");
					g_object_unref (myobj);
				}
				else
					g_warning ("Object described as %s is empty", mytext);
				g_free (mytext);
			} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (mylist), &iter));
		}
		else
			g_warning ("List is empty");
	}
	else
		g_warning ("List was not created at all");
//	gtk_main();
	return 0;
}



More information about the Glade-users mailing list