Exemplo n.º 1
0
static gboolean
trace_view_store_get_iter (GtkTreeModel *tree_model,
			   GtkTreeIter	*iter,
			   GtkTreePath	*path)
{
	TraceViewStore	*trace_view_store;
	TraceViewRecord	*record;
	gint	*indices, n, depth;

	g_assert(TRACE_VIEW_IS_LIST(tree_model));
	g_assert(path!=NULL);

	trace_view_store = TRACE_VIEW_STORE(tree_model);

	indices = gtk_tree_path_get_indices(path);
	depth	= gtk_tree_path_get_depth(path);

	/* we do not allow children */
	g_assert(depth == 1); /* depth 1 = top level; a list only has top level nodes and no children */

	n = indices[0]; /* the n-th top level row */

	record = trace_view_store_get_visible_row(trace_view_store, n);
	if (!record)
		return FALSE;

	/* We simply store a pointer to our custom record in the iter */
	iter->stamp	= trace_view_store->stamp;
	iter->user_data	= record;
	iter->user_data2 = NULL;	/* unused */
	iter->user_data3 = NULL;	/* unused */

	return TRUE;
}
Exemplo n.º 2
0
void trace_view_cpu_filter_callback(gboolean accept,
				    gboolean all_cpus,
				    guint64 *selected_cpu_mask,
				    gpointer data)
{
	GtkTreeView *trace_tree = data;
	TraceViewRecord *rec;
	GtkTreeModel *model;
	TraceViewStore *store;
	guint64 time = 0;
	gint selected_row;
	gint cpus;
	gint cpu;

	if (!accept)
		return;

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	store = TRACE_VIEW_STORE(model);

	selected_row = trace_view_get_selected_row(GTK_WIDGET(trace_tree));
	if (selected_row < 0)
		selected_row = 0;

	g_object_ref(store);
	gtk_tree_view_set_model(trace_tree, NULL);

	/*
	 * If the selected row is not part of one of the CPUs
	 * that are kept, then find one that is. Do nothing if
	 * the first row is selected.
	 */
	if (selected_row) {
		/* Save this timestamp */
		rec = trace_view_store_get_visible_row(TRACE_VIEW_STORE(model), selected_row);
		time = rec->timestamp;
	}

	if (all_cpus) {
		trace_view_store_set_all_cpus(store);
		goto set_model;
	}

	cpus = trace_view_store_get_cpus(store);

	for (cpu = 0; cpu < cpus; cpu++) {
		if (cpu_isset(selected_cpu_mask, cpu))
			trace_view_store_set_cpu(store, cpu);
		else
			trace_view_store_clear_cpu(store, cpu);
	}

 set_model:
	gtk_tree_view_set_model(trace_tree, GTK_TREE_MODEL(store));
	g_object_unref(store);

	if (!time)
		return;
	/*
	 * Try to select the row that was near the selection
	 * before the change.
	 */
	trace_view_select(GTK_WIDGET(trace_tree), time);
}