Sign up

Problems with Custom TreeModels and ComboBox

Sorry to bug again, but I'm hitting a stumbling block again. I'm using a custom TreeModel based on CustomList.d from the demo, and while it's working fine put into a TreeView, I'm having some weird OS-specific problems when I put it into a ComboBox

On Windows, the popup seems to work unless I use setWrapWidth, in which case I get a blank single-pixel popup.
On Linux, it's the same if I use setWrapWidth, but if I don't use setWrapWidth, the popup is still blank, but full width.

I'm able to reproduce the behavior with a small change to DemoCustomList.d:

module DemoCostumList;

import CustomList;

import glib.RandG;
import gtk.Main;
import gtk.ScrolledWindow;
import gtk.MainWindow;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.CellRendererText;
import gtk.ListStore;
import gtk.ComboBox;

class CustomListWindow : MainWindow
{
	this()
	{
		super("GtkD - Custom TreeModel");
		setDefaultSize(200, 400);
		
		ScrolledWindow scrollwin = new ScrolledWindow();
		ComboBox view = createViewAndModel();

		scrollwin.add(view);
		add(scrollwin);

		showAll();
	}

	ComboBox createViewAndModel()
	{
		TreeViewColumn   col;
		CellRendererText renderer;
		CustomList       customlist;
		//TreeView         view;
		ComboBox view;

		customlist = new CustomList();
		fillModel(customlist);
		
		//view = new TreeView(customlist);
		view = new ComboBox(customlist);
		
		//col = new TreeViewColumn();
		renderer  = new CellRendererText();
		view.packStart(renderer, true);
		//col.addAttribute(renderer, "text", CustomListColumn.Name);
		//col.setTitle("Name");
//		view.appendColumn(col);

//		col = new TreeViewColumn();
		renderer  = new CellRendererText();
		view.packStart(renderer, true);
//		col.addAttribute(renderer, "text", CustomListColumn.YearBorn);
//		col.setTitle("Year Born");
	//	view.appendColumn(col);

		return view;
	}

	void fillModel (CustomList customlist)
	{
		string[]  firstnames = [ "Joe", "Jane", "William", "Hannibal", "Timothy", "Gargamel" ];
		string[]  surnames   = [ "Grokowich", "Twitch", "Borheimer", "Bork" ];

		foreach (sname; surnames)
		{
			foreach (fname; firstnames)
			{
				customlist.appendRecord(fname ~" "~ sname, 1900 + (RandG.randomInt() % 100));
			}
		}
	}
}

void main (string[] arg)
{
	Main.init(arg);

	new CustomListWindow();

	Main.run();
}

This is on the GTK2 branch, if that affects anything.

Re: Problems with Custom TreeModels and ComboBox

Additionally, I don't have the problems when I use a ListStore to power the ComboBox; that works just fine both with and without setWrapWidth(), which is why I think the problem is somewhere in GtkD or CustomList.

Re: Problems with Custom TreeModels and ComboBox

On 01/09/2014 08:35 PM, E.S. Quinn wrote:

Sorry to bug again, but I'm hitting a stumbling block again. I'm using a custom TreeModel based on CustomList.d from the demo, and while it's working fine put into a TreeView, I'm having some weird OS-specific problems when I put it into a ComboBox

On Windows, the popup seems to work unless I use setWrapWidth, in which case I get a blank single-pixel popup.
On Linux, it's the same if I use setWrapWidth, but if I don't use setWrapWidth, the popup is still blank, but full width.

I'm able to reproduce the behavior with a small change to DemoCustomList.d:

... code ...

This is on the GTK2 branch, if that affects anything.

After you add the renderer to the combobox you'll have to tell it which
column to render using:

view.addAttribute(renderer, "text", CustomListColumn.Name);

and for the second renderer / column:

view.addAttribute(renderer, "text", CustomListColumn.YearBorn);

Re: Problems with Custom TreeModels and ComboBox

On Thu, 09 Jan 2014 23:50:57 +0100, Mike Wey wrote:

On 01/09/2014 08:35 PM, E.S. Quinn wrote:

Sorry to bug again, but I'm hitting a stumbling block again. I'm using a custom TreeModel based on CustomList.d from the demo, and while it's working fine put into a TreeView, I'm having some weird OS-specific problems when I put it into a ComboBox

On Windows, the popup seems to work unless I use setWrapWidth, in which case I get a blank single-pixel popup.
On Linux, it's the same if I use setWrapWidth, but if I don't use setWrapWidth, the popup is still blank, but full width.

I'm able to reproduce the behavior with a small change to DemoCustomList.d:

... code ...

This is on the GTK2 branch, if that affects anything.

After you add the renderer to the combobox you'll have to tell it which
column to render using:

view.addAttribute(renderer, "text", CustomListColumn.Name);

and for the second renderer / column:

view.addAttribute(renderer, "text", CustomListColumn.YearBorn);

Oh! Sorry, that was a mistake in my "reduced" testcase. I still get the problem when I add the attribute properly. I've also tried both Pixbuf and Text CellRenderers (my TreeModel has columns for both)

Re: Problems with Custom TreeModels and ComboBox

It occurs to me I may have described the problem poorly--here's a screenshot of the problem with the Linux version (On windows the non-wrapped one does work, but the wrapped one looks identical.)

Without using setWrapWidth: https://dl.dropboxusercontent.com/u/187059/ComboBox-nowrapwidth.png
With setWrapWidth: https://dl.dropboxusercontent.com/u/187059/ComboBox-wrapwidth.png

I'm using DMD 2.064 on both OSes, the latest Git update of GtkD1, and the latest official GTK 2.24 runtime on windows, the latest Ubuntu 13.10 GTK 2.24 package. 32-bit on Windows, and 64-bit on Linux. And this problem doesn't show up if I use a gtk.ListStore as the model for the ComboBox; both wrapped and unwrapped popups render fine in that case.

Re: Problems with Custom TreeModels and ComboBox

On 01/10/2014 08:09 PM, E.S. Quinn wrote:

It occurs to me I may have described the problem poorly--here's a screenshot of the problem with the Linux version (On windows the non-wrapped one does work, but the wrapped one looks identical.)

Without using setWrapWidth: https://dl.dropboxusercontent.com/u/187059/ComboBox-nowrapwidth.png
With setWrapWidth: https://dl.dropboxusercontent.com/u/187059/ComboBox-wrapwidth.png

I'm using DMD 2.064 on both OSes, the latest Git update of GtkD1, and the latest official GTK 2.24 runtime on windows, the latest Ubuntu 13.10 GTK 2.24 package. 32-bit on Windows, and 64-bit on Linux. And this problem doesn't show up if I use a gtk.ListStore as the model for the ComboBox; both wrapped and unwrapped popups render fine in that case.

I was using Gtk3 / GtkD master. I indeed have the same issue with Gtk2.

Re: Problems with Custom TreeModels and ComboBox

On 01/10/2014 08:25 PM, Mike Wey wrote:

On 01/10/2014 08:09 PM, E.S. Quinn wrote:

It occurs to me I may have described the problem poorly--here's a
screenshot of the problem with the Linux version (On windows the
non-wrapped one does work, but the wrapped one looks identical.)

Without using setWrapWidth:
https://dl.dropboxusercontent.com/u/187059/ComboBox-nowrapwidth.png
With setWrapWidth:
https://dl.dropboxusercontent.com/u/187059/ComboBox-wrapwidth.png

I'm using DMD 2.064 on both OSes, the latest Git update of GtkD1, and
the latest official GTK 2.24 runtime on windows, the latest Ubuntu
13.10 GTK 2.24 package. 32-bit on Windows, and 64-bit on Linux. And
this problem doesn't show up if I use a gtk.ListStore as the model for
the ComboBox; both wrapped and unwrapped popups render fine in that case.

I was using Gtk3 / GtkD master. I indeed have the same issue with Gtk2.

I also can't reproduce the problem in C so it's defiantly a bug in GtkD.

Re: Problems with Custom TreeModels and ComboBox

Fixed in git Head.

With these two commits.

GtkD didn't check fot null when creating Objects:
https://github.com/gtkd-developers/GtkD/commit/c99e2ff228fea744297a2838032831cb1d1aa8da

A small typo in the CustomList implementation:
https://github.com/gtkd-developers/GtkD/commit/169f1583c35fdc1c13f8768acb777955b2a44f82

Re: Problems with Custom TreeModels and ComboBox

On Sun, 12 Jan 2014 14:25:59 +0100, Mike Wey wrote:

Fixed in git Head.

With these two commits.

GtkD didn't check fot null when creating Objects:
https://github.com/gtkd-developers/GtkD/commit/c99e2ff228fea744297a2838032831cb1d1aa8da

A small typo in the CustomList implementation:
https://github.com/gtkd-developers/GtkD/commit/169f1583c35fdc1c13f8768acb777955b2a44f82

Thank you! Works fine now.