示例#1
0
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;
}
示例#2
0
gboolean fm_folder_model_get_iter(GtkTreeModel *tree_model,
                                  GtkTreeIter *iter,
                                  GtkTreePath *path)
{
    FmFolderModel* model;
    gint *indices, n, depth;
    GSequenceIter* items_it;

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

    model = FM_FOLDER_MODEL(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 */

    if( n >= g_sequence_get_length(model->items) || n < 0 )
        return FALSE;

    items_it = g_sequence_get_iter_at_pos(model->items, n);

    g_assert( items_it  != g_sequence_get_end_iter(model->items) );

    /* We simply store a pointer in the iter */
    iter->stamp = model->stamp;
    iter->user_data  = items_it;

    return TRUE;
}
示例#3
0
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;
}
示例#4
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;
}
示例#5
0
static void
g_file_monitor_source_dispose (GFileMonitorSource *fms)
{
  g_mutex_lock (&fms->lock);

  if (fms->instance)
    {
      GHashTableIter iter;
      gpointer seqiter;
      QueuedEvent *event;

      g_hash_table_iter_init (&iter, fms->pending_changes_table);
      while (g_hash_table_iter_next (&iter, NULL, &seqiter))
        {
          g_hash_table_iter_remove (&iter);
          g_sequence_remove (seqiter);
        }

      while ((event = g_queue_pop_head (&fms->event_queue)))
        queued_event_free (event);

      g_assert (g_sequence_get_length (fms->pending_changes) == 0);
      g_assert (g_hash_table_size (fms->pending_changes_table) == 0);
      g_assert (fms->event_queue.length == 0);
      fms->instance = NULL;

      g_file_monitor_source_update_ready_time (fms);
    }

  g_mutex_unlock (&fms->lock);

  g_source_destroy ((GSource *) fms);
}
示例#6
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);
}
示例#7
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;
}
示例#8
0
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);
		}
	}
}
示例#9
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);
	}
示例#10
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;
}
示例#11
0
static guint
ide_recent_projects_get_n_items (GListModel *model)
{
  g_assert (IDE_IS_RECENT_PROJECTS (model));

  return g_sequence_get_length (IDE_RECENT_PROJECTS (model)->projects);
}
示例#12
0
文件: gmenumodel.c 项目: antono/glib
static gint
random_menu_get_n_items (GMenuModel *model)
{
  RandomMenu *menu = (RandomMenu *) model;

  return g_sequence_get_length (menu->items);
}
示例#13
0
gboolean fm_folder_model_iter_nth_child(GtkTreeModel *tree_model,
                                        GtkTreeIter *iter,
                                        GtkTreeIter *parent,
                                        gint n)
{
    GSequenceIter* items_it;
    FmFolderModel* model;

    g_return_val_if_fail(FM_IS_FOLDER_MODEL(tree_model), FALSE);
    model = FM_FOLDER_MODEL(tree_model);

    /* a list has only top-level rows */
    if( parent )
        return FALSE;

    /* special case: if parent == NULL, set iter to n-th top-level row */
    if( n >= g_sequence_get_length(model->items) || n < 0 )
        return FALSE;

    items_it = g_sequence_get_iter_at_pos(model->items, n);
    g_assert( items_it  != g_sequence_get_end_iter(model->items) );

    iter->stamp = model->stamp;
    iter->user_data  = items_it;

    return TRUE;
}
static guint
ide_recent_projects_get_n_items (GListModel *model)
{
  IdeRecentProjects *self = (IdeRecentProjects *)model;

  g_assert (IDE_IS_RECENT_PROJECTS (self));

  return g_sequence_get_length (self->projects);
}
示例#15
0
static void
g_dbus_menu_group_changed (GDBusMenuGroup *group,
                           guint           menu_id,
                           gint            position,
                           gint            removed,
                           GVariant       *added)
{
  GSequenceIter *point;
  GVariantIter iter;
  GDBusMenuModel *proxy;
  GSequence *items;
  GVariant *item;
  gint n_added;

  /* We could have signals coming to us when we're not active (due to
   * some other process having subscribed to this group) or when we're
   * pending.  In both of those cases, we want to ignore the signal
   * since we'll get our own information when we call "Start" for
   * ourselves.
   */
  if (group->state != GROUP_ONLINE)
    return;

  items = g_hash_table_lookup (group->menus, GINT_TO_POINTER (menu_id));

  if (items == NULL)
    {
      items = g_sequence_new (g_dbus_menu_model_item_free);
      g_hash_table_insert (group->menus, GINT_TO_POINTER (menu_id), items);
    }

  point = g_sequence_get_iter_at_pos (items, position + removed);

  g_return_if_fail (point != NULL);

  if (removed)
    {
      GSequenceIter *start;

      start = g_sequence_get_iter_at_pos (items, position);
      g_sequence_remove_range (start, point);
    }

  n_added = g_variant_iter_init (&iter, added);
  while (g_variant_iter_loop (&iter, "@a{sv}", &item))
    g_sequence_insert_before (point, g_dbus_menu_group_create_item (item));

  if (g_sequence_get_length (items) == 0)
    {
      g_hash_table_remove (group->menus, GINT_TO_POINTER (menu_id));
      items = NULL;
    }

  if ((proxy = g_hash_table_lookup (group->proxies, GINT_TO_POINTER (menu_id))))
    g_dbus_menu_model_changed (proxy, items, position, removed, n_added);
}
示例#16
0
static gint
bt_pattern_list_model_tree_model_iter_n_children (GtkTreeModel * tree_model,
    GtkTreeIter * iter)
{
  BtPatternListModel *model = BT_PATTERN_LIST_MODEL (tree_model);

  if (iter == NULL)
    return g_sequence_get_length (model->priv->seq);

  g_return_val_if_fail (model->priv->stamp == iter->stamp, -1);
  return 0;
}
示例#17
0
gint fm_folder_model_iter_n_children(GtkTreeModel *tree_model,
                                     GtkTreeIter *iter)
{
    FmFolderModel* model;
    g_return_val_if_fail(FM_IS_FOLDER_MODEL(tree_model), -1);
    g_return_val_if_fail(iter == NULL || iter->user_data != NULL, FALSE);
    model = FM_FOLDER_MODEL(tree_model);
    /* special case: if iter == NULL, return number of top-level rows */
    if( !iter )
        return g_sequence_get_length(model->items);
    return 0; /* otherwise, this is easy again for a list */
}
示例#18
0
static gboolean
nemo_list_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
	FileEntry *file_entry;
	
	if (iter == NULL) {
		return !nemo_list_model_is_empty (NEMO_LIST_MODEL (tree_model));
	}

	file_entry = g_sequence_get (iter->user_data);

	return (file_entry->files != NULL && g_sequence_get_length (file_entry->files) > 0);
}
示例#19
0
static GVariant *
g_menu_exporter_menu_list (GMenuExporterMenu *menu)
{
  GVariantBuilder builder;
  gint i, n;

  g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));

  n = g_sequence_get_length (menu->item_links);
  for (i = 0; i < n; i++)
    g_variant_builder_add_value (&builder, g_menu_exporter_menu_describe_item (menu, i));

  return g_variant_builder_end (&builder);
}
示例#20
0
static ClutterModelIter *
clutter_list_model_insert_row (ClutterModel *model,
                               gint          index_)
{
  ClutterListModel *model_default = CLUTTER_LIST_MODEL (model);
  GSequence *sequence = model_default->priv->sequence;
  ClutterListModelIter *retval;
  guint n_columns, i, pos;
  GValueArray *array;
  GSequenceIter *seq_iter;

  n_columns = clutter_model_get_n_columns (model);
  array = g_value_array_new (n_columns);

  for (i = 0; i < n_columns; i++)
    {
      GValue *value = NULL;

      g_value_array_append (array, NULL);

      value = g_value_array_get_nth (array, i);
      g_value_init (value, clutter_model_get_column_type (model, i));
    }

  if (index_ < 0)
    {
      seq_iter = g_sequence_append (sequence, array);
      pos = g_sequence_get_length (sequence) - 1;
    }
  else if (index_ == 0)
    {
      seq_iter = g_sequence_prepend (sequence, array);
      pos = 0;
    }
  else
    {
      seq_iter = g_sequence_get_iter_at_pos (sequence, index_);
      seq_iter = g_sequence_insert_before (seq_iter, array);
      pos = index_;
    }

  retval = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
                         "model", model,
                         "row", pos,
                         NULL);
  retval->seq_iter = seq_iter;

  return CLUTTER_MODEL_ITER (retval);
}
示例#21
0
static gboolean
bt_pattern_list_model_tree_model_get_iter (GtkTreeModel * tree_model,
    GtkTreeIter * iter, GtkTreePath * path)
{
  BtPatternListModel *model = BT_PATTERN_LIST_MODEL (tree_model);
  GSequence *seq = model->priv->seq;
  gint i = gtk_tree_path_get_indices (path)[0];

  if (i >= g_sequence_get_length (seq))
    return FALSE;

  iter->stamp = model->priv->stamp;
  iter->user_data = g_sequence_get_iter_at_pos (seq, i);

  return TRUE;
}
示例#22
0
static gboolean
bt_pattern_list_model_tree_model_iter_children (GtkTreeModel * tree_model,
    GtkTreeIter * iter, GtkTreeIter * parent)
{
  BtPatternListModel *model = BT_PATTERN_LIST_MODEL (tree_model);

  /* this is a list, nodes have no children */
  if (!parent) {
    if (g_sequence_get_length (model->priv->seq) > 0) {
      iter->stamp = model->priv->stamp;
      iter->user_data = g_sequence_get_begin_iter (model->priv->seq);
      return TRUE;
    }
  }
  iter->stamp = 0;
  return FALSE;
}
示例#23
0
static int
nemo_list_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
	NemoListModel *model;
	GSequence *files;
	FileEntry *file_entry;

	model = (NemoListModel *)tree_model;

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

	return g_sequence_get_length (files);
}
示例#24
0
static void
on_pattern_name_changed (BtPattern * pattern, GParamSpec * arg,
    gpointer user_data)
{
  BtPatternListModel *model = BT_PATTERN_LIST_MODEL (user_data);
  GSequence *seq = model->priv->seq;
  GtkTreePath *path;
  GtkTreeIter iter;
  gint pos1, pos2 = -1, len;

  // find the item by pattern (cannot use model_item_cmp, as id has changed)
  iter.stamp = model->priv->stamp;
  len = g_sequence_get_length (seq);
  for (pos1 = 0; pos1 < len; pos1++) {
    iter.user_data = g_sequence_get_iter_at_pos (seq, pos1);
    if (g_sequence_get (iter.user_data) == pattern) {
      g_sequence_sort_changed (iter.user_data, model_item_cmp, NULL);
      pos2 = g_sequence_iter_get_position (iter.user_data);
      break;
    }
  }
  if (G_UNLIKELY (pos2 == -1))
    return;

  GST_DEBUG ("pos %d -> %d", pos1, pos2);

  // signal updates
  if (pos1 != pos2) {
    path = gtk_tree_path_new ();
    gtk_tree_path_append_index (path, pos1);
    gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
    gtk_tree_path_free (path);
    path = gtk_tree_path_new ();
    gtk_tree_path_append_index (path, pos2);
    gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
    gtk_tree_path_free (path);
  } else {
    path = gtk_tree_path_new ();
    gtk_tree_path_append_index (path, pos2);
    gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
    gtk_tree_path_free (path);
  }
}
示例#25
0
static void
g_file_monitor_source_finalize (GSource *source)
{
  GFileMonitorSource *fms = (GFileMonitorSource *) source;

  /* should already have been cleared in dispose of the monitor */
  g_assert (fms->instance == NULL);
  g_assert (g_sequence_get_length (fms->pending_changes) == 0);
  g_assert (g_hash_table_size (fms->pending_changes_table) == 0);
  g_assert (fms->event_queue.length == 0);

  g_hash_table_unref (fms->pending_changes_table);
  g_sequence_free (fms->pending_changes);

  g_free (fms->dirname);
  g_free (fms->basename);
  g_free (fms->filename);

  g_mutex_clear (&fms->lock);
}
示例#26
0
static void
query_add_blacklisted_filter (TrackerDecorator *decorator,
                              GString          *query)
{
	TrackerDecoratorPrivate *priv = decorator->priv;
	GSequenceIter *iter;

	if (g_sequence_get_length (priv->blacklist_items) == 0)
		return;

	g_string_append (query, "&& tracker:id(?urn) NOT IN (");

	iter = g_sequence_get_begin_iter (priv->blacklist_items);

	while (!g_sequence_iter_is_end (iter)) {
		query_append_id (query, GPOINTER_TO_INT (g_sequence_get (iter)));
		iter = g_sequence_iter_next (iter);
	}

	g_string_append (query, ")");
}
示例#27
0
void fm_folder_model_sort(FmFolderModel* model)
{
    GHashTable* old_order;
    gint *new_order;
    GSequenceIter *items_it;
    GtkTreePath *path;

    /* if there is only one item */
    if( model->items == NULL || g_sequence_get_length(model->items) <= 1 )
        return;

    old_order = g_hash_table_new(g_direct_hash, g_direct_equal);
    /* save old order */
    items_it = g_sequence_get_begin_iter(model->items);
    while( !g_sequence_iter_is_end(items_it) )
    {
        int i = g_sequence_iter_get_position(items_it);
        g_hash_table_insert( old_order, items_it, GINT_TO_POINTER(i) );
        items_it = g_sequence_iter_next(items_it);
    }

    /* sort the list */
    g_sequence_sort(model->items, fm_folder_model_compare, model);

    /* save new order */
    new_order = g_new( int, g_sequence_get_length(model->items) );
    items_it = g_sequence_get_begin_iter(model->items);
    while( !g_sequence_iter_is_end(items_it) )
    {
        int i = g_sequence_iter_get_position(items_it);
        new_order[i] = (guint)g_hash_table_lookup(old_order, items_it);
        items_it = g_sequence_iter_next(items_it);
    }
    g_hash_table_destroy(old_order);
    path = gtk_tree_path_new();
    gtk_tree_model_rows_reordered(GTK_TREE_MODEL(model),
                                  path, NULL, new_order);
    gtk_tree_path_free(path);
    g_free(new_order);
}
示例#28
0
static void
g_menu_exporter_group_subscribe (GMenuExporterGroup *group,
                                 GVariantBuilder    *builder)
{
  GHashTableIter iter;
  gpointer key, val;

  if (!group->prepared)
    {
      GMenuExporterMenu *menu;

      /* set this first, so that any menus created during the
       * preparation of the first menu also end up in the prepared
       * state.
       * */
      group->prepared = TRUE;

      menu = g_hash_table_lookup (group->menus, 0);
      g_menu_exporter_menu_prepare (menu);
    }

  group->subscribed++;

  g_hash_table_iter_init (&iter, group->menus);
  while (g_hash_table_iter_next (&iter, &key, &val))
    {
      guint id = GPOINTER_TO_INT (key);
      GMenuExporterMenu *menu = val;

      if (g_sequence_get_length (menu->item_links))
        {
          g_variant_builder_open (builder, G_VARIANT_TYPE ("(uuaa{sv})"));
          g_variant_builder_add (builder, "u", group->id);
          g_variant_builder_add (builder, "u", id);
          g_variant_builder_add_value (builder, g_menu_exporter_menu_list (menu));
          g_variant_builder_close (builder);
        }
    }
}
示例#29
0
static void
g_menu_exporter_menu_items_changed (GMenuModel *model,
                                    gint        position,
                                    gint        removed,
                                    gint        added,
                                    gpointer    user_data)
{
  GMenuExporterMenu *menu = user_data;
  GSequenceIter *point;
  gint i;

  g_assert (menu->model == model);
  g_assert (menu->item_links != NULL);
  g_assert (position + removed <= g_sequence_get_length (menu->item_links));

  point = g_sequence_get_iter_at_pos (menu->item_links, position + removed);
  g_sequence_remove_range (g_sequence_get_iter_at_pos (menu->item_links, position), point);

  for (i = position; i < position + added; i++)
    g_sequence_insert_before (point, g_menu_exporter_menu_create_links (menu, i));

  if (g_menu_exporter_group_is_subscribed (menu->group))
    {
      GVariantBuilder builder;

      g_variant_builder_init (&builder, G_VARIANT_TYPE ("(uuuuaa{sv})"));
      g_variant_builder_add (&builder, "u", g_menu_exporter_group_get_id (menu->group));
      g_variant_builder_add (&builder, "u", menu->id);
      g_variant_builder_add (&builder, "u", position);
      g_variant_builder_add (&builder, "u", removed);

      g_variant_builder_open (&builder, G_VARIANT_TYPE ("aa{sv}"));
      for (i = position; i < position + added; i++)
        g_variant_builder_add_value (&builder, g_menu_exporter_menu_describe_item (menu, i));
      g_variant_builder_close (&builder);

      g_menu_exporter_report (g_menu_exporter_group_get_exporter (menu->group), g_variant_builder_end (&builder));
    }
}
示例#30
0
static gboolean _is_store_iter_nth_child(GtkTreeModel *tree_model,
					 GtkTreeIter *iter,
					 GtkTreeIter *parent,
					 gint n)
{
	IsStore *self;
	IsStorePrivate *priv;
	IsStoreEntry *entry;
	gboolean ret = FALSE;

	g_return_val_if_fail(IS_IS_STORE(tree_model), FALSE);

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

	if (!parent &&
	    (n >= 0 && n < g_sequence_get_length(priv->entries)))
	{
		iter->stamp = priv->stamp;
		iter->user_data = g_sequence_get_iter_at_pos(priv->entries,
							     n);
		ret = TRUE;
		goto out;
	}

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

	entry = (IsStoreEntry *)
		g_sequence_get((GSequenceIter *)parent->user_data);
	if (entry->entries) {
		iter->stamp = priv->stamp;
		iter->user_data = g_sequence_get_iter_at_pos(entry->entries, n);
		ret = TRUE;
	}

out:
	return ret;
}