2 * Copyright © 2011 Canonical Ltd.
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * licence, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * Author: Ryan Lortie <desrt@desrt.ca>
22 #ifndef __G_MENU_MODEL_H__
23 #define __G_MENU_MODEL_H__
25 #include <glib-object.h>
27 #include <gio/giotypes.h>
31 #define G_MENU_ATTRIBUTE_ACTION "action"
32 #define G_MENU_ATTRIBUTE_TARGET "target"
33 #define G_MENU_ATTRIBUTE_LABEL "label"
35 #define G_MENU_LINK_SUBMENU "submenu"
36 #define G_MENU_LINK_SECTION "section"
38 #define G_TYPE_MENU_MODEL (g_menu_model_get_type ())
39 #define G_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
40 G_TYPE_MENU_MODEL, GMenuModel))
41 #define G_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
42 G_TYPE_MENU_MODEL, GMenuModelClass))
43 #define G_IS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
45 #define G_IS_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
47 #define G_MENU_MODEL_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
48 G_TYPE_MENU_MODEL, GMenuModelClass))
50 typedef struct _GMenuModelPrivate GMenuModelPrivate;
51 typedef struct _GMenuModelClass GMenuModelClass;
53 typedef struct _GMenuAttributeIterPrivate GMenuAttributeIterPrivate;
54 typedef struct _GMenuAttributeIterClass GMenuAttributeIterClass;
55 typedef struct _GMenuAttributeIter GMenuAttributeIter;
57 typedef struct _GMenuLinkIterPrivate GMenuLinkIterPrivate;
58 typedef struct _GMenuLinkIterClass GMenuLinkIterClass;
59 typedef struct _GMenuLinkIter GMenuLinkIter;
63 GObject parent_instance;
64 GMenuModelPrivate *priv;
67 struct _GMenuModelClass
69 GObjectClass parent_class;
71 gboolean (*is_mutable) (GMenuModel *model);
72 gint (*get_n_items) (GMenuModel *model);
73 void (*get_item_attributes) (GMenuModel *model,
75 GHashTable **attributes);
76 GMenuAttributeIter * (*iterate_item_attributes) (GMenuModel *model,
78 GVariant * (*get_item_attribute_value) (GMenuModel *model,
80 const gchar *attribute,
81 const GVariantType *expected_type);
82 void (*get_item_links) (GMenuModel *model,
85 GMenuLinkIter * (*iterate_item_links) (GMenuModel *model,
87 GMenuModel * (*get_item_link) (GMenuModel *model,
92 GLIB_AVAILABLE_IN_2_32
93 GType g_menu_model_get_type (void) G_GNUC_CONST;
95 GLIB_AVAILABLE_IN_2_32
96 gboolean g_menu_model_is_mutable (GMenuModel *model);
97 GLIB_AVAILABLE_IN_2_32
98 gint g_menu_model_get_n_items (GMenuModel *model);
100 GLIB_AVAILABLE_IN_2_32
101 GMenuAttributeIter * g_menu_model_iterate_item_attributes (GMenuModel *model,
103 GLIB_AVAILABLE_IN_2_32
104 GVariant * g_menu_model_get_item_attribute_value (GMenuModel *model,
106 const gchar *attribute,
107 const GVariantType *expected_type);
108 GLIB_AVAILABLE_IN_2_32
109 gboolean g_menu_model_get_item_attribute (GMenuModel *model,
111 const gchar *attribute,
112 const gchar *format_string,
114 GLIB_AVAILABLE_IN_2_32
115 GMenuLinkIter * g_menu_model_iterate_item_links (GMenuModel *model,
117 GLIB_AVAILABLE_IN_2_32
118 GMenuModel * g_menu_model_get_item_link (GMenuModel *model,
122 GLIB_AVAILABLE_IN_2_32
123 void g_menu_model_items_changed (GMenuModel *model,
129 #define G_TYPE_MENU_ATTRIBUTE_ITER (g_menu_attribute_iter_get_type ())
130 #define G_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
131 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter))
132 #define G_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
133 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
134 #define G_IS_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
135 G_TYPE_MENU_ATTRIBUTE_ITER))
136 #define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
137 G_TYPE_MENU_ATTRIBUTE_ITER))
138 #define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
139 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
141 struct _GMenuAttributeIter
143 GObject parent_instance;
144 GMenuAttributeIterPrivate *priv;
147 struct _GMenuAttributeIterClass
149 GObjectClass parent_class;
151 gboolean (*get_next) (GMenuAttributeIter *iter,
152 const gchar **out_type,
156 GLIB_AVAILABLE_IN_2_32
157 GType g_menu_attribute_iter_get_type (void) G_GNUC_CONST;
159 GLIB_AVAILABLE_IN_2_32
160 gboolean g_menu_attribute_iter_get_next (GMenuAttributeIter *iter,
161 const gchar **out_name,
163 GLIB_AVAILABLE_IN_2_32
164 gboolean g_menu_attribute_iter_next (GMenuAttributeIter *iter);
165 GLIB_AVAILABLE_IN_2_32
166 const gchar * g_menu_attribute_iter_get_name (GMenuAttributeIter *iter);
167 GLIB_AVAILABLE_IN_2_32
168 GVariant * g_menu_attribute_iter_get_value (GMenuAttributeIter *iter);
171 #define G_TYPE_MENU_LINK_ITER (g_menu_link_iter_get_type ())
172 #define G_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
173 G_TYPE_MENU_LINK_ITER, GMenuLinkIter))
174 #define G_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
175 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
176 #define G_IS_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
177 G_TYPE_MENU_LINK_ITER))
178 #define G_IS_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
179 G_TYPE_MENU_LINK_ITER))
180 #define G_MENU_LINK_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
181 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
183 struct _GMenuLinkIter
185 GObject parent_instance;
186 GMenuLinkIterPrivate *priv;
189 struct _GMenuLinkIterClass
191 GObjectClass parent_class;
193 gboolean (*get_next) (GMenuLinkIter *iter,
194 const gchar **out_name,
198 GLIB_AVAILABLE_IN_2_32
199 GType g_menu_link_iter_get_type (void) G_GNUC_CONST;
201 GLIB_AVAILABLE_IN_2_32
202 gboolean g_menu_link_iter_get_next (GMenuLinkIter *iter,
203 const gchar **out_link,
205 GLIB_AVAILABLE_IN_2_32
206 gboolean g_menu_link_iter_next (GMenuLinkIter *iter);
207 GLIB_AVAILABLE_IN_2_32
208 const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter);
209 GLIB_AVAILABLE_IN_2_32
210 GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter);
214 #endif /* __G_MENU_MODEL_H__ */