Re: Help removing GtkListStore rows

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

 



I've modified the function, but the problem persists. I suppose the
problem isn't in this function but somewhere else, even if all the other
related functions work.

Here is the new version of the func based on the "fixed remove function"
from treestoretest.c:
 
static void
rem_item ()
{
  Files *tmp;
  gint row;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GtkTreePath *path;


  /* First of all detects the row selected and the model */
  if (gtk_tree_selection_get_selected
      (gtk_tree_view_get_selection (GTK_TREE_VIEW (main_list_view)),
&model,
       &iter))
    {
      if (GTK_IS_LIST_STORE (model))
	{
	  /* Let's retrive the current row index */
	  path = gtk_tree_model_get_path (model, &iter);
	  gchar *str_row = g_strdup (gtk_tree_path_to_string (path));
	  row = atoi (str_row);
	  g_free (str_row);
	  //row = atoi (gtk_tree_path_to_string (path));
#if DEBUG
	  g_print ("I'm going to delete row %d... ", row);
#endif

	  /* Then deletes the element from the files list */
	  tmp = del_file (fileslist, row);
	  fileslist = tmp;

	  if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
	    {
	      gtk_tree_selection_select_iter
		(gtk_tree_view_get_selection
		 (GTK_TREE_VIEW (main_list_view)), &iter);
	    }
	  else if (gtk_tree_path_prev (path))
	    {
	      gtk_tree_selection_select_path
		(gtk_tree_view_get_selection
		 (GTK_TREE_VIEW (main_list_view)), path);
	    }
	  gtk_tree_path_free (path);
	}
    }
}


This is the func where I construct the GtkTreeView and model etc. :

-- 
LordGolem <lordgolem@xxxxxxxxxxxxxxxxx>

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux