Re: GtkIconView remove item



Hi.

You need to remove the data from underlying model and your icon view
will get updated automatically.

Sample code that is capable of removing multiple items at a time would
look like this:
------
GtkIconView  *icon_view;
GtkListStore *store;
GList        *elements,
             *iter;

/* Initialize icon_view here */

elements = gtk_icon_view_get_selected_items (icon_view);

/* Convert to row references for safe removal */
for (iter = elements; iter; iter = g_list_next (iter))
{
  GtkTreeRowReference *ref;
  GtkTreePath         *path = (GtkTreePath *)iter->data;

  ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
  gtk_tree_path_free (path);
  iter->data = ref;
}

/* Remove now */
for (iter = elements; iter; iter = g_list_next (iter))
{
  GtkTreeRowReference *ref = (GtkTreeRowReference *)iter->data;
  GtkTreePath         *path;
  GtkTreeIter          remove_me;

  path = gtk_tree_row_reference_get_path (ref);
  gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &remove_me, path);
  gtk_tree_path_free (path);

  gtk_list_store_remove (store, &remove_me);
  gtk_tree_row_reference_free (ref);
}

g_list_free (elements);
-------------

Tadej

-- 
Tadej BorovÅak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com



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