Beispiel #1
0
void fm_folder_model_file_deleted(FmFolderModel* model, FmFileInfo* file)
{
    GSequenceIter *seq_it;
    /* not required for hidden files */
    gboolean update_view;
#if 0
    /* If there is no file info, that means the dir itself was deleted. */
    if( G_UNLIKELY(!file) )
    {
        /* Clear the whole list */
        GSequenceIter *items_it = g_sequence_get_begin_iter(model->items);
        path = gtk_tree_path_new_from_indices(0, -1);
        while( !g_sequence_iter_is_end(items_it) )
        {
            gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path);
            file  = (VFSFileInfo*)g_sequence_get(items_it);
            items_it = g_sequence_iter_next(it);
            vfs_file_info_unref(file);
        }
        for( l = model->items; l; l = model->items )
        {
            gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path);
            file = (VFSFileInfo*)l->data;
            model->items = g_list_delete_link(model->items, l);
            vfs_file_info_unref(file);
        }
        g_sequence_remove_range( g_sequence_get_begin_iter(model->items), g_sequence_get_end_iter(model->items) );
        gtk_tree_path_free(path);
        return;
    }
#endif

    if( !model->show_hidden && fm_file_info_is_hidden(file) ) /* if this is a hidden file */
    {
        update_view = FALSE;
        seq_it = g_sequence_get_begin_iter(model->hidden);
    }
    else
    {
        update_view = TRUE;
        seq_it = g_sequence_get_begin_iter(model->items);
    }

    while( !g_sequence_iter_is_end(seq_it) )
    {
        FmFolderItem* item = (FmFolderItem*)g_sequence_get(seq_it);
        if( item->inf == file )
            break;
        seq_it = g_sequence_iter_next(seq_it);
    }

    if( update_view )
    {
        GtkTreePath* path = gtk_tree_path_new_from_indices(g_sequence_iter_get_position(seq_it), -1);
        gtk_tree_model_row_deleted(GTK_TREE_MODEL(model), path);
        gtk_tree_path_free(path);
    }
    model->iter_age++;
    g_sequence_remove(seq_it);
}
Beispiel #2
0
static gboolean fm_folder_model_find_iter_by_req(FmFolderModel* model, GtkTreeIter* it, FmThumbnailRequest* req)
{
    guint iter_age = (guint)fm_thumbnail_request_get_payload1(req);
    FmFolderItem* item = (FmFolderItem*)fm_thumbnail_request_get_payload2(req);
    if (iter_age && item && model->iter_age == iter_age && item == (FmFolderItem*)g_sequence_get(item->iter))
    {
        it->stamp = model->stamp;
        it->user_data  = item->iter;
        return TRUE;
    }

    FmFileInfo* fi = fm_thumbnail_request_get_file_info(req);

    GSequenceIter *item_it = g_sequence_get_begin_iter(model->items);
    for( ; !g_sequence_iter_is_end(item_it); item_it = g_sequence_iter_next(item_it) )
    {
        FmFolderItem* item1 = (FmFolderItem*)g_sequence_get(item_it);
        if (item1 == item && item1->inf == fi)
        {
            item1->iter = item_it;
            item1->iter_age = model->iter_age;
            it->stamp = model->stamp;
            it->user_data  = item_it;
            return TRUE;
        }
    }

    return FALSE;
}
Beispiel #3
0
guint
swfdec_text_buffer_get_unique (SwfdecTextBuffer *buffer, 
    gsize start, gsize length)
{
  guint result = SWFDEC_TEXT_ATTRIBUTES_MASK;
  SwfdecTextBufferFormat *format, *cur;
  GSequenceIter *iter;
  gsize end;

  g_return_val_if_fail (SWFDEC_IS_TEXT_BUFFER (buffer), 0);
  g_return_val_if_fail (start + length <= buffer->text->len, 0);

  if (start == buffer->text->len)
    return result;

  end = start + length;
  iter = swfdec_text_buffer_get_iter_for_pos (buffer, start);
  format = g_sequence_get (iter);
  for (iter = g_sequence_iter_next (iter); !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter)) {
    cur = g_sequence_get (iter);
    if (cur->start >= end)
      break;
    result &= ~swfdec_text_attributes_diff (&format->attr, &cur->attr);
  }

  return result;
}
Beispiel #4
0
void g_sequence_remove_sorted ( GSequence * seq, gpointer data, GCompareDataFunc cmp_func, gpointer cmp_data )
{
    gpointer found;
    GSequenceIter * sj, * si = g_sequence_lookup( seq, data, cmp_func, cmp_data );
    if ( si == NULL )
        return;
    
    sj = si;
    while ( !g_sequence_iter_is_end( sj ) )
    {
        found = g_sequence_get( sj );
        if ( found == data )
            return g_sequence_remove( sj );
        else if ( cmp_func( found, data, cmp_data ) != 0 )
            break;
        sj = g_sequence_iter_next( sj );
    }
    
    sj = si;
    while ( !g_sequence_iter_is_begin( sj ) )
    {
        sj = g_sequence_iter_prev( sj );
        found = g_sequence_get( sj );
        if ( found == data )
            return g_sequence_remove( sj );
        else if ( cmp_func( found, data, cmp_data ) != 0 )
            break;
    }
}
Beispiel #5
0
static GSequenceIter *
lookup_file (FMListModel *model, CajaFile *file,
             CajaDirectory *directory)
{
    FileEntry *file_entry;
    GSequenceIter *ptr, *parent_ptr;

    parent_ptr = NULL;
    if (directory)
    {
        parent_ptr = g_hash_table_lookup (model->details->directory_reverse_map,
                                          directory);
    }

    if (parent_ptr)
    {
        file_entry = g_sequence_get (parent_ptr);
        ptr = g_hash_table_lookup (file_entry->reverse_map, file);
    }
    else
    {
        ptr = g_hash_table_lookup (model->details->top_reverse_map, file);
    }

    if (ptr)
    {
        g_assert (((FileEntry *)g_sequence_get (ptr))->file == file);
    }

    return ptr;
}
static inline void
_get_nearest_control_points2 (GstTimedValueControlSource * self,
    GstClockTime ts, GstControlPoint ** cp1, GstControlPoint ** cp2,
    GstClockTime * next_ts)
{
  GSequenceIter *iter1, *iter2 = NULL;

  *cp1 = *cp2 = NULL;
  iter1 = gst_timed_value_control_source_find_control_point_iter (self, ts);
  if (iter1) {
    *cp1 = g_sequence_get (iter1);
    iter2 = g_sequence_iter_next (iter1);
  } else {
    if (G_LIKELY (self->values)) {
      /* all values in the control point list come after the given timestamp */
      iter2 = g_sequence_get_begin_iter (self->values);
      /* why this? if !cp1 we don't interpolate anyway
       * if we can eliminate this, we can also use _get_nearest_control_points()
       * here, is this just to set next_ts? */
    } else {
      /* no values */
      iter2 = NULL;
    }
  }

  if (iter2 && !g_sequence_iter_is_end (iter2)) {
    *cp2 = g_sequence_get (iter2);
    *next_ts = (*cp2)->timestamp;
  } else {
    *next_ts = GST_CLOCK_TIME_NONE;
  }
}
Beispiel #7
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 #8
0
void reload_icons(FmFolderModel* model, enum ReloadFlags flags)
{
    /* reload icons */
    GSequenceIter* it = g_sequence_get_begin_iter(model->items);
    GtkTreePath* tp = gtk_tree_path_new_from_indices(0, -1);

    if(model->thumbnail_requests)
    {
        g_list_foreach(model->thumbnail_requests, (GFunc)fm_thumbnail_request_cancel, NULL);
        g_list_free(model->thumbnail_requests);
        model->thumbnail_requests = NULL;
    }

    for( ; !g_sequence_iter_is_end(it); it = g_sequence_iter_next(it) )
    {
        FmFolderItem* item = (FmFolderItem*)g_sequence_get(it);
        if(item->icon)
        {
            GtkTreeIter tree_it = {0};
            if((flags & RELOAD_ICONS && !item->is_thumbnail) ||
               (flags & RELOAD_THUMBNAILS && item->is_thumbnail))
            {
                g_object_unref(item->icon);
                item->icon = NULL;
                item->is_thumbnail = FALSE;
                item->thumbnail_loading = FALSE;
                tree_it.stamp = model->stamp;
                tree_it.user_data = it;
                gtk_tree_model_row_changed(GTK_TREE_MODEL(model), tp, &tree_it);
            }
        }
        gtk_tree_path_next(tp);
    }
    gtk_tree_path_free(tp);

    it = g_sequence_get_begin_iter(model->hidden);
    for( ; !g_sequence_iter_is_end(it); it = g_sequence_iter_next(it) )
    {
        FmFolderItem* item = (FmFolderItem*)g_sequence_get(it);
        if(item->icon)
        {
            g_object_unref(item->icon);
            item->icon = NULL;
            item->is_thumbnail = FALSE;
            item->thumbnail_loading = FALSE;
        }
    }
}
static gint _is_store_iter_n_children(GtkTreeModel *tree_model,
				      GtkTreeIter *iter)
{
	IsStore *self;
	IsStorePrivate *priv;
	IsStoreEntry *entry;
	gint n;

	g_return_val_if_fail(IS_IS_STORE(tree_model), 0);

	self = IS_STORE(tree_model);
	priv = self->priv;

	if (!iter) {
		n = g_sequence_get_length(priv->entries);
		goto out;
	}
	g_return_val_if_fail(iter->stamp == priv->stamp, 0);
	g_assert(iter->user_data);

	entry = (IsStoreEntry *)
		g_sequence_get((GSequenceIter *)iter->user_data);
	n = g_sequence_get_length(entry->entries);

out:
	return n;
}
Beispiel #10
0
static gboolean
fm_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, int n)
{
    FMListModel *model;
    GSequenceIter *child;
    GSequence *files;
    FileEntry *file_entry;

    model = (FMListModel *)tree_model;

    if (parent != NULL)
    {
        file_entry = g_sequence_get (parent->user_data);
        files = file_entry->files;
    }
    else
    {
        files = model->details->files;
    }

    child = g_sequence_get_iter_at_pos (files, n);

    if (g_sequence_iter_is_end (child))
    {
        return FALSE;
    }

    iter->stamp = model->details->stamp;
    iter->user_data = child;

    return TRUE;
}
static gboolean _is_store_iter_parent(GtkTreeModel *tree_model,
				      GtkTreeIter *iter,
				      GtkTreeIter *child)
{
	IsStore *self;
	IsStorePrivate *priv;
	IsStoreEntry *entry;
	gboolean ret = FALSE;

	g_return_val_if_fail(IS_IS_STORE(tree_model), FALSE);
	g_return_val_if_fail(child != NULL, FALSE);

	self = IS_STORE(tree_model);
	priv = self->priv;

	g_return_val_if_fail(child->stamp == priv->stamp, FALSE);
	g_assert(child->user_data);
	entry = (IsStoreEntry *)
		g_sequence_get((GSequenceIter *)child->user_data);
	if (entry->parent) {
		iter->stamp = priv->stamp;
		iter->user_data = entry->parent;
		ret = TRUE;
	}
	return ret;
}
Beispiel #12
0
static gboolean
fm_list_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
{
    FMListModel *model;
    GSequence *files;
    GSequenceIter *ptr;
    FileEntry *file_entry;
    int i, d;

    model = (FMListModel *)tree_model;
    ptr = NULL;

    files = model->details->files;
    for (d = 0; d < gtk_tree_path_get_depth (path); d++)
    {
        i = gtk_tree_path_get_indices (path)[d];

        if (files == NULL || i >= g_sequence_get_length (files))
        {
            return FALSE;
        }

        ptr = g_sequence_get_iter_at_pos (files, i);
        file_entry = g_sequence_get (ptr);
        files = file_entry->files;
    }

    fm_list_model_ptr_to_iter (model, ptr, iter);

    return TRUE;
}
Beispiel #13
0
static gboolean
fm_list_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
{
    FMListModel *model;
    GSequence *files;
    FileEntry *file_entry;

    model = (FMListModel *)tree_model;

    if (parent == NULL)
    {
        files = model->details->files;
    }
    else
    {
        file_entry = g_sequence_get (parent->user_data);
        files = file_entry->files;
    }

    if (files == NULL || g_sequence_get_length (files) == 0)
    {
        return FALSE;
    }

    iter->stamp = model->details->stamp;
    iter->user_data = g_sequence_get_begin_iter (files);

    return TRUE;
}
gboolean
is_store_set_label(IsStore *self,
		   GtkTreeIter *iter,
		   const gchar *label)
{
	IsStorePrivate *priv;
	IsStoreEntry *entry = NULL;
	gboolean ret = FALSE;

	g_return_val_if_fail(IS_IS_STORE(self), FALSE);
	g_return_val_if_fail(iter != NULL, FALSE);

	priv = self->priv;

	g_return_val_if_fail(iter->stamp == priv->stamp, FALSE);
	g_return_val_if_fail(iter->user_data, FALSE);

	entry = (IsStoreEntry *)g_sequence_get(iter->user_data);
	if (entry->sensor &&
	    g_strcmp0(is_sensor_get_label(entry->sensor), label) != 0) {
		GtkTreePath *path;

		is_sensor_set_label(entry->sensor, label);

		path = gtk_tree_model_get_path(GTK_TREE_MODEL(self), iter);
		gtk_tree_model_row_changed(GTK_TREE_MODEL(self), path, iter);
		gtk_tree_path_free(path);

		ret = TRUE;
	}
	return ret;
}
Beispiel #15
0
static void
nemo_list_model_sort_file_entries (NemoListModel *model, GSequence *files, GtkTreePath *path)
{
	GSequenceIter **old_order;
	GtkTreeIter iter;
	int *new_order;
	int length;
	int i;
	FileEntry *file_entry;
	gboolean has_iter;

	length = g_sequence_get_length (files);

	if (length <= 1) {
		return;
	}
	
	/* generate old order of GSequenceIter's */
	old_order = g_new (GSequenceIter *, length);
	for (i = 0; i < length; ++i) {
		GSequenceIter *ptr = g_sequence_get_iter_at_pos (files, i);
		
		file_entry = g_sequence_get (ptr);
		if (file_entry->files != NULL) {
			gtk_tree_path_append_index (path, i);
			nemo_list_model_sort_file_entries (model, file_entry->files, path);
			gtk_tree_path_up (path);
		}

		old_order[i] = ptr;
	}

	/* sort */
	g_sequence_sort (files, nemo_list_model_file_entry_compare_func, model);

	/* generate new order */
	new_order = g_new (int, length);
	/* Note: new_order[newpos] = oldpos */
	for (i = 0; i < length; ++i) {
		new_order[g_sequence_iter_get_position (old_order[i])] = i;
	}

	/* Let the world know about our new order */

	g_assert (new_order != NULL);

	has_iter = FALSE;
	if (gtk_tree_path_get_depth (path) != 0) {
		gboolean get_iter_result;
		has_iter = TRUE;
		get_iter_result = gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
		g_assert (get_iter_result);
	}

	gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model),
				       path, has_iter ? &iter : NULL, new_order);

	g_free (old_order);
	g_free (new_order);
}
Beispiel #16
0
static void
fm_ogl_model_remove (FMOGLModel *model, GSequenceIter *iter)
{
	FileEntry *file_entry;
	file_entry = g_sequence_get (iter);
	g_sequence_remove (iter);
}
static gboolean _is_store_iter_has_child(GtkTreeModel *tree_model,
					 GtkTreeIter *iter)
{
	IsStore *self;
	IsStorePrivate *priv;
	IsStoreEntry *entry;
	gboolean ret = FALSE;

	g_return_val_if_fail(IS_IS_STORE(tree_model), FALSE);
	g_return_val_if_fail(iter != NULL, FALSE);

	self = IS_STORE(tree_model);
	priv = self->priv;

	g_return_val_if_fail(iter->stamp == priv->stamp, FALSE);
	g_assert(iter->user_data);

	/* end iter is invalid and has no entry associated with it */
	if (!g_sequence_iter_is_end((GSequenceIter *)iter->user_data)) {
		entry = (IsStoreEntry *)
			g_sequence_get((GSequenceIter *)iter->user_data);

		ret = (g_sequence_get_length(entry->entries) > 0);
	}

	return ret;
}
Beispiel #18
0
static void service_state_changed(struct connman_service *service,
					enum connman_service_state state)
{
	GHashTableIter iter;
	gpointer key, value;

	DBG("service %p state %d", service, state);

	g_hash_table_iter_init(&iter, session_hash);

	while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
		struct connman_session *session = value;
		GSequenceIter *service_iter;

		service_iter = g_hash_table_lookup(session->service_hash, service);
		if (service_iter != NULL) {
			struct service_entry *entry;

			entry = g_sequence_get(service_iter);
			entry->state = state;
		}

		session_changed(session,
				CONNMAN_SESSION_TRIGGER_SERVICE);
	}
}
Beispiel #19
0
static GVariant *
g_menu_exporter_menu_describe_item (GMenuExporterMenu *menu,
                                    gint               position)
{
  GMenuAttributeIter *attr_iter;
  GVariantBuilder builder;
  GSequenceIter *iter;
  GMenuExporterLink *link;
  const char *name;
  GVariant *value;

  g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);

  attr_iter = g_menu_model_iterate_item_attributes (menu->model, position);
  while (g_menu_attribute_iter_get_next (attr_iter, &name, &value))
    {
      g_variant_builder_add (&builder, "{sv}", name, value);
      g_variant_unref (value);
    }
  g_object_unref (attr_iter);

  iter = g_sequence_get_iter_at_pos (menu->item_links, position);
  for (link = g_sequence_get (iter); link; link = link->next)
    g_variant_builder_add (&builder, "{sv}", link->name,
                           g_variant_new ("(uu)", g_menu_exporter_group_get_id (link->menu->group), link->menu->id));

  return g_variant_builder_end (&builder);
}
Beispiel #20
0
static void populate_service_list(struct connman_session *session)
{
	struct service_entry *entry;
	GSequenceIter *iter;

	session->service_hash =
		g_hash_table_new_full(g_direct_hash, g_direct_equal,
					NULL, NULL);
	session->service_list = __connman_service_get_list(session,
							service_match,
							create_service_entry,
							destroy_service_entry);

	g_sequence_sort(session->service_list, sort_services, session);

	iter = g_sequence_get_begin_iter(session->service_list);

	while (g_sequence_iter_is_end(iter) == FALSE) {
		entry = g_sequence_get(iter);

		DBG("service %p type %s name %s", entry->service,
			service2bearer(connman_service_get_type(entry->service)),
			entry->name);

		g_hash_table_replace(session->service_hash,
					entry->service, iter);

		iter = g_sequence_iter_next(iter);
	}
}
Beispiel #21
0
static void select_and_connect(struct connman_session *session,
				enum connman_session_reason reason)
{
	struct session_info *info = session->info;
	struct service_entry *entry = NULL;
	GSequenceIter *iter;

	DBG("session %p reason %s", session, reason2string(reason));

	info->reason = reason;

	iter = g_sequence_get_begin_iter(session->service_list);

	while (g_sequence_iter_is_end(iter) == FALSE) {
		entry = g_sequence_get(iter);

		switch (entry->state) {
		case CONNMAN_SERVICE_STATE_ASSOCIATION:
		case CONNMAN_SERVICE_STATE_CONFIGURATION:
		case CONNMAN_SERVICE_STATE_READY:
		case CONNMAN_SERVICE_STATE_ONLINE:
		case CONNMAN_SERVICE_STATE_IDLE:
		case CONNMAN_SERVICE_STATE_DISCONNECT:
			select_service(info, entry);
			return;
		case CONNMAN_SERVICE_STATE_UNKNOWN:
		case CONNMAN_SERVICE_STATE_FAILURE:
			break;
		}

		iter = g_sequence_iter_next(iter);
	}
}
gboolean
is_store_set_enabled(IsStore *self,
		     GtkTreeIter *iter,
		     gboolean enabled)
{
	IsStorePrivate *priv;
	IsStoreEntry *entry = NULL;
	gboolean ret = FALSE;

	g_return_val_if_fail(IS_IS_STORE(self), FALSE);
	g_return_val_if_fail(iter != NULL, FALSE);

	priv = self->priv;

	g_return_val_if_fail(iter->stamp == priv->stamp, FALSE);
	g_return_val_if_fail(iter->user_data, FALSE);

	entry = (IsStoreEntry *)g_sequence_get(iter->user_data);
	if (entry->sensor && entry->enabled != enabled) {
		GtkTreePath *path;

		entry->enabled = enabled;

		path = gtk_tree_model_get_path(GTK_TREE_MODEL(self), iter);
		gtk_tree_model_row_changed(GTK_TREE_MODEL(self), path, iter);
		gtk_tree_path_free(path);

		ret = TRUE;
	}
	return ret;
}
Beispiel #23
0
/**
* @brief Send message to each expired alarm.
*/
static void
notify_alarms(void)
{
	time_t now;
	bool fired = false;

	now = reference_time();

	GSequenceIter *iter = g_sequence_get_begin_iter(gAlarmQueue->alarms);

	while (!g_sequence_iter_is_end(iter))
	{
		_Alarm *alarm = (_Alarm *)g_sequence_get(iter);
		GSequenceIter *next = g_sequence_iter_next(iter);

		if (alarm && alarm->expiry <= now)
		{
			fire_alarm(alarm);
			g_sequence_remove(iter);

			fired = true;
		}

		iter = next;
	}

	if (fired)
	{
		alarm_write_db();
	}
}
Beispiel #24
0
static GtkTreePath *
nemo_list_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
	GtkTreePath *path;
	NemoListModel *model;
	GSequenceIter *ptr;
	FileEntry *file_entry;


	model = (NemoListModel *)tree_model;
	
	g_return_val_if_fail (iter->stamp == model->details->stamp, NULL);

	if (g_sequence_iter_is_end (iter->user_data)) {
		/* FIXME is this right? */
		return NULL;
	}
	
	path = gtk_tree_path_new ();
	ptr = iter->user_data;
	while (ptr != NULL) {
		gtk_tree_path_prepend_index (path, g_sequence_iter_get_position (ptr));
		file_entry = g_sequence_get (ptr);
		if (file_entry->parent != NULL) {
			ptr = file_entry->parent->ptr;
		} else {
			ptr = NULL;
		}
	}

	return path;
}
Beispiel #25
0
/**
* @brief Adjusts the alarm when a time set occurs and the wall clock
*        and rtc clock diverge.
*
* This should also be called on init, in case of a crash before we
* were able to adjust the alarms successfully.
*
*/
void
recalculate_alarms(time_t delta)
{
	if (delta)
	{
		/* Adjust each fixed time alarm by the delta.
		 * i.e. 5 seconds in the future + delta = T + 5 + delta
		 */
		GSequenceIter *iter = g_sequence_get_begin_iter(gAlarmQueue->alarms);

		while (!g_sequence_iter_is_end(iter))
		{
			_Alarm *alarm = (_Alarm *)g_sequence_get(iter);
			GSequenceIter *next = g_sequence_iter_next(iter);

			if (alarm && !alarm->calendar)
			{
				alarm->expiry += delta;
			}

			iter = next;
		}

		/* resort */
		g_sequence_sort(gAlarmQueue->alarms,
		                (GCompareDataFunc)alarm_cmp_func, NULL);

		/* persist */
		alarm_write_db();
	}

	return;
}
static void
remove_entry(IsStore *self,
	     IsStoreEntry *entry)
{
	IsStorePrivate *priv;
	GtkTreeIter iter;
	GtkTreePath *path;
	GSequenceIter *parent_iter;

	priv = self->priv;

	parent_iter = entry->parent;
	iter.stamp = priv->stamp;
	iter.user_data = entry->iter;
	path = gtk_tree_model_get_path(GTK_TREE_MODEL(self), &iter);
	g_sequence_remove(entry->iter);
	gtk_tree_model_row_deleted(GTK_TREE_MODEL(self), path);
	gtk_tree_path_free(path);

	/* remove parent if it has no children now */
	if (parent_iter) {
		IsStoreEntry *parent = g_sequence_get(parent_iter);
		if (g_sequence_get_length(parent->entries) == 0) {
			remove_entry(self, parent);
		}
	}
}
Beispiel #27
0
static IdeProjectItem *
ide_project_files_find_child (IdeProjectItem *item,
                              const gchar    *child)
{
  GSequence *children;
  GSequenceIter *iter;

  g_assert (IDE_IS_PROJECT_ITEM (item));
  g_assert (child);

  children = ide_project_item_get_children (item);
  if (!children)
    return NULL;

  for (iter = g_sequence_get_begin_iter (children);
       !g_sequence_iter_is_end (iter);
       iter = g_sequence_iter_next (iter))
    {
      IdeProjectItem *item = g_sequence_get (iter);

      if (IDE_IS_PROJECT_FILE (item))
        {
          IdeProjectFile *file = IDE_PROJECT_FILE (item);
          const gchar *name = ide_project_file_get_name (file);

          if (g_strcmp0 (name, child) == 0)
            return item;
        }
    }

  return NULL;
}
Beispiel #28
0
void
nemo_list_model_file_changed (NemoListModel *model, NemoFile *file,
				  NemoDirectory *directory)
{
	FileEntry *parent_file_entry;
	GtkTreeIter iter;
	GtkTreePath *path, *parent_path;
	GSequenceIter *ptr;
	int pos_before, pos_after, length, i, old;
	int *new_order;
	gboolean has_iter;
	GSequence *files;

	ptr = lookup_file (model, file, directory);
	if (!ptr) {
		return;
	}

	
	pos_before = g_sequence_iter_get_position (ptr);
		
	g_sequence_sort_changed (ptr, nemo_list_model_file_entry_compare_func, model);

	pos_after = g_sequence_iter_get_position (ptr);

	if (pos_before != pos_after) {
		/* The file moved, we need to send rows_reordered */
		
		parent_file_entry = ((FileEntry *)g_sequence_get (ptr))->parent;

		if (parent_file_entry == NULL) {
			has_iter = FALSE;
			parent_path = gtk_tree_path_new ();
			files = model->details->files;
		} else {
			has_iter = TRUE;
			nemo_list_model_ptr_to_iter (model, parent_file_entry->ptr, &iter);
			parent_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
			files = parent_file_entry->files;
		}

		length = g_sequence_get_length (files);
		new_order = g_new (int, length);
		/* Note: new_order[newpos] = oldpos */
		for (i = 0, old = 0; i < length; ++i) {
			if (i == pos_after) {
				new_order[i] = pos_before;
			} else {
				if (old == pos_before)
					old++;
				new_order[i] = old++;
			}
		}

		gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model),
					       parent_path, has_iter ? &iter : NULL, new_order);

		gtk_tree_path_free (parent_path);
		g_free (new_order);
	}
Beispiel #29
0
guint event_queue_execute(event_queue *equeue, guint time)
{
  GSequence *queue = equeue->queue;
  GSequenceIter *first_iter = g_sequence_get_begin_iter(queue);
  GSequenceIter *current_iter = first_iter;
  event_queue_entry *entry = NULL;

  while(g_sequence_iter_is_end(current_iter) == FALSE) {
    entry = (event_queue_entry *) g_sequence_get(current_iter);
    if(entry->time > time) {
      break;
    }
    current_iter = g_sequence_iter_next(current_iter);
    if(entry->func != NULL) {
      entry->func(time, entry->data);
    }
  }

  g_sequence_remove_range(first_iter, current_iter);
  if(g_sequence_get_length(queue) == 0) {
    return G_MAXUINT;
  }

  return entry->time;
}
static gpointer
photos_base_manager_get_item (GListModel *list, guint position)
{
  PhotosBaseManager *self = PHOTOS_BASE_MANAGER (list);
  PhotosBaseManagerPrivate *priv;
  GSequenceIter *iter = NULL;
  gpointer ret_val = NULL;

  priv = photos_base_manager_get_instance_private (self);

  if (priv->last_position != G_MAXUINT)
    {
      if (priv->last_position == position + 1)
        iter = g_sequence_iter_prev (priv->last_iter);
      else if (priv->last_position == position - 1)
        iter = g_sequence_iter_next (priv->last_iter);
      else if (priv->last_position == position)
        iter = priv->last_iter;
    }

  if (iter == NULL)
    iter = g_sequence_get_iter_at_pos (priv->sequence, position);

  priv->last_iter = iter;
  priv->last_position = position;

  if (g_sequence_iter_is_end (iter))
    goto out;

  ret_val = g_object_ref (g_sequence_get (iter));

 out:
  return ret_val;
}