summaryrefslogtreecommitdiff
path: root/src/trg-model.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-02-17 09:45:23 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-02-17 09:45:23 +0000
commit973aaa9d9a020e1644ce2fe45fd3613422f6ada9 (patch)
treec12c0ecfe8e9f890b7414287cd62e5085fcf0a7d /src/trg-model.c
parentc10b672d05b8b6b68bbc1ccb92da8b5caa451c68 (diff)
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.
Diffstat (limited to 'src/trg-model.c')
-rw-r--r--src/trg-model.c40
1 files changed, 40 insertions, 0 deletions
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 <glib.h>
#include <gtk/gtk.h>
+#include <json-glib/json-glib.h>
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, &currentId, -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;
+}