Re: gtk_tree_store_remove differences in API?



On Wednesday 19 February 2003 11:45, Andy Jeffries wrote:

What was the old behaviour (so I know how to handle it in my app) and is
there anyway I can #ifdef this or whatever so it builds correctly on
both RedHat 8.0 and 8.1 machines?

I've had the same issue and just changed my code so that the items are not 
removed right away from the store, but later in an idle timeout after I've 
walked through the whole store and decided which items to remove.

I don't know if that's the best solution, but it should get rid of the compile 
problem.

Here's a code snippet, maybe you find it useful.

/******************************************************************************
 *
 *  downloads_remove_iter
 *
 *  callback for idle timeout to remove multiple iters when
 *  walking through a store or using foo_foreach();
 *
 ***/

gboolean
downloads_remove_iter (GtkTreeIter *iter)
{
        g_return_val_if_fail (iter != NULL, FALSE);

        gtk_list_store_remove ( downloads_store, iter);

        gtk_tree_iter_free (iter);

        return FALSE;
}

/******************************************************************************
 *
 *  downloads_onClearCompletedDownloads
 *
 *  removes all items from the store that are completed.
 *
 ***/

static void
downloads_onClearCompletedDownloads (GtkWidget *widget, gpointer data)
{
        GtkTreeIter  tmpiter;
        gboolean     val;

        g_return_if_fail ( downloads_store != NULL );

        val = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(downloads_store), 
&tmpiter);

        while (val)
        {
                guint status = G_MAXUINT;

                gtk_tree_model_get ( GTK_TREE_MODEL(downloads_store), 
&tmpiter, DOWNLOADS_STATUS_COLUMN, &status, -1);

                if ( status == STATUS_COMPLETE )
                        g_idle_add ( (GSourceFunc) downloads_remove_iter, 
gtk_tree_iter_copy (&tmpiter));

                val = gtk_tree_model_iter_next 
(GTK_TREE_MODEL(downloads_store), &tmpiter);
        }
}

Cheers
-Tim





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