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>
32 * G_MENU_ATTRIBUTE_ACTION:
34 * The menu item attribute which holds the action name of the item. Action
35 * names are namespaced with an identifier for the action group in which the
36 * action resides. For example, "win." for window-specific actions and "app."
37 * for application-wide actions.
39 * See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute().
43 #define G_MENU_ATTRIBUTE_ACTION "action"
46 * G_MENU_ATTRIBUTE_ACTION_NAMESPACE:
48 * The menu item attribute that holds the namespace for all action names in
49 * menus that are linked from this item.
53 #define G_MENU_ATTRIBUTE_ACTION_NAMESPACE "action-namespace"
56 * G_MENU_ATTRIBUTE_TARGET:
58 * The menu item attribute which holds the target with which the item's action
61 * See also g_menu_item_set_action_and_target()
65 #define G_MENU_ATTRIBUTE_TARGET "target"
68 * G_MENU_ATTRIBUTE_LABEL:
70 * The menu item attribute which holds the label of the item.
74 #define G_MENU_ATTRIBUTE_LABEL "label"
77 * G_MENU_LINK_SUBMENU:
79 * The name of the link that associates a menu item with a submenu.
81 * See also g_menu_item_set_link().
85 #define G_MENU_LINK_SUBMENU "submenu"
88 * G_MENU_LINK_SECTION:
90 * The name of the link that associates a menu item with a section. The linked
91 * menu will usually be shown in place of the menu item, using the item's label
94 * See also g_menu_item_set_link().
98 #define G_MENU_LINK_SECTION "section"
100 #define G_TYPE_MENU_MODEL (g_menu_model_get_type ())
101 #define G_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
102 G_TYPE_MENU_MODEL, GMenuModel))
103 #define G_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
104 G_TYPE_MENU_MODEL, GMenuModelClass))
105 #define G_IS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
107 #define G_IS_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
109 #define G_MENU_MODEL_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
110 G_TYPE_MENU_MODEL, GMenuModelClass))
112 typedef struct _GMenuModelPrivate GMenuModelPrivate;
113 typedef struct _GMenuModelClass GMenuModelClass;
115 typedef struct _GMenuAttributeIterPrivate GMenuAttributeIterPrivate;
116 typedef struct _GMenuAttributeIterClass GMenuAttributeIterClass;
117 typedef struct _GMenuAttributeIter GMenuAttributeIter;
119 typedef struct _GMenuLinkIterPrivate GMenuLinkIterPrivate;
120 typedef struct _GMenuLinkIterClass GMenuLinkIterClass;
121 typedef struct _GMenuLinkIter GMenuLinkIter;
125 GObject parent_instance;
126 GMenuModelPrivate *priv;
129 struct _GMenuModelClass
131 GObjectClass parent_class;
133 gboolean (*is_mutable) (GMenuModel *model);
134 gint (*get_n_items) (GMenuModel *model);
135 void (*get_item_attributes) (GMenuModel *model,
137 GHashTable **attributes);
138 GMenuAttributeIter * (*iterate_item_attributes) (GMenuModel *model,
140 GVariant * (*get_item_attribute_value) (GMenuModel *model,
142 const gchar *attribute,
143 const GVariantType *expected_type);
144 void (*get_item_links) (GMenuModel *model,
147 GMenuLinkIter * (*iterate_item_links) (GMenuModel *model,
149 GMenuModel * (*get_item_link) (GMenuModel *model,
154 GLIB_AVAILABLE_IN_2_32
155 GType g_menu_model_get_type (void) G_GNUC_CONST;
157 GLIB_AVAILABLE_IN_2_32
158 gboolean g_menu_model_is_mutable (GMenuModel *model);
159 GLIB_AVAILABLE_IN_2_32
160 gint g_menu_model_get_n_items (GMenuModel *model);
162 GLIB_AVAILABLE_IN_2_32
163 GMenuAttributeIter * g_menu_model_iterate_item_attributes (GMenuModel *model,
165 GLIB_AVAILABLE_IN_2_32
166 GVariant * g_menu_model_get_item_attribute_value (GMenuModel *model,
168 const gchar *attribute,
169 const GVariantType *expected_type);
170 GLIB_AVAILABLE_IN_2_32
171 gboolean g_menu_model_get_item_attribute (GMenuModel *model,
173 const gchar *attribute,
174 const gchar *format_string,
176 GLIB_AVAILABLE_IN_2_32
177 GMenuLinkIter * g_menu_model_iterate_item_links (GMenuModel *model,
179 GLIB_AVAILABLE_IN_2_32
180 GMenuModel * g_menu_model_get_item_link (GMenuModel *model,
184 GLIB_AVAILABLE_IN_2_32
185 void g_menu_model_items_changed (GMenuModel *model,
191 #define G_TYPE_MENU_ATTRIBUTE_ITER (g_menu_attribute_iter_get_type ())
192 #define G_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
193 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter))
194 #define G_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
195 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
196 #define G_IS_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
197 G_TYPE_MENU_ATTRIBUTE_ITER))
198 #define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
199 G_TYPE_MENU_ATTRIBUTE_ITER))
200 #define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
201 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
203 struct _GMenuAttributeIter
205 GObject parent_instance;
206 GMenuAttributeIterPrivate *priv;
209 struct _GMenuAttributeIterClass
211 GObjectClass parent_class;
213 gboolean (*get_next) (GMenuAttributeIter *iter,
214 const gchar **out_name,
218 GLIB_AVAILABLE_IN_2_32
219 GType g_menu_attribute_iter_get_type (void) G_GNUC_CONST;
221 GLIB_AVAILABLE_IN_2_32
222 gboolean g_menu_attribute_iter_get_next (GMenuAttributeIter *iter,
223 const gchar **out_name,
225 GLIB_AVAILABLE_IN_2_32
226 gboolean g_menu_attribute_iter_next (GMenuAttributeIter *iter);
227 GLIB_AVAILABLE_IN_2_32
228 const gchar * g_menu_attribute_iter_get_name (GMenuAttributeIter *iter);
229 GLIB_AVAILABLE_IN_2_32
230 GVariant * g_menu_attribute_iter_get_value (GMenuAttributeIter *iter);
233 #define G_TYPE_MENU_LINK_ITER (g_menu_link_iter_get_type ())
234 #define G_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
235 G_TYPE_MENU_LINK_ITER, GMenuLinkIter))
236 #define G_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
237 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
238 #define G_IS_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
239 G_TYPE_MENU_LINK_ITER))
240 #define G_IS_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
241 G_TYPE_MENU_LINK_ITER))
242 #define G_MENU_LINK_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
243 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
245 struct _GMenuLinkIter
247 GObject parent_instance;
248 GMenuLinkIterPrivate *priv;
251 struct _GMenuLinkIterClass
253 GObjectClass parent_class;
255 gboolean (*get_next) (GMenuLinkIter *iter,
256 const gchar **out_link,
260 GLIB_AVAILABLE_IN_2_32
261 GType g_menu_link_iter_get_type (void) G_GNUC_CONST;
263 GLIB_AVAILABLE_IN_2_32
264 gboolean g_menu_link_iter_get_next (GMenuLinkIter *iter,
265 const gchar **out_link,
267 GLIB_AVAILABLE_IN_2_32
268 gboolean g_menu_link_iter_next (GMenuLinkIter *iter);
269 GLIB_AVAILABLE_IN_2_32
270 const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter);
271 GLIB_AVAILABLE_IN_2_32
272 GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter);
276 #endif /* __G_MENU_MODEL_H__ */