c - GTKButton with GtkListStore -
i tried add gtkbutton gtkliststore edit data in each row... button doesn't appear, , error message : "glib-gobject-warning **: unable set property text' of type
gchararray' value of type `gtkbutton'". here code :
#include <gtk/gtk.h> gtktreemodel * create_and_fill_model() { gtkliststore *store; gtktreeiter iter; store = gtk_list_store_new (9, g_type_string, g_type_string, g_type_string, g_type_string, g_type_string, g_type_string, g_type_uint, g_type_float, gtk_type_button); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, "a5525654", 1, "dfffccn", 2, "doe", 3, "john", 4, "m", 5, "casablanca", 6, 2014, 7, 18.22, 8,gtk_button(gtk_button_new_with_label("edit")), -1); return gtk_tree_model (store); } gtkwidget * create_view_and_model() { gtkcellrenderer *renderer; gtktreemodel *model; gtkwidget *view; view = gtk_tree_view_new (); char colonne[9][16] = { "cin", "cne", "nom", "prenom", "sexe", "etablissement", "annee obt", "note gener", "edit" }; int i; for(i=0; i<9; i++) { renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (gtk_tree_view (view), -1, colonne[i], renderer, "text", i, null); } model = create_and_fill_model (); gtk_tree_view_set_model (gtk_tree_view (view), model); g_object_unref (model); return view; } int main (int argc, char **argv) { gtkwidget *window; gtkwidget *view; gtk_init (&argc, &argv); window = gtk_window_new (gtk_window_toplevel); g_signal_connect (window, "delete_event", gtk_main_quit, null); view = create_view_and_model (); gtk_container_add (gtk_container (window), view); gtk_widget_show_all (window); gtk_main (); return 0; }
your implementation of placing button in tree view cannot work written. creating text renderer columns, , text renderer cannot draw gtk button. (you error while setting text
property on renderer based on button-typed column in model.)
one simple way of placing button in tree view putting clickable image in cell, shown this answer.
Comments
Post a Comment