Re: editable entries in tree view



Em Fri, 14 Jun 2002 16:48:25 +0200, Olivier Sessink <olivier lx student wau nl>
escreveu:

Hi all,

I'm working with the new (and excellent!!) tree widget, found out the
cell_renderer_text can do editing as well, but if I change an entry, the
change dissapears directly after I hit enter?!?

Should the change be 'committed' by the callback? If so, the problem is:
the
callback prototype is not yet finished in the API reference so how do I do
this?

Yes, here's what I use:

[...]
  /* column for description */
  cr = gtk_cell_renderer_text_new ();
  g_signal_connect (G_OBJECT(cr), "edited",
                    G_CALLBACK(edit_description_cb),
                    tree_model);
[...]

and the callback:

[...]
void
edit_description_cb (GtkCellRendererText *cell,
                     const gchar *path_string,
                     const gchar *new_text,
                     gpointer data)
{
  GtkTreeModel *tree_model = (GtkTreeModel*) data;
  GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
  GtkTreeIter ti;
  gchar *old_text;

  gtk_tree_model_get_iter (tree_model, &ti, path);

  gtk_tree_model_get (tree_model, &ti, DESCRIPTION_COLUMN, &old_text, -1);
  g_free (old_text);

  gtk_tree_store_set (GTK_TREE_STORE(tree_model), &ti, DESCRIPTION_COLUMN,
                      new_text, -1);
    
  gtk_tree_path_free (path);
}
[...]

There is a nice example on gtk-demo, also.

(b.t.w. if somebody is interested in code to get a tree-like directory and
file structure, I have something almost ready).

I am, I have done something also (a directory tree that loads subdirs when
you double-click) and would like to see what you've done.

[]s!

-- 
kov debian org: Gustavo Noronha <http://people.debian.org/~kov>
Debian: <http://www.debian.org> * <http://debian-br.cipsga.org.br>

Attachment: pgpijXIyfm_qY.pgp
Description: PGP signature



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