Editable TreeView Cell problem



Hello Everyone,

I am using a Gtk::TreeView to present from and allow users to edit data from a data table.  Part of this process involves insertion of new rows into the list store associated with the tree view.

I am trying to do this in such a way whereby the list store cursor ends up positioned to the new row and a desired cell in that row is set to edit mode.

The list store is sorted on the first column, so when a new row is inserted and the set_cursor command is issued, the row is already positioned where it would normally be in the list store.

My problem is this:  the following code works correctly UNLESS the row to be inserted would end up being the FIRST row in the list.  The new row appears in the proper position (first); but,  the CELL being edited for that new row APPEARS to be on the row immediately following the first row.  Here's the strange part:  once editing is completed, then all appears as it should be, i.e. the newly edited data appears in the proper cell in the first row.

<source code>

gboolean TaxTablewin::add_jurisdiction_record(void)
{

Gtk::TreeModel::iterator iter;
Gtk::TreeModel::Row row;
gchar *locbuf;
const gchar *result_text;

Gtk::Label label;
label.set_markup("<big> Enter new jurisdiction name: </big>");
Gtk::Entry entry;
entry.set_max_length(25);
entry.set_has_frame();
entry.set_activates_default(TRUE);

Gtk::Dialog db;
db.set_title(" New Jurisdiction Record ");
db.set_has_separator(TRUE);
db.set_position(Gtk::WIN_POS_CENTER_ALWAYS);
db.add_button(Gtk::Stock::OK,Gtk::RESPONSE_OK);
db.add_button(Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL);
db.set_default_response(Gtk::RESPONSE_OK);
Gtk::HBox hbox(FALSE,4);
hbox.set_border_width(CONTAINER_BORDER_WIDTH);
hbox.pack_start(label,TRUE,FALSE,3);
hbox.pack_start(entry,TRUE,FALSE,3);
db.get_vbox()->pack_start(hbox,TRUE,FALSE,3);
db.show_all_children();

if(db.run() != Gtk::RESPONSE_OK)
return FALSE;

db.hide();

result_text = C_STR(entry.get_text());

if(!strlen(result_text))
return FALSE;

row = *(iter = jurisdiction_list->append());
row[jurisdiction_columns.m_name_text] = result_text;
Gtk::TreeModel::Path *path = new Gtk::TreeModel::Path(iter);
Gtk::TreeView::Column *pColumn = j_tree->get_column(1);
j_tree->set_cursor(*path,*pColumn,TRUE);
delete path;
return TRUE;
}


</source code>

Any ideas as to the error of my way?

Robert L. Caryl Jr.
Fiscal Systems Inc.
102 Commerce Circle
Madison  AL 35758


256.772.8920 ext. 108 -- Office
256.527.7855 -- Cell

This email message may contain privileged or confidential information. If you are not the recipient, you may not disclose, use, disseminate, distribute, copy or rely on this message or attachment in any way. If you received this email message in error, please return by forwarding the message and its attachment to the sender and then delete the message and its attachment from your computer.  Fiscal Systems, Inc. and its affiliates do not accept liability for any errors, omissions, corruption or virus in the contents of this message or any attachments that arise as a result of e-mail transmission.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]