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_TARGET:
48 * The menu item attribute which holds the target with which the item's action
51 * See also g_menu_item_set_action_and_target()
55 #define G_MENU_ATTRIBUTE_TARGET "target"
58 * G_MENU_ATTRIBUTE_LABEL:
60 * The menu item attribute which holds the label of the item.
64 #define G_MENU_ATTRIBUTE_LABEL "label"
67 * G_MENU_LINK_SUBMENU:
69 * The name of the link that associates a menu item with a submenu.
71 * See also g_menu_item_set_link().
75 #define G_MENU_LINK_SUBMENU "submenu"
78 * G_MENU_LINK_SUBMENU:
80 * The name of the link that associates a menu item with a section. The linked
81 * menu will usually be shown in place of the menu item, using the item's label
84 * See also g_menu_item_set_link().
88 #define G_MENU_LINK_SECTION "section"
90 #define G_TYPE_MENU_MODEL (g_menu_model_get_type ())
91 #define G_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
92 G_TYPE_MENU_MODEL, GMenuModel))
93 #define G_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
94 G_TYPE_MENU_MODEL, GMenuModelClass))
95 #define G_IS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
97 #define G_IS_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
99 #define G_MENU_MODEL_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
100 G_TYPE_MENU_MODEL, GMenuModelClass))
102 typedef struct _GMenuModelPrivate GMenuModelPrivate;
103 typedef struct _GMenuModelClass GMenuModelClass;
105 typedef struct _GMenuAttributeIterPrivate GMenuAttributeIterPrivate;
106 typedef struct _GMenuAttributeIterClass GMenuAttributeIterClass;
107 typedef struct _GMenuAttributeIter GMenuAttributeIter;
109 typedef struct _GMenuLinkIterPrivate GMenuLinkIterPrivate;
110 typedef struct _GMenuLinkIterClass GMenuLinkIterClass;
111 typedef struct _GMenuLinkIter GMenuLinkIter;
115 GObject parent_instance;
116 GMenuModelPrivate *priv;
119 struct _GMenuModelClass
121 GObjectClass parent_class;
123 gboolean (*is_mutable) (GMenuModel *model);
124 gint (*get_n_items) (GMenuModel *model);
125 void (*get_item_attributes) (GMenuModel *model,
127 GHashTable **attributes);
128 GMenuAttributeIter * (*iterate_item_attributes) (GMenuModel *model,
130 GVariant * (*get_item_attribute_value) (GMenuModel *model,
132 const gchar *attribute,
133 const GVariantType *expected_type);
134 void (*get_item_links) (GMenuModel *model,
137 GMenuLinkIter * (*iterate_item_links) (GMenuModel *model,
139 GMenuModel * (*get_item_link) (GMenuModel *model,
144 GLIB_AVAILABLE_IN_2_32
145 GType g_menu_model_get_type (void) G_GNUC_CONST;
147 GLIB_AVAILABLE_IN_2_32
148 gboolean g_menu_model_is_mutable (GMenuModel *model);
149 GLIB_AVAILABLE_IN_2_32
150 gint g_menu_model_get_n_items (GMenuModel *model);
152 GLIB_AVAILABLE_IN_2_32
153 GMenuAttributeIter * g_menu_model_iterate_item_attributes (GMenuModel *model,
155 GLIB_AVAILABLE_IN_2_32
156 GVariant * g_menu_model_get_item_attribute_value (GMenuModel *model,
158 const gchar *attribute,
159 const GVariantType *expected_type);
160 GLIB_AVAILABLE_IN_2_32
161 gboolean g_menu_model_get_item_attribute (GMenuModel *model,
163 const gchar *attribute,
164 const gchar *format_string,
166 GLIB_AVAILABLE_IN_2_32
167 GMenuLinkIter * g_menu_model_iterate_item_links (GMenuModel *model,
169 GLIB_AVAILABLE_IN_2_32
170 GMenuModel * g_menu_model_get_item_link (GMenuModel *model,
174 GLIB_AVAILABLE_IN_2_32
175 void g_menu_model_items_changed (GMenuModel *model,
181 #define G_TYPE_MENU_ATTRIBUTE_ITER (g_menu_attribute_iter_get_type ())
182 #define G_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
183 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter))
184 #define G_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
185 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
186 #define G_IS_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
187 G_TYPE_MENU_ATTRIBUTE_ITER))
188 #define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
189 G_TYPE_MENU_ATTRIBUTE_ITER))
190 #define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
191 G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
193 struct _GMenuAttributeIter
195 GObject parent_instance;
196 GMenuAttributeIterPrivate *priv;
199 struct _GMenuAttributeIterClass
201 GObjectClass parent_class;
203 gboolean (*get_next) (GMenuAttributeIter *iter,
204 const gchar **out_type,
208 GLIB_AVAILABLE_IN_2_32
209 GType g_menu_attribute_iter_get_type (void) G_GNUC_CONST;
211 GLIB_AVAILABLE_IN_2_32
212 gboolean g_menu_attribute_iter_get_next (GMenuAttributeIter *iter,
213 const gchar **out_name,
215 GLIB_AVAILABLE_IN_2_32
216 gboolean g_menu_attribute_iter_next (GMenuAttributeIter *iter);
217 GLIB_AVAILABLE_IN_2_32
218 const gchar * g_menu_attribute_iter_get_name (GMenuAttributeIter *iter);
219 GLIB_AVAILABLE_IN_2_32
220 GVariant * g_menu_attribute_iter_get_value (GMenuAttributeIter *iter);
223 #define G_TYPE_MENU_LINK_ITER (g_menu_link_iter_get_type ())
224 #define G_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
225 G_TYPE_MENU_LINK_ITER, GMenuLinkIter))
226 #define G_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
227 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
228 #define G_IS_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
229 G_TYPE_MENU_LINK_ITER))
230 #define G_IS_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
231 G_TYPE_MENU_LINK_ITER))
232 #define G_MENU_LINK_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
233 G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
235 struct _GMenuLinkIter
237 GObject parent_instance;
238 GMenuLinkIterPrivate *priv;
241 struct _GMenuLinkIterClass
243 GObjectClass parent_class;
245 gboolean (*get_next) (GMenuLinkIter *iter,
246 const gchar **out_name,
250 GLIB_AVAILABLE_IN_2_32
251 GType g_menu_link_iter_get_type (void) G_GNUC_CONST;
253 GLIB_AVAILABLE_IN_2_32
254 gboolean g_menu_link_iter_get_next (GMenuLinkIter *iter,
255 const gchar **out_link,
257 GLIB_AVAILABLE_IN_2_32
258 gboolean g_menu_link_iter_next (GMenuLinkIter *iter);
259 GLIB_AVAILABLE_IN_2_32
260 const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter);
261 GLIB_AVAILABLE_IN_2_32
262 GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter);
266 #endif /* __G_MENU_MODEL_H__ */