GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Oct 25, 2014 8:40 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GtkTreeView - Edit Cells and Save Changes
PostPosted: Tue Dec 20, 2011 9:29 pm 
Offline

Joined: Tue Dec 20, 2011 9:20 pm
Posts: 3
hello,

(sorry for my bad english -.-)

i recently wrote a C based Gtk Program, which shows the content of a database in a GtkTreeView-Widget. The content should be editable. The CellRenderer already allow to edit the cells, but when i edit a cell, the changes won't be saved. It would be fine, if the changed cells would automatically be saved.

i haven't found any tutorial. most tutorials are for PyGTK or php-gtk, but i need it for C.


greetings xD


Top
 Profile  
 
 Post subject: Re: GtkTreeView - Edit Cells and Save Changes
PostPosted: Tue Dec 20, 2011 10:55 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Take a look at the GTK+ 2.0 Treeview Tutorial

The key part of that is:

Quote:
Note that the cell renderer will not change the data for you in the store. After a cell has been edited, you will only receive an "edited" signal. If you do not change the data in the store, the old text will be rendered again as if nothing had happened.


That tripped me up when I first learned how to deal with editable treeview cells too.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject: Re: GtkTreeView - Edit Cells and Save Changes
PostPosted: Wed Dec 21, 2011 7:52 am 
Offline

Joined: Tue Dec 20, 2011 9:20 pm
Posts: 3
Code:
GtkTreePath *path;

void cell_edited_callback (GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
{
path = gtk_tree_path_new_from_string(path_string);

/* getting changed data and write it to mysql-database */

}



the first column in treeview is the ID column (primary key).

my questions:
1) how to get the primary key of the changed row?
2) the gchar *new_text contains the changed value, but i dont know which cell in the row is changed. (for example first name, Last Name, Location etc.)


i think it would work with GtkTreeSelection (no multi-selections in treeview allowed), but i don't know how to use **, which is used in most of the gtktreeselection-functions.


greetings


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group