Re: GtkTree row.set_value does not work
- From: "Luis A. Montes" <luis montes qdusa com>
- To: gtkmm-list gnome org
- Subject: Re: GtkTree row.set_value does not work
- Date: Wed, 16 Feb 2011 10:52:29 -0800
Hi there,
I'm still trying to figure out why this does not work. But now I do have
two minimal programs that try to set values to the tree store using the
set_value method. One uses plain Gtk+ and the other uses gtkmm. Both
read the same glade file using GtkBuilder. The Gtk+ program works, a row
with the desired value appears on the TreeView, but the gtkmm doesn't
work and outputs the following warning:
Gtk-WARNING **: gtktreestore.c:765: Unable to convert from
glibmm__CustomPointer_char++ to gchararray.
The programs are really simple, so I hope it's not to much of a deluge
if I quote them. They both compile without warnings. First the Gtk+
version:
//-------------------------------------------------------------------------
#include "gtk/gtk.h"
int main(int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
GtkTreeStore *store;
GtkTreeIter iter;
gtk_init( &argc, &argv );
builder = gtk_builder_new();
gtk_builder_add_from_file(builder,"GladeTest.glade",NULL);
window = GTK_WIDGET( gtk_builder_get_object(builder,"window1") );
store = GTK_TREE_STORE( gtk_builder_get_object(builder,"treestore1") );
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set (store, &iter, 0, "Hello", -1);
g_object_unref( G_OBJECT(builder) );
gtk_widget_show(window);
gtk_main();
return 0;
}
//-------------------------------------------------------------------------
And now the Gtkmm version:
//-------------------------------------------------------------------------
#include <gtkmm.h>
static Glib::RefPtr<Gtk::Builder> builder;
int main(int argc, char *argv[])
{
gchar buffer[]="Hello";
Gtk::Main kit(argc, argv);
builder = Gtk::Builder::create_from_file("GladeTest.glade");
Glib::RefPtr<Gtk::TreeStore> tree_store =
Glib::RefPtr<Gtk::TreeStore>::cast_static(builder->get_object("treestore1"));
if (tree_store){
Gtk::TreeStore::Row row = *(tree_store->append());
row.set_value<gchararray>(0, &buffer[0]);
}
Gtk::Window* pWindow = 0;
builder->get_widget("window1", pWindow);
if (pWindow)
kit.run(*pWindow);
}
//-------------------------------------------------------------------------
Both use the same glade file:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkTreeStore" id="treestore1">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name type -->
<column type="gint"/>
</columns>
</object>
<object class="GtkWindow" id="window1">
<child>
<object class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">treestore1</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title">column</property>
<child>
<object class="GtkCellRendererText"
id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]