gio: GLIB_AVAILABLE_IN to more APIs
[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 #define G_MENU_ATTRIBUTE_ACTION "action"
32 #define G_MENU_ATTRIBUTE_TARGET "target"
33 #define G_MENU_ATTRIBUTE_LABEL "label"
34
35 #define G_MENU_LINK_SUBMENU "submenu"
36 #define G_MENU_LINK_SECTION "section"
37
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),                     \
44                                                              G_TYPE_MENU_MODEL))
45 #define G_IS_MENU_MODEL_CLASS(class)                        (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
46                                                              G_TYPE_MENU_MODEL))
47 #define G_MENU_MODEL_GET_CLASS(inst)                        (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
48                                                              G_TYPE_MENU_MODEL, GMenuModelClass))
49
50 typedef struct _GMenuModelPrivate                           GMenuModelPrivate;
51 typedef struct _GMenuModelClass                             GMenuModelClass;
52
53 typedef struct _GMenuAttributeIterPrivate                   GMenuAttributeIterPrivate;
54 typedef struct _GMenuAttributeIterClass                     GMenuAttributeIterClass;
55 typedef struct _GMenuAttributeIter                          GMenuAttributeIter;
56
57 typedef struct _GMenuLinkIterPrivate                        GMenuLinkIterPrivate;
58 typedef struct _GMenuLinkIterClass                          GMenuLinkIterClass;
59 typedef struct _GMenuLinkIter                               GMenuLinkIter;
60
61 struct _GMenuModel
62 {
63   GObject            parent_instance;
64   GMenuModelPrivate *priv;
65 };
66
67 struct _GMenuModelClass
68 {
69   GObjectClass parent_class;
70
71   gboolean              (*is_mutable)                       (GMenuModel          *model);
72   gint                  (*get_n_items)                      (GMenuModel          *model);
73   void                  (*get_item_attributes)              (GMenuModel          *model,
74                                                              gint                 item_index,
75                                                              GHashTable         **attributes);
76   GMenuAttributeIter *  (*iterate_item_attributes)          (GMenuModel          *model,
77                                                              gint                 item_index);
78   GVariant *            (*get_item_attribute_value)         (GMenuModel          *model,
79                                                              gint                 item_index,
80                                                              const gchar         *attribute,
81                                                              const GVariantType  *expected_type);
82   void                  (*get_item_links)                   (GMenuModel          *model,
83                                                              gint                 item_index,
84                                                              GHashTable         **links);
85   GMenuLinkIter *       (*iterate_item_links)               (GMenuModel          *model,
86                                                              gint                 item_index);
87   GMenuModel *          (*get_item_link)                    (GMenuModel          *model,
88                                                              gint                 item_index,
89                                                              const gchar         *link);
90 };
91
92 GLIB_AVAILABLE_IN_2_32
93 GType                   g_menu_model_get_type                           (void) G_GNUC_CONST;
94
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);
99
100 GLIB_AVAILABLE_IN_2_32
101 GMenuAttributeIter *    g_menu_model_iterate_item_attributes            (GMenuModel         *model,
102                                                                          gint                item_index);
103 GLIB_AVAILABLE_IN_2_32
104 GVariant *              g_menu_model_get_item_attribute_value           (GMenuModel         *model,
105                                                                          gint                item_index,
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,
110                                                                          gint                item_index,
111                                                                          const gchar        *attribute,
112                                                                          const gchar        *format_string,
113                                                                          ...);
114 GLIB_AVAILABLE_IN_2_32
115 GMenuLinkIter *         g_menu_model_iterate_item_links                 (GMenuModel         *model,
116                                                                          gint                item_index);
117 GLIB_AVAILABLE_IN_2_32
118 GMenuModel *            g_menu_model_get_item_link                      (GMenuModel         *model,
119                                                                          gint                item_index,
120                                                                          const gchar        *link);
121
122 GLIB_AVAILABLE_IN_2_32
123 void                    g_menu_model_items_changed                      (GMenuModel         *model,
124                                                                          gint                position,
125                                                                          gint                removed,
126                                                                          gint                added);
127
128
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))
140
141 struct _GMenuAttributeIter
142 {
143   GObject parent_instance;
144   GMenuAttributeIterPrivate *priv;
145 };
146
147 struct _GMenuAttributeIterClass
148 {
149   GObjectClass parent_class;
150
151   gboolean      (*get_next) (GMenuAttributeIter  *iter,
152                              const gchar        **out_type,
153                              GVariant           **value);
154 };
155
156 GLIB_AVAILABLE_IN_2_32
157 GType                   g_menu_attribute_iter_get_type                  (void) G_GNUC_CONST;
158
159 GLIB_AVAILABLE_IN_2_32
160 gboolean                g_menu_attribute_iter_get_next                  (GMenuAttributeIter  *iter,
161                                                                          const gchar        **out_name,
162                                                                          GVariant           **value);
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);
169
170
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))
182
183 struct _GMenuLinkIter
184 {
185   GObject parent_instance;
186   GMenuLinkIterPrivate *priv;
187 };
188
189 struct _GMenuLinkIterClass
190 {
191   GObjectClass parent_class;
192
193   gboolean      (*get_next) (GMenuLinkIter  *iter,
194                              const gchar   **out_name,
195                              GMenuModel    **value);
196 };
197
198 GLIB_AVAILABLE_IN_2_32
199 GType                   g_menu_link_iter_get_type                       (void) G_GNUC_CONST;
200
201 GLIB_AVAILABLE_IN_2_32
202 gboolean                g_menu_link_iter_get_next                       (GMenuLinkIter  *iter,
203                                                                          const gchar   **out_link,
204                                                                          GMenuModel    **value);
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);
211
212 G_END_DECLS
213
214 #endif /* __G_MENU_MODEL_H__ */