After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 94170 - TreeModelColumns cannot be of type "UNSIGNED SHORT"
TreeModelColumns cannot be of type "UNSIGNED SHORT"
Status: VERIFIED NOTABUG
Product: gtkmm
Classification: Bindings
Component: TreeView
2.0
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-09-25 12:40 UTC by Patrick L. Polzer
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Patrick L. Polzer 2002-09-25 12:40:36 UTC
Try to create a TreeModel::ColumnRecord with a column like this:

Gtk::TreeModelColumn<unsigned short> my_unsigned_short;

and you get a lot of:

"GLib-GObject-WARNING **: unable to set property `text' of type 
`gchararray' from value of type `glibmm__CustomBoxed_Us'"

and cannot assign values to this column.
I didn't try this with other variable types and use normal signed integers 
now.


Thank you for your time,

Leslie
Comment 1 Murray Cumming 2002-09-29 19:39:26 UTC
I think we need to see some simple-as-possible compilable test code to
show this.
Comment 2 Patrick L. Polzer 2002-09-30 12:05:44 UTC
There you go.. The example clearly shows that both unsigned and 
signed int work, but none of the short types.


#include <gtkmm/box.h>
#include <gtkmm/window.h>
#include <gtkmm/main.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>

/* column definition */
class MyColumns : public Gtk::TreeModel::ColumnRecord
{
	public:
		inline MyColumns()
		{
			add(s_sh_test);
			add(us_sh_test);
			add(s_int_test);
			add(us_int_test);
		}

		Gtk::TreeModelColumn<signed short> s_sh_test;
		Gtk::TreeModelColumn<unsigned short> us_sh_test;
		Gtk::TreeModelColumn<signed int> s_int_test;
		Gtk::TreeModelColumn<unsigned int> us_int_test;
};


/* main window */
class MainWindow : public Gtk::Window
{
	public:
		MainWindow();
		inline ~MainWindow() {}

	protected:
		Gtk::VBox box1;
		Gtk::TreeView myview;
		MyColumns mycolumns;
};


MainWindow::MainWindow()
{

	Glib::RefPtr<Gtk::ListStore> mylist_ListStore = 
Gtk::ListStore::create(mycolumns);
	Gtk::TreeModel::iterator mylistRowPtr;
	Gtk::TreeModel::Row mylistRow;

	myview.set_model(mylist_ListStore);

	myview.append_column("Signed Short", 
mycolumns.s_sh_test);
	myview.append_column("Unsigned Short", 
mycolumns.us_sh_test);
	myview.append_column("Signed Int", mycolumns.s_int_test);
	myview.append_column("Unsigned Int", 
mycolumns.us_int_test);

	for (int i = 0; i <= 3; i++)
	{
		(myview.get_column(i))->set_clickable(TRUE);
		(myview.get_column(i))->set_resizable(TRUE);
		(myview.get_column(i))->set_sort_indicator(TRUE);
	}

	this->add(box1);


	mylistRowPtr = mylist_ListStore->append();
	mylistRow = *mylistRowPtr;

	mylistRow[mycolumns.s_sh_test] = 1;
	mylistRow[mycolumns.us_sh_test] = 1;
	mylistRow[mycolumns.s_int_test] = 1;
	mylistRow[mycolumns.us_int_test] = 1;
	

	box1.pack_start(myview);

	myview.show();
	box1.show();

}

/* entry point */
int main(int argc, char **argv)
{

	Gtk::Main *test = new Gtk::Main(argc, argv);

	MainWindow mw;
	test->run(mw);

	return(0);
}
Comment 3 Patrick L. Polzer 2002-09-30 12:12:55 UTC
Note:

If you change the

myview.append_column("Signed Short", mycolumns.s_sh_test);
myview.append_column("Unsigned Short", mycolumns.us_sh_test);

to 

myview.append_column_editable(...);

the code won't even compile.
Comment 4 Daniel Elstner 2002-09-30 19:57:03 UTC
This is a GLib problem -- there is no GValue implementation for
"unsigned short".  However, with gtkmm2 a custom GValue implementation
is generated automatically and should work.  You're getting this error
message

"GLib-GObject-WARNING **: unable to set property `text' of type 
`gchararray' from value of type `glibmm__CustomBoxed_Us'"

because you'd have to set up your own cell_data_func callbacks -- GTK+
doesn't know about the type.

However, the reason why there's no GValue implementation for signed or
unsigned short is that it wouldn't save you any space (GValue is
padded up anyway) and rarely needed at all.

--Daniel
Comment 5 Patrick L. Polzer 2002-10-01 06:54:34 UTC
Thank you, Daniel - but why is

+You're getting this error message
+ [...]
+because you'd have to set up your own cell_data_func callbacks -- 
+GTK+ doesn't know about the type.

not true for the bool-type, for which a call_data_func_cb is also 
necessary?
Comment 6 Murray Cumming 2002-10-04 19:04:10 UTC
Daniel?
Comment 7 Daniel Elstner 2002-10-10 19:55:32 UTC
The cell data callback is probably necessary for you because you're
using Gtk::CellRendererString to display it -- if you'd use
Gtk::CellRendererToggle it'd work out of the box.  GTK+ does know
about the bool type, it's just that there isn't a standard
CellRenderer that does what you want to do with it (displaying "true"
or "false" I guess).

You can see what types are available by looking at the Glib reference
docs for Glib::Value<> specializations.

(BTW: Murray, why did you exclude the Glib::Value<> specializations
for strings from the docs?  I don't see the reason for doing so
especially since all the other ones are still shown.)