More doc fixes
[platform/upstream/glib.git] / gio / gmenumodel.h
1 /*
2  * Copyright © 2011 Canonical Ltd.
3  *
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.
8  *
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.
13  *
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,
17  * USA.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #ifndef __G_MENU_MODEL_H__
23 #define __G_MENU_MODEL_H__
24
25 #include <glib-object.h>
26
27 #include <gio/giotypes.h>
28
29 G_BEGIN_DECLS
30
31 /**
32  * G_MENU_ATTRIBUTE_ACTION:
33  *
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.
38  *
39  * See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute().
40  *
41  * Since: 2.32
42  **/
43 #define G_MENU_ATTRIBUTE_ACTION "action"
44
45 /**
46  * G_MENU_ATTRIBUTE_ACTION_NAMESPACE:
47  *
48  * The menu item attribute that holds the namespace for all action names in
49  * menus that are linked from this item.
50  *
51  * Since: 2.36
52  **/
53 #define G_MENU_ATTRIBUTE_ACTION_NAMESPACE "action-namespace"
54
55 /**
56  * G_MENU_ATTRIBUTE_TARGET:
57  *
58  * The menu item attribute which holds the target with which the item's action
59  * will be activated.
60  *
61  * See also g_menu_item_set_action_and_target()
62  *
63  * Since: 2.32
64  **/
65 #define G_MENU_ATTRIBUTE_TARGET "target"
66
67 /**
68  * G_MENU_ATTRIBUTE_LABEL:
69  *
70  * The menu item attribute which holds the label of the item.
71  *
72  * Since: 2.32
73  **/
74 #define G_MENU_ATTRIBUTE_LABEL "label"
75
76 /**
77  * G_MENU_LINK_SUBMENU:
78  *
79  * The name of the link that associates a menu item with a submenu.
80  *
81  * See also g_menu_item_set_link().
82  *
83  * Since: 2.32
84  **/
85 #define G_MENU_LINK_SUBMENU "submenu"
86
87 /**
88  * G_MENU_LINK_SECTION:
89  *
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
92  * as a header.
93  *
94  * See also g_menu_item_set_link().
95  *
96  * Since: 2.32
97  **/
98 #define G_MENU_LINK_SECTION "section"
99
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),                     \
106                                                              G_TYPE_MENU_MODEL))
107 #define G_IS_MENU_MODEL_CLASS(class)                        (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
108                                                              G_TYPE_MENU_MODEL))
109 #define G_MENU_MODEL_GET_CLASS(inst)                        (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
110                                                              G_TYPE_MENU_MODEL, GMenuModelClass))
111
112 typedef struct _GMenuModelPrivate                           GMenuModelPrivate;
113 typedef struct _GMenuModelClass                             GMenuModelClass;
114
115 typedef struct _GMenuAttributeIterPrivate                   GMenuAttributeIterPrivate;
116 typedef struct _GMenuAttributeIterClass                     GMenuAttributeIterClass;
117 typedef struct _GMenuAttributeIter                          GMenuAttributeIter;
118
119 typedef struct _GMenuLinkIterPrivate                        GMenuLinkIterPrivate;
120 typedef struct _GMenuLinkIterClass                          GMenuLinkIterClass;
121 typedef struct _GMenuLinkIter                               GMenuLinkIter;
122
123 struct _GMenuModel
124 {
125   GObject            parent_instance;
126   GMenuModelPrivate *priv;
127 };
128
129 struct _GMenuModelClass
130 {
131   GObjectClass parent_class;
132
133   gboolean              (*is_mutable)                       (GMenuModel          *model);
134   gint                  (*get_n_items)                      (GMenuModel          *model);
135   void                  (*get_item_attributes)              (GMenuModel          *model,
136                                                              gint                 item_index,
137                                                              GHashTable         **attributes);
138   GMenuAttributeIter *  (*iterate_item_attributes)          (GMenuModel          *model,
139                                                              gint                 item_index);
140   GVariant *            (*get_item_attribute_value)         (GMenuModel          *model,
141                                                              gint                 item_index,
142                                                              const gchar         *attribute,
143                                                              const GVariantType  *expected_type);
144   void                  (*get_item_links)                   (GMenuModel          *model,
145                                                              gint                 item_index,
146                                                              GHashTable         **links);
147   GMenuLinkIter *       (*iterate_item_links)               (GMenuModel          *model,
148                                                              gint                 item_index);
149   GMenuModel *          (*get_item_link)                    (GMenuModel          *model,
150                                                              gint                 item_index,
151                                                              const gchar         *link);
152 };
153
154 GLIB_AVAILABLE_IN_2_32
155 GType                   g_menu_model_get_type                           (void) G_GNUC_CONST;
156
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);
161
162 GLIB_AVAILABLE_IN_2_32
163 GMenuAttributeIter *    g_menu_model_iterate_item_attributes            (GMenuModel         *model,
164                                                                          gint                item_index);
165 GLIB_AVAILABLE_IN_2_32
166 GVariant *              g_menu_model_get_item_attribute_value           (GMenuModel         *model,
167                                                                          gint                item_index,
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,
172                                                                          gint                item_index,
173                                                                          const gchar        *attribute,
174                                                                          const gchar        *format_string,
175                                                                          ...);
176 GLIB_AVAILABLE_IN_2_32
177 GMenuLinkIter *         g_menu_model_iterate_item_links                 (GMenuModel         *model,
178                                                                          gint                item_index);
179 GLIB_AVAILABLE_IN_2_32
180 GMenuModel *            g_menu_model_get_item_link                      (GMenuModel         *model,
181                                                                          gint                item_index,
182                                                                          const gchar        *link);
183
184 GLIB_AVAILABLE_IN_2_32
185 void                    g_menu_model_items_changed                      (GMenuModel         *model,
186                                                                          gint                position,
187                                                                          gint                removed,
188                                                                          gint                added);
189
190
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))
202
203 struct _GMenuAttributeIter
204 {
205   GObject parent_instance;
206   GMenuAttributeIterPrivate *priv;
207 };
208
209 struct _GMenuAttributeIterClass
210 {
211   GObjectClass parent_class;
212
213   gboolean      (*get_next) (GMenuAttributeIter  *iter,
214                              const gchar        **out_name,
215                              GVariant           **value);
216 };
217
218 GLIB_AVAILABLE_IN_2_32
219 GType                   g_menu_attribute_iter_get_type                  (void) G_GNUC_CONST;
220
221 GLIB_AVAILABLE_IN_2_32
222 gboolean                g_menu_attribute_iter_get_next                  (GMenuAttributeIter  *iter,
223                                                                          const gchar        **out_name,
224                                                                          GVariant           **value);
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);
231
232
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))
244
245 struct _GMenuLinkIter
246 {
247   GObject parent_instance;
248   GMenuLinkIterPrivate *priv;
249 };
250
251 struct _GMenuLinkIterClass
252 {
253   GObjectClass parent_class;
254
255   gboolean      (*get_next) (GMenuLinkIter  *iter,
256                              const gchar   **out_link,
257                              GMenuModel    **value);
258 };
259
260 GLIB_AVAILABLE_IN_2_32
261 GType                   g_menu_link_iter_get_type                       (void) G_GNUC_CONST;
262
263 GLIB_AVAILABLE_IN_2_32
264 gboolean                g_menu_link_iter_get_next                       (GMenuLinkIter  *iter,
265                                                                          const gchar   **out_link,
266                                                                          GMenuModel    **value);
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);
273
274 G_END_DECLS
275
276 #endif /* __G_MENU_MODEL_H__ */