Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:58

0001 /*
0002  * Copyright © 2011 Canonical Ltd.
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful, but
0012  * WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
0018  *
0019  * Author: Ryan Lortie <desrt@desrt.ca>
0020  */
0021 
0022 #ifndef __G_MENU_MODEL_H__
0023 #define __G_MENU_MODEL_H__
0024 
0025 #include <glib-object.h>
0026 
0027 #include <gio/giotypes.h>
0028 
0029 G_BEGIN_DECLS
0030 
0031 /**
0032  * G_MENU_ATTRIBUTE_ACTION:
0033  *
0034  * The menu item attribute which holds the action name of the item.  Action
0035  * names are namespaced with an identifier for the action group in which the
0036  * action resides. For example, "win." for window-specific actions and "app."
0037  * for application-wide actions.
0038  *
0039  * See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute().
0040  *
0041  * Since: 2.32
0042  **/
0043 #define G_MENU_ATTRIBUTE_ACTION "action"
0044 
0045 /**
0046  * G_MENU_ATTRIBUTE_ACTION_NAMESPACE:
0047  *
0048  * The menu item attribute that holds the namespace for all action names in
0049  * menus that are linked from this item.
0050  *
0051  * Since: 2.36
0052  **/
0053 #define G_MENU_ATTRIBUTE_ACTION_NAMESPACE "action-namespace"
0054 
0055 /**
0056  * G_MENU_ATTRIBUTE_TARGET:
0057  *
0058  * The menu item attribute which holds the target with which the item's action
0059  * will be activated.
0060  *
0061  * See also g_menu_item_set_action_and_target()
0062  *
0063  * Since: 2.32
0064  **/
0065 #define G_MENU_ATTRIBUTE_TARGET "target"
0066 
0067 /**
0068  * G_MENU_ATTRIBUTE_LABEL:
0069  *
0070  * The menu item attribute which holds the label of the item.
0071  *
0072  * Since: 2.32
0073  **/
0074 #define G_MENU_ATTRIBUTE_LABEL "label"
0075 
0076 /**
0077  * G_MENU_ATTRIBUTE_ICON:
0078  *
0079  * The menu item attribute which holds the icon of the item.
0080  *
0081  * The icon is stored in the format returned by g_icon_serialize().
0082  *
0083  * This attribute is intended only to represent 'noun' icons such as
0084  * favicons for a webpage, or application icons.  It should not be used
0085  * for 'verbs' (ie: stock icons).
0086  *
0087  * Since: 2.38
0088  **/
0089 #define G_MENU_ATTRIBUTE_ICON "icon"
0090 
0091 /**
0092  * G_MENU_LINK_SUBMENU:
0093  *
0094  * The name of the link that associates a menu item with a submenu.
0095  *
0096  * See also g_menu_item_set_link().
0097  *
0098  * Since: 2.32
0099  **/
0100 #define G_MENU_LINK_SUBMENU "submenu"
0101 
0102 /**
0103  * G_MENU_LINK_SECTION:
0104  *
0105  * The name of the link that associates a menu item with a section.  The linked
0106  * menu will usually be shown in place of the menu item, using the item's label
0107  * as a header.
0108  *
0109  * See also g_menu_item_set_link().
0110  *
0111  * Since: 2.32
0112  **/
0113 #define G_MENU_LINK_SECTION "section"
0114 
0115 #define G_TYPE_MENU_MODEL                                   (g_menu_model_get_type ())
0116 #define G_MENU_MODEL(inst)                                  (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
0117                                                              G_TYPE_MENU_MODEL, GMenuModel))
0118 #define G_MENU_MODEL_CLASS(class)                           (G_TYPE_CHECK_CLASS_CAST ((class),                       \
0119                                                              G_TYPE_MENU_MODEL, GMenuModelClass))
0120 #define G_IS_MENU_MODEL(inst)                               (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
0121                                                              G_TYPE_MENU_MODEL))
0122 #define G_IS_MENU_MODEL_CLASS(class)                        (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
0123                                                              G_TYPE_MENU_MODEL))
0124 #define G_MENU_MODEL_GET_CLASS(inst)                        (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
0125                                                              G_TYPE_MENU_MODEL, GMenuModelClass))
0126 
0127 typedef struct _GMenuModelPrivate                           GMenuModelPrivate;
0128 typedef struct _GMenuModelClass                             GMenuModelClass;
0129 
0130 typedef struct _GMenuAttributeIterPrivate                   GMenuAttributeIterPrivate;
0131 typedef struct _GMenuAttributeIterClass                     GMenuAttributeIterClass;
0132 typedef struct _GMenuAttributeIter                          GMenuAttributeIter;
0133 
0134 typedef struct _GMenuLinkIterPrivate                        GMenuLinkIterPrivate;
0135 typedef struct _GMenuLinkIterClass                          GMenuLinkIterClass;
0136 typedef struct _GMenuLinkIter                               GMenuLinkIter;
0137 
0138 struct _GMenuModel
0139 {
0140   GObject            parent_instance;
0141   GMenuModelPrivate *priv;
0142 };
0143 
0144 /**
0145  * GMenuModelClass::get_item_attributes:
0146  * @model: the #GMenuModel to query
0147  * @item_index: The #GMenuItem to query
0148  * @attributes: (out) (element-type utf8 GLib.Variant): Attributes on the item
0149  *
0150  * Gets all the attributes associated with the item in the menu model.
0151  */
0152 /**
0153  * GMenuModelClass::get_item_links:
0154  * @model: the #GMenuModel to query
0155  * @item_index: The #GMenuItem to query
0156  * @links: (out) (element-type utf8 Gio.MenuModel): Links from the item
0157  *
0158  * Gets all the links associated with the item in the menu model.
0159  */
0160 struct _GMenuModelClass
0161 {
0162   GObjectClass parent_class;
0163 
0164   gboolean              (*is_mutable)                       (GMenuModel          *model);
0165   gint                  (*get_n_items)                      (GMenuModel          *model);
0166   void                  (*get_item_attributes)              (GMenuModel          *model,
0167                                                              gint                 item_index,
0168                                                              GHashTable         **attributes);
0169   GMenuAttributeIter *  (*iterate_item_attributes)          (GMenuModel          *model,
0170                                                              gint                 item_index);
0171   GVariant *            (*get_item_attribute_value)         (GMenuModel          *model,
0172                                                              gint                 item_index,
0173                                                              const gchar         *attribute,
0174                                                              const GVariantType  *expected_type);
0175   void                  (*get_item_links)                   (GMenuModel          *model,
0176                                                              gint                 item_index,
0177                                                              GHashTable         **links);
0178   GMenuLinkIter *       (*iterate_item_links)               (GMenuModel          *model,
0179                                                              gint                 item_index);
0180   GMenuModel *          (*get_item_link)                    (GMenuModel          *model,
0181                                                              gint                 item_index,
0182                                                              const gchar         *link);
0183 };
0184 
0185 GIO_AVAILABLE_IN_2_32
0186 GType                   g_menu_model_get_type                           (void) G_GNUC_CONST;
0187 
0188 GIO_AVAILABLE_IN_2_32
0189 gboolean                g_menu_model_is_mutable                         (GMenuModel         *model);
0190 GIO_AVAILABLE_IN_2_32
0191 gint                    g_menu_model_get_n_items                        (GMenuModel         *model);
0192 
0193 GIO_AVAILABLE_IN_2_32
0194 GMenuAttributeIter *    g_menu_model_iterate_item_attributes            (GMenuModel         *model,
0195                                                                          gint                item_index);
0196 GIO_AVAILABLE_IN_2_32
0197 GVariant *              g_menu_model_get_item_attribute_value           (GMenuModel         *model,
0198                                                                          gint                item_index,
0199                                                                          const gchar        *attribute,
0200                                                                          const GVariantType *expected_type);
0201 GIO_AVAILABLE_IN_2_32
0202 gboolean                g_menu_model_get_item_attribute                 (GMenuModel         *model,
0203                                                                          gint                item_index,
0204                                                                          const gchar        *attribute,
0205                                                                          const gchar        *format_string,
0206                                                                          ...);
0207 GIO_AVAILABLE_IN_2_32
0208 GMenuLinkIter *         g_menu_model_iterate_item_links                 (GMenuModel         *model,
0209                                                                          gint                item_index);
0210 GIO_AVAILABLE_IN_2_32
0211 GMenuModel *            g_menu_model_get_item_link                      (GMenuModel         *model,
0212                                                                          gint                item_index,
0213                                                                          const gchar        *link);
0214 
0215 GIO_AVAILABLE_IN_2_32
0216 void                    g_menu_model_items_changed                      (GMenuModel         *model,
0217                                                                          gint                position,
0218                                                                          gint                removed,
0219                                                                          gint                added);
0220 
0221 
0222 #define G_TYPE_MENU_ATTRIBUTE_ITER                          (g_menu_attribute_iter_get_type ())
0223 #define G_MENU_ATTRIBUTE_ITER(inst)                         (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
0224                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter))
0225 #define G_MENU_ATTRIBUTE_ITER_CLASS(class)                  (G_TYPE_CHECK_CLASS_CAST ((class),                       \
0226                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
0227 #define G_IS_MENU_ATTRIBUTE_ITER(inst)                      (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
0228                                                              G_TYPE_MENU_ATTRIBUTE_ITER))
0229 #define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class)               (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
0230                                                              G_TYPE_MENU_ATTRIBUTE_ITER))
0231 #define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst)               (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
0232                                                              G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass))
0233 
0234 struct _GMenuAttributeIter
0235 {
0236   GObject parent_instance;
0237   GMenuAttributeIterPrivate *priv;
0238 };
0239 
0240 struct _GMenuAttributeIterClass
0241 {
0242   GObjectClass parent_class;
0243 
0244   gboolean      (*get_next) (GMenuAttributeIter  *iter,
0245                              const gchar        **out_name,
0246                              GVariant           **value);
0247 };
0248 
0249 GIO_AVAILABLE_IN_2_32
0250 GType                   g_menu_attribute_iter_get_type                  (void) G_GNUC_CONST;
0251 
0252 GIO_AVAILABLE_IN_2_32
0253 gboolean                g_menu_attribute_iter_get_next                  (GMenuAttributeIter  *iter,
0254                                                                          const gchar        **out_name,
0255                                                                          GVariant           **value);
0256 GIO_AVAILABLE_IN_2_32
0257 gboolean                g_menu_attribute_iter_next                      (GMenuAttributeIter  *iter);
0258 GIO_AVAILABLE_IN_2_32
0259 const gchar *           g_menu_attribute_iter_get_name                  (GMenuAttributeIter  *iter);
0260 GIO_AVAILABLE_IN_2_32
0261 GVariant *              g_menu_attribute_iter_get_value                 (GMenuAttributeIter  *iter);
0262 
0263 
0264 #define G_TYPE_MENU_LINK_ITER                               (g_menu_link_iter_get_type ())
0265 #define G_MENU_LINK_ITER(inst)                              (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
0266                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIter))
0267 #define G_MENU_LINK_ITER_CLASS(class)                       (G_TYPE_CHECK_CLASS_CAST ((class),                       \
0268                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
0269 #define G_IS_MENU_LINK_ITER(inst)                           (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
0270                                                              G_TYPE_MENU_LINK_ITER))
0271 #define G_IS_MENU_LINK_ITER_CLASS(class)                    (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
0272                                                              G_TYPE_MENU_LINK_ITER))
0273 #define G_MENU_LINK_ITER_GET_CLASS(inst)                    (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
0274                                                              G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass))
0275 
0276 struct _GMenuLinkIter
0277 {
0278   GObject parent_instance;
0279   GMenuLinkIterPrivate *priv;
0280 };
0281 
0282 struct _GMenuLinkIterClass
0283 {
0284   GObjectClass parent_class;
0285 
0286   gboolean      (*get_next) (GMenuLinkIter  *iter,
0287                              const gchar   **out_link,
0288                              GMenuModel    **value);
0289 };
0290 
0291 GIO_AVAILABLE_IN_2_32
0292 GType                   g_menu_link_iter_get_type                       (void) G_GNUC_CONST;
0293 
0294 GIO_AVAILABLE_IN_2_32
0295 gboolean                g_menu_link_iter_get_next                       (GMenuLinkIter  *iter,
0296                                                                          const gchar   **out_link,
0297                                                                          GMenuModel    **value);
0298 GIO_AVAILABLE_IN_2_32
0299 gboolean                g_menu_link_iter_next                           (GMenuLinkIter  *iter);
0300 GIO_AVAILABLE_IN_2_32
0301 const gchar *           g_menu_link_iter_get_name                       (GMenuLinkIter  *iter);
0302 GIO_AVAILABLE_IN_2_32
0303 GMenuModel *            g_menu_link_iter_get_value                      (GMenuLinkIter  *iter);
0304 
0305 G_END_DECLS
0306 
0307 #endif /* __G_MENU_MODEL_H__ */