{-# LINE 2 "./Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget RecentAction
--
-- Author : Andy Stewart
--
-- Created: 24 Mar 2010
--
-- Copyright (C) 2010 Andy Stewart
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- An action of which represents a list of recently used files
--
-- * Module available since Gtk+ version 2.12
--
module Graphics.UI.Gtk.ActionMenuToolbar.RecentAction (

-- * Detail
--
-- | A 'RecentAction' represents a list of recently used files, which can be
-- shown by widgets such as 'RecentChooserDialog' or 'RecentChooserMenu'.
--
-- To construct a submenu showing recently used files, use a 'RecentAction'
-- as the action for a \<menuitem>. To construct a menu toolbutton showing the
-- recently used files in the popup menu, use a 'RecentAction' as the action
-- for a \<toolitem> element.

-- * Class Hierarchy
--
-- |
-- @
-- | 'GObject'
-- | +----'Action'
-- | +----RecentAction
-- @


-- * Types
  RecentAction,
  RecentActionClass,
  castToRecentAction,
  toRecentAction,

-- * Constructors
  recentActionNew,
  recentActionNewForManager,

-- * Attributes
  recentActionShowNumbers,

  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import System.Glib.UTFString
import Graphics.UI.Gtk.Types
{-# LINE 74 "./Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs" #-}


{-# LINE 76 "./Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs" #-}


--------------------
-- Constructors

-- | Creates a new 'RecentAction' object. To add the action to a 'ActionGroup'
-- and set the accelerator for the action, call
-- 'actionGroupAddActionWithAccel'.
--
recentActionNew :: GlibString string
 => string -- ^ @name@ - a unique name for the action
 -> Maybe string -- ^ @label@ - the label displayed in menu items and on buttons, or 'Nothing'
 -> Maybe string -- ^ @tooltip@ - a tooltip for the action, or 'Nothing'
 -> Maybe string -- ^ @stockId@ - the stock icon to display in widgets representing
           -- the action, or 'Nothing'
 -> IO RecentAction
recentActionNew :: forall string.
GlibString string =>
string
-> Maybe string -> Maybe string -> Maybe string -> IO RecentAction
recentActionNew string
name Maybe string
label Maybe string
tooltip Maybe string
stockId =
  (ForeignPtr RecentAction -> RecentAction,
 FinalizerPtr RecentAction)
-> IO (Ptr RecentAction) -> IO RecentAction
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr RecentAction -> RecentAction,
 FinalizerPtr RecentAction)
forall {a}.
(ForeignPtr RecentAction -> RecentAction, FinalizerPtr a)
mkRecentAction (IO (Ptr RecentAction) -> IO RecentAction)
-> IO (Ptr RecentAction) -> IO RecentAction
forall a b. (a -> b) -> a -> b
$
  (Ptr Action -> Ptr RecentAction)
-> IO (Ptr Action) -> IO (Ptr RecentAction)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr Action -> Ptr RecentAction
forall a b. Ptr a -> Ptr b
castPtr (IO (Ptr Action) -> IO (Ptr RecentAction))
-> IO (Ptr Action) -> IO (Ptr RecentAction)
forall a b. (a -> b) -> a -> b
$
  string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
name ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
namePtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
label ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
labelPtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
tooltip ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
tooltipPtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
stockId ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
stockIdPtr ->
  CString -> CString -> CString -> CString -> IO (Ptr Action)
gtk_recent_action_new
{-# LINE 100 "./Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs" #-}
    namePtr
    CString
labelPtr
    CString
tooltipPtr
    CString
stockIdPtr

-- | Creates a new 'RecentAction' object. To add the action to a 'ActionGroup'
-- and set the accelerator for the action, call
-- 'actionGroupAddActionWithAccel'.
--
recentActionNewForManager :: (RecentManagerClass manager, GlibString string) =>
    string -- ^ @name@ - a unique name for the action
 -> Maybe string -- ^ @label@ - the label displayed in menu items and on buttons,
            -- or 'Nothing'
 -> Maybe string -- ^ @tooltip@ - a tooltip for the action, or 'Nothing'
 -> Maybe string -- ^ @stockId@ - the stock icon to display in widgets representing
            -- the action, or 'Nothing'
 -> Maybe manager -- ^ @manager@ - a 'RecentManager', or 'Nothing' for the
            -- default 'RecentManager'
 -> IO RecentAction
recentActionNewForManager :: forall manager string.
(RecentManagerClass manager, GlibString string) =>
string
-> Maybe string
-> Maybe string
-> Maybe string
-> Maybe manager
-> IO RecentAction
recentActionNewForManager string
name Maybe string
label Maybe string
tooltip Maybe string
stockId Maybe manager
manager =
  (ForeignPtr RecentAction -> RecentAction,
 FinalizerPtr RecentAction)
-> IO (Ptr RecentAction) -> IO RecentAction
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr RecentAction -> RecentAction,
 FinalizerPtr RecentAction)
forall {a}.
(ForeignPtr RecentAction -> RecentAction, FinalizerPtr a)
mkRecentAction (IO (Ptr RecentAction) -> IO RecentAction)
-> IO (Ptr RecentAction) -> IO RecentAction
forall a b. (a -> b) -> a -> b
$ (Ptr Action -> Ptr RecentAction)
-> IO (Ptr Action) -> IO (Ptr RecentAction)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr Action -> Ptr RecentAction
forall a b. Ptr a -> Ptr b
castPtr (IO (Ptr Action) -> IO (Ptr RecentAction))
-> IO (Ptr Action) -> IO (Ptr RecentAction)
forall a b. (a -> b) -> a -> b
$
  string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
name ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
namePtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
label ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
labelPtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
tooltip ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
tooltipPtr ->
  (string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> Maybe string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string -> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
stockId ((CString -> IO (Ptr Action)) -> IO (Ptr Action))
-> (CString -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \CString
stockIdPtr -> do
    (\CString
arg1 CString
arg2 CString
arg3 CString
arg4 (RecentManager ForeignPtr RecentManager
arg5) -> ForeignPtr RecentManager
-> (Ptr RecentManager -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr RecentManager
arg5 ((Ptr RecentManager -> IO (Ptr Action)) -> IO (Ptr Action))
-> (Ptr RecentManager -> IO (Ptr Action)) -> IO (Ptr Action)
forall a b. (a -> b) -> a -> b
$ \Ptr RecentManager
argPtr5 ->CString
-> CString
-> CString
-> CString
-> Ptr RecentManager
-> IO (Ptr Action)
gtk_recent_action_new_for_manager CString
arg1 CString
arg2 CString
arg3 CString
arg4 Ptr RecentManager
argPtr5)
{-# LINE 126 "./Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs" #-}
      namePtr
      CString
labelPtr
      CString
tooltipPtr
      CString
stockIdPtr
      (RecentManager
-> (manager -> RecentManager) -> Maybe manager -> RecentManager
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (ForeignPtr RecentManager -> RecentManager
RecentManager ForeignPtr RecentManager
forall a. ForeignPtr a
nullForeignPtr) manager -> RecentManager
forall o. RecentManagerClass o => o -> RecentManager
toRecentManager Maybe manager
manager)

--------------------
-- Attributes

-- | If recent items should be shown with numbers next to them.
--
recentActionShowNumbers :: RecentActionClass self => Attr self Bool
recentActionShowNumbers :: forall self. RecentActionClass self => Attr self Bool
recentActionShowNumbers = String -> Attr self Bool
forall gobj. GObjectClass gobj => String -> Attr gobj Bool
newAttrFromBoolProperty String
"show-numbers"

foreign import ccall safe "gtk_recent_action_new"
  gtk_recent_action_new :: ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> (IO (Ptr Action))))))

foreign import ccall safe "gtk_recent_action_new_for_manager"
  gtk_recent_action_new_for_manager :: ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr RecentManager) -> (IO (Ptr Action)))))))