Beispiel #1
0
gboolean sorted_sequence_contains(SortedSequence * sequence, gpointer data)
{
	GSequenceIter * iter = g_sequence_search(sequence -> seq, data, sequence -> cmp_func, NULL);
	GSequenceIter * prev = g_sequence_iter_prev(iter);
	if (g_sequence_iter_is_end(prev)) return FALSE;
	gpointer element = g_sequence_get(prev);
	return sequence -> cmp_func(data, element, NULL) == 0;
}
Beispiel #2
0
void sorted_sequence_remove(SortedSequence * sequence, gpointer data)
{
	GSequenceIter * iter = g_sequence_search(sequence -> seq, data, sequence -> cmp_func, NULL);
	GSequenceIter * prev = g_sequence_iter_prev(iter);
	gpointer element = g_sequence_get(prev);
	if(sequence -> cmp_func(data, element, NULL) == 0){
		g_sequence_remove(prev);
	}
}
Beispiel #3
0
static GSequenceIter *
find_first_proposal (GscProviderDevhelp *devhelp)
{
	GSequenceIter *iter;
	GSequenceIter *prev;

	iter = g_sequence_search (devhelp->priv->proposals,
	                          NULL,
	                          (GCompareDataFunc)compare_items,
	                          devhelp);

	if (iter == NULL)
	{
		return NULL;
	}
	
	/* Test if this position might be after the last match */
	if (!g_sequence_iter_is_begin (iter) && 
	    (g_sequence_iter_is_end (iter) || 
	     !iter_match_prefix (devhelp, iter)))
	{
		iter = g_sequence_iter_prev (iter);
	
		/* Maybe there is actually nothing in the sequence */
		if (g_sequence_iter_is_end (iter) || 
		    !iter_match_prefix (devhelp, iter))
		{
			return NULL;
		}
	}
	
	if (g_sequence_iter_is_end (iter))
	{
		return NULL;
	}

	/* Go back while it matches */
	while (iter &&
	       (prev = g_sequence_iter_prev (iter)) && 
	       iter_match_prefix (devhelp, prev))
	{
		iter = prev;
		
		if (g_sequence_iter_is_begin (iter))
		{
			break;
		}
	}
	
	return iter;
}
Beispiel #4
0
void fm_folder_model_set_show_hidden(FmFolderModel* model, gboolean show_hidden)
{
    FmFolderItem* item;
    GList *l, *next;
    GSequenceIter *items_it;
    g_return_if_fail(model != NULL);
    if( model->show_hidden == show_hidden )
        return;

    model->show_hidden = show_hidden;
    if( show_hidden ) /* add previously hidden items back to the list */
    {
        GSequenceIter *hidden_it = g_sequence_get_begin_iter(model->hidden);
        while( !g_sequence_iter_is_end(hidden_it) )
        {
            GtkTreeIter it;
            GSequenceIter *next_hidden_it;
            GSequenceIter *insert_item_it = g_sequence_search(model->items, g_sequence_get(hidden_it),
                                                              fm_folder_model_compare, model);
            next_hidden_it = g_sequence_iter_next(hidden_it);
            item = (FmFolderItem*)g_sequence_get(hidden_it);
            it.stamp = model->stamp;
            it.user_data  = hidden_it;
            g_sequence_move(hidden_it, insert_item_it);
            GtkTreePath *path = gtk_tree_path_new_from_indices(g_sequence_iter_get_position(hidden_it), -1);
            gtk_tree_model_row_inserted(GTK_TREE_MODEL(model), path, &it);
            gtk_tree_path_free(path);
            hidden_it = next_hidden_it;
        }
    }
    else /* move invisible items to hidden list */
    {
        GSequenceIter *items_it = g_sequence_get_begin_iter(model->items);
        while( !g_sequence_iter_is_end(items_it) )
        {
            GtkTreePath* tp;
            GSequenceIter *next_item_it = g_sequence_iter_next(items_it);
            item = (FmFolderItem*)g_sequence_get(items_it);
            if( fm_file_info_is_hidden(item->inf) )
            {
                gint delete_pos = g_sequence_iter_get_position(items_it);
                g_sequence_move( items_it, g_sequence_get_begin_iter(model->hidden) );
                tp = gtk_tree_path_new_from_indices(delete_pos, -1);
                /* tell everybody that we removed an item */
                gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), tp);
                gtk_tree_path_free(tp);
            }
            items_it = next_item_it;
        }
    }
}
Beispiel #5
0
/* return iter to format relevant for position, that is the format pointed to
 * by iter will have a lower or equal start index than pos */
static GSequenceIter *
swfdec_text_buffer_get_iter_for_pos (SwfdecTextBuffer *buffer, guint pos)
{
  SwfdecTextBufferFormat format = { pos, };
  GSequenceIter *iter;

  iter = g_sequence_search (buffer->attributes, &format,
      swfdec_text_buffer_format_compare, NULL);
  if (g_sequence_iter_is_end (iter) ||
      ((SwfdecTextBufferFormat *) g_sequence_get (iter))->start > pos)
    iter = g_sequence_iter_prev (iter);

  return iter;
}
Beispiel #6
0
const BlueSkyRangesetItem *bluesky_rangeset_lookup(BlueSkyRangeset *rangeset,
                                                   uint64_t offset)
{
    GSequenceIter *i;
    i = g_sequence_search(rangeset->seq, &offset, compare64, NULL);
    i = g_sequence_iter_prev(i);
    if (g_sequence_iter_is_end(i))
        return NULL;

    BlueSkyRangesetItem *item = (BlueSkyRangesetItem *)g_sequence_get(i);
    if (offset >= item->start && offset < item->start + item->length)
        return item;
    else
        return NULL;
}
Beispiel #7
0
static void
decorator_blacklist_add (TrackerDecorator *decorator,
                         gint              id)
{
	TrackerDecoratorPrivate *priv = decorator->priv;
	GSequenceIter *iter;

	iter = g_sequence_search (priv->blacklist_items,
	                          GINT_TO_POINTER (id),
	                          sequence_compare_func,
	                          NULL);

	if (g_sequence_iter_is_end (iter) ||
	    g_sequence_get (g_sequence_iter_prev (iter)) != GINT_TO_POINTER (id))
		g_sequence_insert_before (iter, GINT_TO_POINTER (id));
}
Beispiel #8
0
/* Look up the first rangeset item starting at or following the given address.
 * Can be used to iterate through a rangeset. */
const BlueSkyRangesetItem *bluesky_rangeset_lookup_next(BlueSkyRangeset *rangeset, uint64_t offset)
{
    GSequenceIter *i;
    i = g_sequence_search(rangeset->seq, &offset, compare64, NULL);
    i = g_sequence_iter_prev(i);
    if (g_sequence_iter_is_end(i))
        return NULL;
    BlueSkyRangesetItem *item = (BlueSkyRangesetItem *)g_sequence_get(i);
    if (item->start < offset) {
        i = g_sequence_iter_next(i);
        if (g_sequence_iter_is_end(i))
            item = NULL;
        else
            item = (BlueSkyRangesetItem *)g_sequence_get(i);
    }
    return item;
}
Beispiel #9
0
gboolean bluesky_rangeset_insert(BlueSkyRangeset *rangeset,
                                 uint64_t start, uint64_t length,
                                 gpointer data)
{
    GSequenceIter *i;
    i = g_sequence_search(rangeset->seq, &start, compare64, NULL);
    i = g_sequence_iter_prev(i);

    /* TODO: Checks that no other item overlaps. */

    BlueSkyRangesetItem *item = g_new(BlueSkyRangesetItem, 1);
    item->start = start;
    item->length = length;
    item->data = data;
    g_sequence_insert_sorted(rangeset->seq, item, compare64, NULL);

    return TRUE;
}
Beispiel #10
0
RmOff rm_offset_lookup(RmOffsetTable offset_list, RmOff file_offset) {
    if (offset_list != NULL) {
        RmOffsetEntry token;
        token.physical = 0;
        token.logical = file_offset;

        GSequenceIter *nearest = g_sequence_search(
                                     offset_list, &token,
                                     (GCompareDataFunc)rm_offset_find_logical, NULL
                                 );

        if(!g_sequence_iter_is_end(nearest)) {
            RmOffsetEntry *off = g_sequence_get(nearest);
            return (gint64)(off->physical + file_offset) - (gint64)off->logical;
        }
    }

    /* default to 0 always */
    return 0;
}
/**
 * gst_timed_value_control_source_find_control_point_iter:
 * @self: the control source to search in
 * @timestamp: the search key
 *
 * Find last value before given timestamp in control point list.
 * If all values in the control point list come after the given
 * timestamp or no values exist, %NULL is returned.
 *
 * For use in control source implementations.
 *
 * Returns: (transfer none): the found #GSequenceIter or %NULL
 */
GSequenceIter *gst_timed_value_control_source_find_control_point_iter
    (GstTimedValueControlSource * self, GstClockTime timestamp)
{
  GSequenceIter *iter;

  if (!self->values)
    return NULL;

  iter =
      g_sequence_search (self->values, &timestamp,
      (GCompareDataFunc) gst_control_point_find, NULL);

  /* g_sequence_search() returns the iter where timestamp
   * would be inserted, i.e. the iter > timestamp, so
   * we need to get the previous one. And of course, if
   * there is no previous one, we return NULL. */
  if (g_sequence_iter_is_begin (iter))
    return NULL;

  return g_sequence_iter_prev (iter);
}
Beispiel #12
0
RmOff rm_offset_bytes_to_next_fragment(RmOffsetTable offset_list, RmOff file_offset) {
    if (offset_list != NULL) {
        RmOffsetEntry token;
        token.physical = 0;
        token.logical = file_offset;

        GSequenceIter *next_fragment = g_sequence_iter_prev(
                                           g_sequence_search(
                                               offset_list, &token,
                                               (GCompareDataFunc)rm_offset_find_logical, NULL
                                           )
                                       );

        if(!g_sequence_iter_is_end(next_fragment) && !g_sequence_iter_is_begin(next_fragment) ) {
            RmOffsetEntry *off = g_sequence_get(next_fragment);
            return off->logical - file_offset;
        }
    }
    /* default to 0 always */
    return 0;
}
Beispiel #13
0
static void draw(GtkDrawingArea *drawing_area, cairo_t *cr, EdosuView *self)
{
    (void) drawing_area;

    if (self->hitobjects == NULL)
        return;

    cairo_scale(cr, _w/667., _h/499.);
    cairo_translate(cr, 77, 57);
    cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);

    osux_hitobject key, *obj;
    GSequenceIter *iter = NULL;
    key.offset = self->position-1;
    key.end_offset = self->position-1;
    iter = g_sequence_search(self->hitobjects, &key, get_object_end_offset, NULL);
    //iter = g_sequence_iter_next(iter);

    GList *list = NULL;
    while (!g_sequence_iter_is_end(iter) &&
           (obj = g_sequence_get(iter)) &&
           object_is_approach_time_or_slider(obj, self->position))
    {
        list = g_list_prepend(list, (gpointer) obj);
        iter = g_sequence_iter_next(iter);
    }

    GList *itr = list;
    while (itr != NULL) {
        edosu_color cl;
        obj = (osux_hitobject*) itr->data;
        edosu_color_get(&cl, obj);
        edosu_draw_object(obj, cr, self->position, &cl);
        itr = itr->next;
    }
    g_list_free(list);
}