Esempio n. 1
0
TEST_F(GQueueTest, linkIndex)
{
	int testData1 = 42;
	int testData2 = 1337;
	int testData3 = 27;

	g_queue_push_tail(queue, &testData1);
	g_queue_push_tail(queue, &testData2);

	gint index = g_queue_link_index(queue, queue->head);
	ASSERT_EQ(0, index) << "index of head element should be zero";
	index = g_queue_link_index(queue, queue->tail);
	ASSERT_EQ(1, index) << "index of tail element should be one";
	index = g_queue_link_index(queue, NULL);
	ASSERT_EQ(-1, index) << "index of unknown element should be minus one";
}
Esempio n. 2
0
void
sql_reserved_query_move_to_tail(sql_reserved_query *srq, reserved_query_item *rqi)
{
    GList   *to_tail = rqi->list_pos;
    GQueue  *gq = NULL;
    reserved_query_item *rm_rqi = NULL;
    int     ret = 0;

    if (srq == NULL || to_tail == NULL) return;

    ret = g_queue_link_index(srq->gq_reserved_long_query, to_tail);
    gq = (ret != -1) ? (srq->gq_reserved_long_query) : (srq->gq_reserved_short_query);

    if (g_queue_get_length(gq) == 0) return ;

    if (to_tail != gq->tail)
    {
        g_queue_unlink(gq, to_tail);
        g_queue_push_tail_link(gq, to_tail);
        rqi->list_pos = g_queue_peek_tail_link(gq);
    }
#ifdef FILTER_DEBUG
    g_queue_travel(srq->gq_reserved_long_query);
    g_queue_travel(srq->gq_reserved_short_query);
#endif

    return ;
}
static GtkTreePath *
get_proposal_path (GtkSourceCompletionModel *model,
		   GList                    *proposal_node)
{
	ProposalInfo *proposal_info;
	ProviderInfo *provider_info;
	gint idx;

	if (proposal_node == NULL)
	{
		return NULL;
	}

	proposal_info = proposal_node->data;
	provider_info = proposal_info->provider_node->data;

	idx = get_provider_start_index (model, provider_info);
	idx += g_queue_link_index (provider_info->proposals, proposal_node);

	return gtk_tree_path_new_from_indices (idx, -1);
}
Esempio n. 4
0
int
call_common_active_call_remove(int id)
{
	struct CallActiveViewData *win = NULL;
	if (active_calls_list) {
		GList *link = g_queue_find_custom(active_calls_list, id,
						  _queue_find_by_id);
		win = g_queue_peek_nth(active_calls_list,
				       g_queue_link_index(active_calls_list,
							  link));

		g_queue_delete_link(active_calls_list, link);
	}

	/* if we haven't found abort */
	if (!win) {
		g_debug("%s:%d no such id! was it active? (id=%d)", __FILE__,
			__LINE__, id);
		return 1;
	}


	g_debug("%s:%d removing a call from active list (id=%d)", __FILE__,
		__LINE__, win->parent.id);

	/* if was active, get a new active */
	if (win->state == CALL_STATE_ACTIVE) {
		win = g_queue_peek_head(active_calls_list);
		if (win) {
			call_common_activate_call(win);
		}
	}
	if (g_queue_get_length(active_calls_list) == 0) {
		g_debug("Freed active calls list");
		g_queue_free(active_calls_list);
		active_calls_list = NULL;
		call_common_set_sound_state(CALL_SOUND_STATE_CLEAR);
	}
	return 0;
}