Re: Tree view and multiple TreeModels.



On Saturday 02 April 2005 14:23, MQ wrote:

gtk_tree_view_get_model()?

Not quite. This returns the model currently connected to the View. But if I
have model A and model B, how do I know which is the one returned by
gtk_tree_view_get_model()?

You could tag the two models with g_object_set_data(), like this:

 g_object_set_data (G_OBJECT (store1), "bla-model-num", GINT_TO_POINTER (1));
 g_object_set_data (G_OBJECT (store2), "bla-model-num", GINT_TO_POINTER (2));

and then later check with:

 gpointer  data = g_object_get_data (G_OBJECT (store), "bla-model-num");
 gint bla_model_num = GPOINTER_TO_INT (data); 

 switch (bla_model_num)
 {
   case 1:
     g_print ("This is model 1\n");
     break;
   case 2:
     g_print ("This is model 2\n");
     break;
   default:
     g_assert_not_reached();
 }

Although I guess it would be easier to just store the two pointers somewhere 
in a struct or so and do

  if (model == GTK_TREE_MODEL (foo->store1))  
  {
      ..
  } 
  else if (model == GTK_TREE_MODEL (foo->store2))
  {
     ...
  }

Cheers
 -Tim



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