Editing data from treeview



Hi,
        I need some ideas to continue my application because I'm stopped
with this problem. I have two treeviews in my application in different
windows. The first one has a Tree Model in 3 levels of depth. The second one
is a list store with the complete set of values for the last child of the
first tree. What I want is to click on the tree child and get the complete
set of values from the child selected and then open a new window where the
user can change them. I need to find a simple method to get the reference
value from the tree model, search the list store to get the right iter, pick
the values from the iter and call a new window using these values.
What I can imagine is (schematic) what follows, but I think it could be a
simplest way to do it. 

Can you help me??

Regards

Jorge Monsalvo

gboolean mysearch(GtkTreeModel *model, GtkTreePath *path,GtkTreeIter *iter,
gpointer data)
{
        gchar   *name;
        gchar *searched;
        gchar *str_path;

        searched = (gchar *)data;
        gtk_tree_model_get(model, &iter, EQ_NAME, &name, -1);
        if (!strcmp(name, searched)){
                str_path = gtk_tree_path_to_string(path);
                memcpy(searched, str_str_path);
                g_free(str_path);
                return TRUE;
        }

        return FALSE;
}


void on_menu_edit_activate(GtkMenuItem *menuitem,  gpointer user_data)
{
        GtkTreeView *tview = (GtkTreeView *)user_data;
        GtkTreeModel            *model;
        GtkTreeIter                     iter;
        GtkTreeSelection        *selection;
        GtkTreePath                     *path;
        gint                            depth;
        gchar                           *name;
        gchar                           *searched;

        tview = (GtkTreeView *)user_data;
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(tview));
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tview));
        if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
                path = gtk_tree_model_get_path(model, &iter);
                depth = gtk_tree_path_get_depth(path);
                if (depth == EQUIPMENT){
                        gtk_tree_model_get(model, &iter, 0, &name, -1);
                        searched = g_strdup(name);
                        gtk_tree_model_foreach(tv_model_data, mysearch,
searched);
                        ...
                        (Here I have the index of the item searched. Do what
I want)
                        ...
                }
        }
}                       






___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar




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