[glib/wip/menus-rebase2] Ditch GMenuModelItem
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/menus-rebase2] Ditch GMenuModelItem
- Date: Sat, 19 Nov 2011 04:44:46 +0000 (UTC)
commit 02556b135e27d894c98b6c2a1502b3f40af289ad
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 18 23:18:40 2011 -0500
Ditch GMenuModelItem
This is purely convenience API, and GMenuItem vs GMenuModelItem
is unnecessarily confusing.
docs/reference/gio/gio-sections.txt | 8 --
gio/gio.symbols | 6 --
gio/gmenumarkup.c | 7 +-
gio/gmenumodel.c | 171 +----------------------------------
gio/gmenumodel.h | 28 +------
5 files changed, 9 insertions(+), 211 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 8a784e8..fe89c12 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -3647,14 +3647,6 @@ g_menu_model_iterate_item_links
g_menu_model_items_changed
<SUBSECTION>
-GMenuModelItem
-g_menu_model_item_get_attribute_value
-g_menu_model_item_get_attribute
-g_menu_model_item_get_link
-g_menu_model_item_iterate_attributes
-g_menu_model_item_iterate_links
-
-<SUBSECTION>
GMenuAttributeIter
g_menu_attribute_iter_get_next
g_menu_attribute_iter_get_name
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 6e6b7db..5afbb7f 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1645,18 +1645,12 @@ g_menu_markup_parser_start
g_menu_markup_parser_start_menu
g_menu_markup_print_stderr
g_menu_markup_print_string
-g_menu_model_get_item
g_menu_model_get_item_attribute
g_menu_model_get_item_attribute_value
g_menu_model_get_item_link
g_menu_model_get_n_items
g_menu_model_get_type
g_menu_model_is_mutable
-g_menu_model_item_get_attribute
-g_menu_model_item_get_attribute_value
-g_menu_model_item_get_link
-g_menu_model_item_iterate_attributes
-g_menu_model_item_iterate_links
g_menu_model_items_changed
g_menu_model_items_changed_signal
g_menu_model_iterate_item_attributes
diff --git a/gio/gmenumarkup.c b/gio/gmenumarkup.c
index 6b2ff02..d198b37 100644
--- a/gio/gmenumarkup.c
+++ b/gio/gmenumarkup.c
@@ -585,14 +585,11 @@ g_menu_markup_print_string (GString *string,
{
GMenuAttributeIter *attr_iter;
GMenuLinkIter *link_iter;
- GMenuModelItem item;
GString *contents;
GString *attrs;
- g_menu_model_get_item (model, i, &item);
-
- attr_iter = g_menu_model_item_iterate_attributes (&item);
- link_iter = g_menu_model_item_iterate_links (&item);
+ attr_iter = g_menu_model_iterate_item_attributes (model, i);
+ link_iter = g_menu_model_iterate_item_links (model, i);
contents = g_string_new (NULL);
attrs = g_string_new (NULL);
diff --git a/gio/gmenumodel.c b/gio/gmenumodel.c
index 4a9fd59..873a886 100644
--- a/gio/gmenumodel.c
+++ b/gio/gmenumodel.c
@@ -54,16 +54,16 @@
* to make use of the exported information are #GDBusActionGroup and
* #GMenuProxy.
*
- * The concrete representation of #GMenuModel is a list of #GMenuModelItems,
- * see g_menu_model_get_item() and g_menu_model_get_n_items(). Each
- * item has attributes and links, see g_menu_model_item_iterate_attributes()
- * and g_menu_model_item_iterate_links(). Among the attributes are
+ * The concrete representation of #GMenuModel is a list of items,
+ * see g_menu_model_get_n_items(). Each
+ * item has attributes and links, see g_menu_model_iterate_item_attributes()
+ * and g_menu_model_iterate_item_links(). Among the attributes are
* representation data such as a user-visible label, but also the name
* of the associated action, see #G_MENU_ATTRIBUTE_LABEL and
* #G_MENU_ATTRIBUTE_ACTION. The links are used to connect an item with
* another menu model, which can represent either a section or a submenu,
* see #G_MENU_LINK_SECTION and #G_MENU_LINK_SUBMENU. To get the #GMenuModel
- * that a link points to, use g_menu_model_item_get_link() or
+ * that a link points to, use
* g_menu_link_iter_get_value().
*
* FIXME: explain how items are associated with actions.
@@ -90,14 +90,6 @@
* the functions below.
**/
-/**
- * GMenuModelItem:
- *
- * #GMenuModelItem is a structure type that is intended to be stack
- * allocated. You can initialise it using g_menu_model_get_item(). The
- * structure fields should be considered private and subject to change.
- **/
-
typedef struct
{
GMenuLinkIter parent_instance;
@@ -410,36 +402,6 @@ g_menu_model_get_n_items (GMenuModel *model)
}
/**
- * g_menu_model_get_item:
- * @model: a #GMenuModel
- * @item_index: the index of the item to get
- * @item: a #GMenuModelItem structure to store the item
- *
- * Initialises a #GMenuModelItem structure to act as a pointer to the
- * item at position @item_index in @model.
- *
- * The #GMenuModelItem will typically be stack-allocated. It remains
- * valid only for as long as the model exists and does not change. The
- * model is guaranteed not to change without returning to the mainloop
- * so it is quite safe to assume that a stack-allocated #GMenuModelItem
- * will remain valid for as long as it is in scope (as long as the
- * #GMenuModel is not destroyed).
- *
- * The #GMenuModelItem need not be initialised to any particular value
- * and does not need to be freed.
- **/
-void
-g_menu_model_get_item (GMenuModel *model,
- gint item_index,
- GMenuModelItem *item)
-{
- g_return_if_fail (G_IS_MENU_MODEL (model));
-
- item->model = model;
- item->position = item_index;
-}
-
-/**
* g_menu_model_iterate_item_attributes:
* @model: a #GMenuModel
* @item_index: the index of the item
@@ -910,126 +872,3 @@ g_menu_link_iter_class_init (GMenuLinkIterClass *class)
g_type_class_add_private (class, sizeof (GMenuLinkIterPrivate));
}
-
-/**
- * g_menu_model_item_iterate_attributes:
- * @item: a #GMenuModelItem
- *
- * Creates a #GMenuAttributeIter to iterate over the links of @item.
- *
- * You must free the iterator with g_object_unref() when you are done.
- *
- * Returns: (transfer full): a new #GMenuLinkIter
- **/
-GMenuAttributeIter *
-g_menu_model_item_iterate_attributes (GMenuModelItem *item)
-{
- return g_menu_model_iterate_item_attributes (item->model, item->position);
-}
-
-/**
- * g_menu_model_item_get_attribute_value:
- * @item: a #GMenuModelItem
- * @attribute: the attribute to query
- * @expected_type: (allow-none): the expected type of the attribute, or
- * %NULL
- *
- * Queries @item for the attribute specified by @attribute.
- *
- * If @expected_type is non-%NULL then it specifies the expected type of
- * the attribute. If it is %NULL then any type will be accepted.
- *
- * If the attribute exists and matches @expected_type (or if the
- * expected type is unspecified) then the value is returned.
- *
- * If the attribute does not exist, or does not match the expected type
- * then %NULL is returned.
- *
- * Returns: (transfer full): the value of the attribute
- **/
-GVariant *
-g_menu_model_item_get_attribute_value (GMenuModelItem *item,
- const gchar *attribute,
- const GVariantType *expected_type)
-{
- return g_menu_model_get_item_attribute_value (item->model, item->position, attribute, expected_type);
-}
-
-/**
- * g_menu_model_item_get_attribute:
- * @item: a #GMenuModelItem
- * @attribute: the attribute to query
- * @format_string: a #GVariant format string
- * @...: positional parameters, as per @format_string
- *
- * Queries @item for the attribute specified by @attribute.
- *
- * If the attribute exists and matches the #GVariantType corresponding
- * to @format_string then @format_string is used to deconstruct the
- * value into the positional parameters and %TRUE is returned.
- *
- * If the attribute does not exist, or it does exist but has the wrong
- * type, then the positional parameters are ignored and %FALSE is
- * returned.
- *
- * Returns: %TRUE if the named attribute was found with the expected
- * type
- **/
-gboolean
-g_menu_model_item_get_attribute (GMenuModelItem *item,
- const gchar *attribute,
- const gchar *format_string,
- ...)
-{
- const GVariantType *expected_type;
- GVariant *value;
- va_list ap;
-
- expected_type = NULL; /* XXX devine the type, ensure no '&' */
-
- value = g_menu_model_get_item_attribute_value (item->model, item->position, attribute, expected_type);
- if (value == NULL)
- return FALSE;
-
- va_start (ap, format_string);
- g_variant_get_va (value, format_string, NULL, &ap);
- g_variant_unref (value);
- va_end (ap);
-
- return TRUE;
-}
-
-/**
- * g_menu_model_item_iterate_links:
- * @item: a #GMenuModelItem
- *
- * Creates a #GMenuLinkIter to iterate over the links of @item.
- *
- * You must free the iterator with g_object_unref() when you are done.
- *
- * Returns: (transfer full): a new #GMenuLinkIter
- **/
-GMenuLinkIter *
-g_menu_model_item_iterate_links (GMenuModelItem *item)
-{
- return g_menu_model_iterate_item_links (item->model, item->position);
-}
-
-/**
- * g_menu_model_item_get_link:
- * @item: a #GMenuModelItem
- * @link: the link to query
- *
- * Queries @item for the link specified by @link.
- *
- * If the link exists, the linked #GMenuModel is returned.
- * If the link does not exist, %NULL is returned.
- *
- * Returns: (transfer full): the linked #GMenuModel, or %NULL
- **/
-GMenuModel *
-g_menu_model_item_get_link (GMenuModelItem *item,
- const gchar *link)
-{
- return g_menu_model_get_item_link (item->model, item->position, link);
-}
diff --git a/gio/gmenumodel.h b/gio/gmenumodel.h
index 8ae8ae9..6e5ed39 100644
--- a/gio/gmenumodel.h
+++ b/gio/gmenumodel.h
@@ -59,8 +59,6 @@ typedef struct _GMenuLinkIterPrivate GMenuLinkIterPrivate
typedef struct _GMenuLinkIterClass GMenuLinkIterClass;
typedef struct _GMenuLinkIter GMenuLinkIter;
-typedef struct _GMenuModelItem GMenuModelItem;
-
struct _GMenuModel
{
GObject parent_instance;
@@ -96,9 +94,6 @@ GType g_menu_model_get_type (void) G
gboolean g_menu_model_is_mutable (GMenuModel *model);
gint g_menu_model_get_n_items (GMenuModel *model);
-void g_menu_model_get_item (GMenuModel *model,
- gint item_index,
- GMenuModelItem *item);
GMenuAttributeIter * g_menu_model_iterate_item_attributes (GMenuModel *model,
gint item_index);
@@ -146,7 +141,7 @@ struct _GMenuAttributeIterClass
GObjectClass parent_class;
gboolean (*get_next) (GMenuAttributeIter *iter,
- const gchar **out_type,
+ const gchar **out_type,
GVariant **value);
};
@@ -183,7 +178,7 @@ struct _GMenuLinkIterClass
GObjectClass parent_class;
gboolean (*get_next) (GMenuLinkIter *iter,
- const gchar **out_name,
+ const gchar **out_name,
GMenuModel **value);
};
@@ -196,25 +191,6 @@ gboolean g_menu_link_iter_next (GMenuLi
const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter);
GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter);
-struct _GMenuModelItem
-{
- /*< private >*/
- GMenuModel *model;
- gint position;
-};
-
-GMenuAttributeIter * g_menu_model_item_iterate_attributes (GMenuModelItem *item);
-GVariant * g_menu_model_item_get_attribute_value (GMenuModelItem *item,
- const gchar *attribute,
- const GVariantType *expected_type);
-gboolean g_menu_model_item_get_attribute (GMenuModelItem *item,
- const gchar *attribute,
- const gchar *format_string,
- ...);
-GMenuLinkIter * g_menu_model_item_iterate_links (GMenuModelItem *item);
-GMenuModel * g_menu_model_item_get_link (GMenuModelItem *item,
- const gchar *link);
-
G_END_DECLS
#endif /* __G_MENU_MODEL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]