From 973aaa9d9a020e1644ce2fe45fd3613422f6ada9 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Thu, 17 Feb 2011 09:45:23 +0000 Subject: a bunch of changes needed to facilitate changing trackers (unfinished). also tidy up general details panel a bit, fix a crash if a stats update is received after stats dialog is closed. --- src/trg-model.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/trg-model.c') diff --git a/src/trg-model.c b/src/trg-model.c index b27c981..2d1ff67 100644 --- a/src/trg-model.c +++ b/src/trg-model.c @@ -19,6 +19,7 @@ #include #include +#include struct trg_model_remove_removed_foreachfunc_args { gint64 currentSerial; @@ -63,3 +64,42 @@ trg_model_remove_removed(GtkListStore * model, gint serial_column, g_list_free(args.toRemove); } } + +struct find_existing_item_foreach_args { + gint64 id; + gint search_column; + GtkTreeIter *iter; + gboolean found; +}; + +static gboolean +find_existing_item_foreachfunc(GtkTreeModel * model, + GtkTreePath * path G_GNUC_UNUSED, + GtkTreeIter * iter, gpointer data) +{ + struct find_existing_item_foreach_args *args = (struct find_existing_item_foreach_args *) data; + gint64 currentId; + + gtk_tree_model_get(model, iter, args->search_column, ¤tId, -1); + if (currentId == args->id) { + args->iter = iter; + return args->found = TRUE; + } + + return FALSE; +} + +gboolean +find_existing_model_item(GtkTreeModel * model, gint search_column, gint64 id, + GtkTreeIter * iter) +{ + struct find_existing_item_foreach_args args; + args.id = id; + args.found = FALSE; + args.search_column = search_column; + gtk_tree_model_foreach(model, + find_existing_item_foreachfunc, &args); + if (args.found == TRUE) + *iter = *(args.iter); + return args.found; +} -- cgit v1.2.3