{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) 'GI.Gio.Objects.MenuModel.MenuModel' represents the contents of a menu -- an ordered list of menu items. The items are associated with actions, which can be activated through them. Items can be grouped in sections, and may have submenus associated with them. Both items and sections usually have some representation data, such as labels or icons. The type of the associated action (ie whether it is stateful, and what kind of state it has) can influence the representation of the item. The conceptual model of menus in 'GI.Gio.Objects.MenuModel.MenuModel' is hierarchical: sections and submenus are again represented by @/GMenuModels/@. Menus themselves do not define their own roles. Rather, the role of a particular 'GI.Gio.Objects.MenuModel.MenuModel' is defined by the item that references it (or, in the case of the \'root\' menu, is defined by the context in which it is used). As an example, consider the visible portions of this menu: ## An example menu # {@/menu/@-example} <> There are 8 \"menus\" visible in the screenshot: one menubar, two submenus and 5 sections: * the toplevel menubar (containing 4 items) * the View submenu (containing 3 sections) * the first section of the View submenu (containing 2 items) * the second section of the View submenu (containing 1 item) * the final section of the View submenu (containing 1 item) * the Highlight Mode submenu (containing 2 sections) * the Sources section (containing 2 items) * the Markup section (containing 2 items) The [example][menu-model] illustrates the conceptual connection between these 8 menus. Each large block in the figure represents a menu and the smaller blocks within the large block represent items in that menu. Some items contain references to other menus. ## A menu example # {@/menu/@-model} <> Notice that the separators visible in the [example][menu-example] appear nowhere in the [menu model][menu-model]. This is because separators are not explicitly represented in the menu model. Instead, a separator is inserted between any two non-empty sections of a menu. Section items can have labels just like any other item. In that case, a display system may show a section header instead of a separator. The motivation for this abstract model of application controls is that modern user interfaces tend to make these controls available outside the application. Examples include global menus, jumplists, dash boards, etc. To support such uses, it is necessary to \'export\' information about actions and their representation in menus, which is exactly what the [GActionGroup exporter][gio-GActionGroup-exporter] and the [GMenuModel exporter][gio-GMenuModel-exporter] do for 'GI.Gio.Interfaces.ActionGroup.ActionGroup' and 'GI.Gio.Objects.MenuModel.MenuModel'. The client-side counterparts to make use of the exported information are 'GI.Gio.Objects.DBusActionGroup.DBusActionGroup' and 'GI.Gio.Objects.DBusMenuModel.DBusMenuModel'. The API of 'GI.Gio.Objects.MenuModel.MenuModel' is very generic, with iterators for the attributes and links of an item, see 'GI.Gio.Objects.MenuModel.menuModelIterateItemAttributes' and 'GI.Gio.Objects.MenuModel.menuModelIterateItemLinks'. The \'standard\' attributes and link types have predefined names: 'GI.Gio.Constants.MENU_ATTRIBUTE_LABEL', 'GI.Gio.Constants.MENU_ATTRIBUTE_ACTION', 'GI.Gio.Constants.MENU_ATTRIBUTE_TARGET', 'GI.Gio.Constants.MENU_LINK_SECTION' and 'GI.Gio.Constants.MENU_LINK_SUBMENU'. Items in a 'GI.Gio.Objects.MenuModel.MenuModel' represent active controls if they refer to an action that can get activated when the user interacts with the menu item. The reference to the action is encoded by the string id in the 'GI.Gio.Constants.MENU_ATTRIBUTE_ACTION' attribute. An action id uniquely identifies an action in an action group. Which action group(s) provide actions depends on the context in which the menu model is used. E.g. when the model is exported as the application menu of a @/GtkApplication/@, actions can be application-wide or window-specific (and thus come from two different action groups). By convention, the application-wide actions have names that start with \"app.\", while the names of window-specific actions start with \"win.\". While a wide variety of stateful actions is possible, the following is the minimum that is expected to be supported by all users of exported menu information: * an action with no parameter type and no state * an action with no parameter type and boolean state * an action with string parameter type and string state == Stateless A stateless action typically corresponds to an ordinary menu item. Selecting such a menu item will activate the action (with no parameter). == Boolean State An action with a boolean state will most typically be used with a \"toggle\" or \"switch\" menu item. The state can be set directly, but activating the action (with no parameter) results in the state being toggled. Selecting a toggle menu item will activate the action. The menu item should be rendered as \"checked\" when the state is true. == String Parameter and State Actions with string parameters and state will most typically be used to represent an enumerated choice over the items available for a group of radio menu items. Activating the action with a string parameter is equivalent to setting that parameter as the state. Radio menu items, in addition to being associated with the action, will have a target value. Selecting that menu item will result in activation of the action with the target value as the parameter. The menu item should be rendered as \"selected\" when the state of the action is equal to the target value of the menu item. /Since: 2.32/ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Gio.Objects.MenuModel ( -- * Exported types MenuModel(..) , IsMenuModel , toMenuModel , noMenuModel , -- * Methods -- ** getItemAttributeValue #method:getItemAttributeValue# #if ENABLE_OVERLOADING MenuModelGetItemAttributeValueMethodInfo, #endif menuModelGetItemAttributeValue , -- ** getItemLink #method:getItemLink# #if ENABLE_OVERLOADING MenuModelGetItemLinkMethodInfo , #endif menuModelGetItemLink , -- ** getNItems #method:getNItems# #if ENABLE_OVERLOADING MenuModelGetNItemsMethodInfo , #endif menuModelGetNItems , -- ** isMutable #method:isMutable# #if ENABLE_OVERLOADING MenuModelIsMutableMethodInfo , #endif menuModelIsMutable , -- ** itemsChanged #method:itemsChanged# #if ENABLE_OVERLOADING MenuModelItemsChangedMethodInfo , #endif menuModelItemsChanged , -- ** iterateItemAttributes #method:iterateItemAttributes# #if ENABLE_OVERLOADING MenuModelIterateItemAttributesMethodInfo, #endif menuModelIterateItemAttributes , -- ** iterateItemLinks #method:iterateItemLinks# #if ENABLE_OVERLOADING MenuModelIterateItemLinksMethodInfo , #endif menuModelIterateItemLinks , -- * Signals -- ** itemsChanged #signal:itemsChanged# C_MenuModelItemsChangedCallback , MenuModelItemsChangedCallback , #if ENABLE_OVERLOADING MenuModelItemsChangedSignalInfo , #endif afterMenuModelItemsChanged , genClosure_MenuModelItemsChanged , mk_MenuModelItemsChangedCallback , noMenuModelItemsChangedCallback , onMenuModelItemsChanged , wrap_MenuModelItemsChangedCallback , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.GLib.Structs.VariantType as GLib.VariantType import qualified GI.GObject.Objects.Object as GObject.Object import {-# SOURCE #-} qualified GI.Gio.Objects.MenuAttributeIter as Gio.MenuAttributeIter import {-# SOURCE #-} qualified GI.Gio.Objects.MenuLinkIter as Gio.MenuLinkIter -- | Memory-managed wrapper type. newtype MenuModel = MenuModel (ManagedPtr MenuModel) foreign import ccall "g_menu_model_get_type" c_g_menu_model_get_type :: IO GType instance GObject MenuModel where gobjectType = c_g_menu_model_get_type -- | Type class for types which can be safely cast to `MenuModel`, for instance with `toMenuModel`. class (GObject o, O.IsDescendantOf MenuModel o) => IsMenuModel o instance (GObject o, O.IsDescendantOf MenuModel o) => IsMenuModel o instance O.HasParentTypes MenuModel type instance O.ParentTypes MenuModel = '[GObject.Object.Object] -- | Cast to `MenuModel`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toMenuModel :: (MonadIO m, IsMenuModel o) => o -> m MenuModel toMenuModel = liftIO . unsafeCastTo MenuModel -- | A convenience alias for `Nothing` :: `Maybe` `MenuModel`. noMenuModel :: Maybe MenuModel noMenuModel = Nothing #if ENABLE_OVERLOADING type family ResolveMenuModelMethod (t :: Symbol) (o :: *) :: * where ResolveMenuModelMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveMenuModelMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveMenuModelMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveMenuModelMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveMenuModelMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveMenuModelMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveMenuModelMethod "isMutable" o = MenuModelIsMutableMethodInfo ResolveMenuModelMethod "itemsChanged" o = MenuModelItemsChangedMethodInfo ResolveMenuModelMethod "iterateItemAttributes" o = MenuModelIterateItemAttributesMethodInfo ResolveMenuModelMethod "iterateItemLinks" o = MenuModelIterateItemLinksMethodInfo ResolveMenuModelMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveMenuModelMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveMenuModelMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveMenuModelMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveMenuModelMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveMenuModelMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveMenuModelMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveMenuModelMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveMenuModelMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveMenuModelMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveMenuModelMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveMenuModelMethod "getItemAttributeValue" o = MenuModelGetItemAttributeValueMethodInfo ResolveMenuModelMethod "getItemLink" o = MenuModelGetItemLinkMethodInfo ResolveMenuModelMethod "getNItems" o = MenuModelGetNItemsMethodInfo ResolveMenuModelMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveMenuModelMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveMenuModelMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveMenuModelMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveMenuModelMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveMenuModelMethod t MenuModel, O.MethodInfo info MenuModel p) => OL.IsLabel t (MenuModel -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif -- signal MenuModel::items-changed {- | Emitted when a change has occured to the menu. The only changes that can occur to a menu is that items are removed or added. Items may not change (except by being removed and added back in the same location). This signal is capable of describing both of those changes (at the same time). The signal means that starting at the index /@position@/, /@removed@/ items were removed and /@added@/ items were added in their place. If /@removed@/ is zero then only items were added. If /@added@/ is zero then only items were removed. As an example, if the menu contains items a, b, c, d (in that order) and the signal (2, 1, 3) occurs then the new composition of the menu will be a, b, _, _, _, d (with each _ representing some new item). Signal handlers may query the model (particularly the added items) and expect to see the results of the modification that is being reported. The signal is emitted after the modification. -} type MenuModelItemsChangedCallback = Int32 {- ^ /@position@/: the position of the change -} -> Int32 {- ^ /@removed@/: the number of items removed -} -> Int32 {- ^ /@added@/: the number of items added -} -> IO () -- | A convenience synonym for @`Nothing` :: `Maybe` `MenuModelItemsChangedCallback`@. noMenuModelItemsChangedCallback :: Maybe MenuModelItemsChangedCallback noMenuModelItemsChangedCallback = Nothing -- | Type for the callback on the (unwrapped) C side. type C_MenuModelItemsChangedCallback = Ptr () -> -- object Int32 -> Int32 -> Int32 -> Ptr () -> -- user_data IO () -- | Generate a function pointer callable from C code, from a `C_MenuModelItemsChangedCallback`. foreign import ccall "wrapper" mk_MenuModelItemsChangedCallback :: C_MenuModelItemsChangedCallback -> IO (FunPtr C_MenuModelItemsChangedCallback) -- | Wrap the callback into a `GClosure`. genClosure_MenuModelItemsChanged :: MonadIO m => MenuModelItemsChangedCallback -> m (GClosure C_MenuModelItemsChangedCallback) genClosure_MenuModelItemsChanged cb = liftIO $ do let cb' = wrap_MenuModelItemsChangedCallback cb mk_MenuModelItemsChangedCallback cb' >>= B.GClosure.newGClosure -- | Wrap a `MenuModelItemsChangedCallback` into a `C_MenuModelItemsChangedCallback`. wrap_MenuModelItemsChangedCallback :: MenuModelItemsChangedCallback -> C_MenuModelItemsChangedCallback wrap_MenuModelItemsChangedCallback _cb _ position removed added _ = do _cb position removed added {- | Connect a signal handler for the “@items-changed@” signal, to be run before the default handler. When is enabled, this is equivalent to @ 'Data.GI.Base.Signals.on' menuModel #itemsChanged callback @ -} onMenuModelItemsChanged :: (IsMenuModel a, MonadIO m) => a -> MenuModelItemsChangedCallback -> m SignalHandlerId onMenuModelItemsChanged obj cb = liftIO $ do let cb' = wrap_MenuModelItemsChangedCallback cb cb'' <- mk_MenuModelItemsChangedCallback cb' connectSignalFunPtr obj "items-changed" cb'' SignalConnectBefore {- | Connect a signal handler for the “@items-changed@” signal, to be run after the default handler. When is enabled, this is equivalent to @ 'Data.GI.Base.Signals.after' menuModel #itemsChanged callback @ -} afterMenuModelItemsChanged :: (IsMenuModel a, MonadIO m) => a -> MenuModelItemsChangedCallback -> m SignalHandlerId afterMenuModelItemsChanged obj cb = liftIO $ do let cb' = wrap_MenuModelItemsChangedCallback cb cb'' <- mk_MenuModelItemsChangedCallback cb' connectSignalFunPtr obj "items-changed" cb'' SignalConnectAfter #if ENABLE_OVERLOADING instance O.HasAttributeList MenuModel type instance O.AttributeList MenuModel = MenuModelAttributeList type MenuModelAttributeList = ('[ ] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING #endif #if ENABLE_OVERLOADING data MenuModelItemsChangedSignalInfo instance SignalInfo MenuModelItemsChangedSignalInfo where type HaskellCallbackType MenuModelItemsChangedSignalInfo = MenuModelItemsChangedCallback connectSignal _ obj cb connectMode = do let cb' = wrap_MenuModelItemsChangedCallback cb cb'' <- mk_MenuModelItemsChangedCallback cb' connectSignalFunPtr obj "items-changed" cb'' connectMode type instance O.SignalList MenuModel = MenuModelSignalList type MenuModelSignalList = ('[ '("itemsChanged", MenuModelItemsChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method MenuModel::get_item_attribute_value -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the attribute to query", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expected_type", argType = TInterface (Name {namespace = "GLib", name = "VariantType"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the expected type of the attribute, or\n %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just TVariant -- throws : False -- Skip return : False foreign import ccall "g_menu_model_get_item_attribute_value" g_menu_model_get_item_attribute_value :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) Int32 -> -- item_index : TBasicType TInt CString -> -- attribute : TBasicType TUTF8 Ptr GLib.VariantType.VariantType -> -- expected_type : TInterface (Name {namespace = "GLib", name = "VariantType"}) IO (Ptr GVariant) {- | Queries the item at position /@itemIndex@/ in /@model@/ for the attribute specified by /@attribute@/. If /@expectedType@/ is non-'Nothing' then it specifies the expected type of the attribute. If it is 'Nothing' then any type will be accepted. If the attribute exists and matches /@expectedType@/ (or if the expected type is unspecified) then the value is returned. If the attribute does not exist, or does not match the expected type then 'Nothing' is returned. /Since: 2.32/ -} menuModelGetItemAttributeValue :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> Int32 {- ^ /@itemIndex@/: the index of the item -} -> T.Text {- ^ /@attribute@/: the attribute to query -} -> Maybe (GLib.VariantType.VariantType) {- ^ /@expectedType@/: the expected type of the attribute, or 'Nothing' -} -> m GVariant {- ^ __Returns:__ the value of the attribute -} menuModelGetItemAttributeValue model itemIndex attribute expectedType = liftIO $ do model' <- unsafeManagedPtrCastPtr model attribute' <- textToCString attribute maybeExpectedType <- case expectedType of Nothing -> return nullPtr Just jExpectedType -> do jExpectedType' <- unsafeManagedPtrGetPtr jExpectedType return jExpectedType' result <- g_menu_model_get_item_attribute_value model' itemIndex attribute' maybeExpectedType checkUnexpectedReturnNULL "menuModelGetItemAttributeValue" result result' <- B.GVariant.wrapGVariantPtr result touchManagedPtr model whenJust expectedType touchManagedPtr freeMem attribute' return result' #if ENABLE_OVERLOADING data MenuModelGetItemAttributeValueMethodInfo instance (signature ~ (Int32 -> T.Text -> Maybe (GLib.VariantType.VariantType) -> m GVariant), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelGetItemAttributeValueMethodInfo a signature where overloadedMethod _ = menuModelGetItemAttributeValue #endif -- method MenuModel::get_item_link -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "link", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the link to query", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Gio", name = "MenuModel"})) -- throws : False -- Skip return : False foreign import ccall "g_menu_model_get_item_link" g_menu_model_get_item_link :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) Int32 -> -- item_index : TBasicType TInt CString -> -- link : TBasicType TUTF8 IO (Ptr MenuModel) {- | Queries the item at position /@itemIndex@/ in /@model@/ for the link specified by /@link@/. If the link exists, the linked 'GI.Gio.Objects.MenuModel.MenuModel' is returned. If the link does not exist, 'Nothing' is returned. /Since: 2.32/ -} menuModelGetItemLink :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> Int32 {- ^ /@itemIndex@/: the index of the item -} -> T.Text {- ^ /@link@/: the link to query -} -> m MenuModel {- ^ __Returns:__ the linked 'GI.Gio.Objects.MenuModel.MenuModel', or 'Nothing' -} menuModelGetItemLink model itemIndex link = liftIO $ do model' <- unsafeManagedPtrCastPtr model link' <- textToCString link result <- g_menu_model_get_item_link model' itemIndex link' checkUnexpectedReturnNULL "menuModelGetItemLink" result result' <- (wrapObject MenuModel) result touchManagedPtr model freeMem link' return result' #if ENABLE_OVERLOADING data MenuModelGetItemLinkMethodInfo instance (signature ~ (Int32 -> T.Text -> m MenuModel), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelGetItemLinkMethodInfo a signature where overloadedMethod _ = menuModelGetItemLink #endif -- method MenuModel::get_n_items -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_menu_model_get_n_items" g_menu_model_get_n_items :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) IO Int32 {- | Query the number of items in /@model@/. /Since: 2.32/ -} menuModelGetNItems :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> m Int32 {- ^ __Returns:__ the number of items -} menuModelGetNItems model = liftIO $ do model' <- unsafeManagedPtrCastPtr model result <- g_menu_model_get_n_items model' touchManagedPtr model return result #if ENABLE_OVERLOADING data MenuModelGetNItemsMethodInfo instance (signature ~ (m Int32), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelGetNItemsMethodInfo a signature where overloadedMethod _ = menuModelGetNItems #endif -- method MenuModel::is_mutable -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_menu_model_is_mutable" g_menu_model_is_mutable :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) IO CInt {- | Queries if /@model@/ is mutable. An immutable 'GI.Gio.Objects.MenuModel.MenuModel' will never emit the 'GI.Gio.Objects.MenuModel.MenuModel'::@/items-changed/@ signal. Consumers of the model may make optimisations accordingly. /Since: 2.32/ -} menuModelIsMutable :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> m Bool {- ^ __Returns:__ 'True' if the model is mutable (ie: \"items-changed\" may be emitted). -} menuModelIsMutable model = liftIO $ do model' <- unsafeManagedPtrCastPtr model result <- g_menu_model_is_mutable model' let result' = (/= 0) result touchManagedPtr model return result' #if ENABLE_OVERLOADING data MenuModelIsMutableMethodInfo instance (signature ~ (m Bool), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelIsMutableMethodInfo a signature where overloadedMethod _ = menuModelIsMutable #endif -- method MenuModel::items_changed -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position of the change", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "removed", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of items removed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "added", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of items added", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_menu_model_items_changed" g_menu_model_items_changed :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) Int32 -> -- position : TBasicType TInt Int32 -> -- removed : TBasicType TInt Int32 -> -- added : TBasicType TInt IO () {- | Requests emission of the 'GI.Gio.Objects.MenuModel.MenuModel'::@/items-changed/@ signal on /@model@/. This function should never be called except by 'GI.Gio.Objects.MenuModel.MenuModel' subclasses. Any other calls to this function will very likely lead to a violation of the interface of the model. The implementation should update its internal representation of the menu before emitting the signal. The implementation should further expect to receive queries about the new state of the menu (and particularly added menu items) while signal handlers are running. The implementation must dispatch this call directly from a mainloop entry and not in response to calls -- particularly those from the 'GI.Gio.Objects.MenuModel.MenuModel' API. Said another way: the menu must not change while user code is running without returning to the mainloop. /Since: 2.32/ -} menuModelItemsChanged :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> Int32 {- ^ /@position@/: the position of the change -} -> Int32 {- ^ /@removed@/: the number of items removed -} -> Int32 {- ^ /@added@/: the number of items added -} -> m () menuModelItemsChanged model position removed added = liftIO $ do model' <- unsafeManagedPtrCastPtr model g_menu_model_items_changed model' position removed added touchManagedPtr model return () #if ENABLE_OVERLOADING data MenuModelItemsChangedMethodInfo instance (signature ~ (Int32 -> Int32 -> Int32 -> m ()), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelItemsChangedMethodInfo a signature where overloadedMethod _ = menuModelItemsChanged #endif -- method MenuModel::iterate_item_attributes -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Gio", name = "MenuAttributeIter"})) -- throws : False -- Skip return : False foreign import ccall "g_menu_model_iterate_item_attributes" g_menu_model_iterate_item_attributes :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) Int32 -> -- item_index : TBasicType TInt IO (Ptr Gio.MenuAttributeIter.MenuAttributeIter) {- | Creates a 'GI.Gio.Objects.MenuAttributeIter.MenuAttributeIter' to iterate over the attributes of the item at position /@itemIndex@/ in /@model@/. You must free the iterator with 'GI.GObject.Objects.Object.objectUnref' when you are done. /Since: 2.32/ -} menuModelIterateItemAttributes :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> Int32 {- ^ /@itemIndex@/: the index of the item -} -> m Gio.MenuAttributeIter.MenuAttributeIter {- ^ __Returns:__ a new 'GI.Gio.Objects.MenuAttributeIter.MenuAttributeIter' -} menuModelIterateItemAttributes model itemIndex = liftIO $ do model' <- unsafeManagedPtrCastPtr model result <- g_menu_model_iterate_item_attributes model' itemIndex checkUnexpectedReturnNULL "menuModelIterateItemAttributes" result result' <- (wrapObject Gio.MenuAttributeIter.MenuAttributeIter) result touchManagedPtr model return result' #if ENABLE_OVERLOADING data MenuModelIterateItemAttributesMethodInfo instance (signature ~ (Int32 -> m Gio.MenuAttributeIter.MenuAttributeIter), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelIterateItemAttributesMethodInfo a signature where overloadedMethod _ = menuModelIterateItemAttributes #endif -- method MenuModel::iterate_item_links -- method type : OrdinaryMethod -- Args : [Arg {argCName = "model", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Gio", name = "MenuLinkIter"})) -- throws : False -- Skip return : False foreign import ccall "g_menu_model_iterate_item_links" g_menu_model_iterate_item_links :: Ptr MenuModel -> -- model : TInterface (Name {namespace = "Gio", name = "MenuModel"}) Int32 -> -- item_index : TBasicType TInt IO (Ptr Gio.MenuLinkIter.MenuLinkIter) {- | Creates a 'GI.Gio.Objects.MenuLinkIter.MenuLinkIter' to iterate over the links of the item at position /@itemIndex@/ in /@model@/. You must free the iterator with 'GI.GObject.Objects.Object.objectUnref' when you are done. /Since: 2.32/ -} menuModelIterateItemLinks :: (B.CallStack.HasCallStack, MonadIO m, IsMenuModel a) => a {- ^ /@model@/: a 'GI.Gio.Objects.MenuModel.MenuModel' -} -> Int32 {- ^ /@itemIndex@/: the index of the item -} -> m Gio.MenuLinkIter.MenuLinkIter {- ^ __Returns:__ a new 'GI.Gio.Objects.MenuLinkIter.MenuLinkIter' -} menuModelIterateItemLinks model itemIndex = liftIO $ do model' <- unsafeManagedPtrCastPtr model result <- g_menu_model_iterate_item_links model' itemIndex checkUnexpectedReturnNULL "menuModelIterateItemLinks" result result' <- (wrapObject Gio.MenuLinkIter.MenuLinkIter) result touchManagedPtr model return result' #if ENABLE_OVERLOADING data MenuModelIterateItemLinksMethodInfo instance (signature ~ (Int32 -> m Gio.MenuLinkIter.MenuLinkIter), MonadIO m, IsMenuModel a) => O.MethodInfo MenuModelIterateItemLinksMethodInfo a signature where overloadedMethod _ = menuModelIterateItemLinks #endif