0

In Gtk 2.0 the cell toggled event, for example, passes the cell rendered and the path to the callback. But in order to change the underlying model data I need to know which treeview or which model this event is for. What is the proper way to determine that?

EDIT:

To clarify, the GtkCellRenderer toggled signal calls a callback with 3 parameters: *cell_renderer, *path, user_data. In this callback, how do I retrieve the model that is connected to the treeview that received this signal?

gpoo
  • 8,408
  • 3
  • 38
  • 53
ClubCranium
  • 111
  • 1
  • 4

1 Answers1

0

When you connect the "toggled" signal, you can pass the GtkTreeView or the model as the user_data. I'm not an expert on Gtk+ with C programming language :), but I guess the following code will help you:

void cb_toggled (GtkCellRendererToggle *cell_renderer,gchar *path, gpointer user_data)
{
    GtkListStore *store = (GtkListStore *) user_data;
    ...
}

int main(int argc, char **argv)
{
    ...
    g_signal_connect(G_OBJECT(cell_renderer), "toggled", G_CALLBACK(cb_toggled), (gpointer)gtk_tree_view_get_model(treeview));
    ...
}
eagleoneraptor
  • 1,217
  • 2
  • 12
  • 20