Revert "GIOScheduler: Avoid constant iteration over pending job list"
[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 GType                   g_menu_model_get_type                           (void) G_GNUC_CONST;
93
94 gboolean                g_menu_model_is_mutable                         (GMenuModel         *model);
95 gint                    g_menu_model_get_n_items                        (GMenuModel         *model);
96
97 GMenuAttributeIter *    g_menu_model_iterate_item_attributes            (GMenuModel         *model,
98                                                                          gint                item_index);
99 GVariant *              g_menu_model_get_item_attribute_value           (GMenuModel         *model,
100                                                                          gint                item_index,
101                                                                          const gchar        *attribute,
102                                                                          const GVariantType *expected_type);
103 gboolean                g_menu_model_get_item_attribute                 (GMenuModel         *model,
104                                                                          gint                item_index,
105                                                                          const gchar        *attribute,
106                                                                          const gchar        *format_string,
107                                                                          ...);
108 GMenuLinkIter *         g_menu_model_iterate_item_links                 (GMenuModel         *model,
109                                                                          gint                item_index);
110 GMenuModel *            g_menu_model_get_item_link                      (GMenuModel         *model,
111                                                                          gint                item_index,
112                                                                          const gchar        *link);
113
114 void                    g_menu_model_items_changed                      (GMenuModel         *model,
115                                                                          gint                position,
116                                                                          gint                removed,
117                                                                          gint                added);
118
119
120 #define G_TYPE_MENU_ATTRIBUTE_ITER                          (g_menu_attribute_iter_get_type ())
121 #define G_MENU_ATTRIBUTE_ITER(inst)                         (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
122                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter))
123 #define G_MENU_ATTRIBUTE_ITER_CLASS(class)                  (G_TYPE_CHECK_CLASS_CAST ((class),                       \
124                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
125 #define G_IS_MENU_ATTRIBUTE_ITER(inst)                      (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
126                                                              G_TYPE_MENU_ATTRIBUTE_ITER))
127 #define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class)               (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
128                                                              G_TYPE_MENU_ATTRIBUTE_ITER))
129 #define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst)               (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
130                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
131
132 struct _GMenuAttributeIter
133 {
134   GObject parent_instance;
135   GMenuAttributeIterPrivate *priv;
136 };
137
138 struct _GMenuAttributeIterClass
139 {
140   GObjectClass parent_class;
141
142   gboolean      (*get_next) (GMenuAttributeIter  *iter,
143                              const gchar        **out_type,
144                              GVariant           **value);
145 };
146
147 GType                   g_menu_attribute_iter_get_type                  (void) G_GNUC_CONST;
148
149 gboolean                g_menu_attribute_iter_get_next                  (GMenuAttributeIter  *iter,
150                                                                          const gchar        **out_name,
151                                                                          GVariant           **value);
152 gboolean                g_menu_attribute_iter_next                      (GMenuAttributeIter  *iter);
153 const gchar *           g_menu_attribute_iter_get_name                  (GMenuAttributeIter  *iter);
154 GVariant *              g_menu_attribute_iter_get_value                 (GMenuAttributeIter  *iter);
155
156
157 #define G_TYPE_MENU_LINK_ITER                               (g_menu_link_iter_get_type ())
158 #define G_MENU_LINK_ITER(inst)                              (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
159                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIter))
160 #define G_MENU_LINK_ITER_CLASS(class)                       (G_TYPE_CHECK_CLASS_CAST ((class),                       \
161                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
162 #define G_IS_MENU_LINK_ITER(inst)                           (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
163                                                              G_TYPE_MENU_LINK_ITER))
164 #define G_IS_MENU_LINK_ITER_CLASS(class)                    (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
165                                                              G_TYPE_MENU_LINK_ITER))
166 #define G_MENU_LINK_ITER_GET_CLASS(inst)                    (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
167                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
168
169 struct _GMenuLinkIter
170 {
171   GObject parent_instance;
172   GMenuLinkIterPrivate *priv;
173 };
174
175 struct _GMenuLinkIterClass
176 {
177   GObjectClass parent_class;
178
179   gboolean      (*get_next) (GMenuLinkIter  *iter,
180                              const gchar   **out_name,
181                              GMenuModel    **value);
182 };
183
184 GType                   g_menu_link_iter_get_type                       (void) G_GNUC_CONST;
185
186 gboolean                g_menu_link_iter_get_next                       (GMenuLinkIter  *iter,
187                                                                          const gchar   **out_link,
188                                                                          GMenuModel    **value);
189 gboolean                g_menu_link_iter_next                           (GMenuLinkIter  *iter);
190 const gchar *           g_menu_link_iter_get_name                       (GMenuLinkIter  *iter);
191 GMenuModel *            g_menu_link_iter_get_value                      (GMenuLinkIter  *iter);
192
193 G_END_DECLS
194
195 #endif /* __G_MENU_MODEL_H__ */