{-# LINE 2 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget DisplayManager
--
-- Author : Andy Stewart
--
-- Created: 29 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)
--
-- Maintains a list of all open GdkDisplays
--
-- * Module available since Gdk version 2.2
--
module Graphics.UI.Gtk.Gdk.DisplayManager (

-- * Detail
--
-- | The purpose of the 'DisplayManager' singleton object is to offer
-- notification when displays appear or disappear or the default display
-- changes.

-- * Class Hierarchy
--
-- |
-- @
-- | 'GObject'
-- | +----DisplayManager
-- @


-- * Types
  DisplayManager,
  DisplayManagerClass,
  castToDisplayManager,
  toDisplayManager,

-- * Methods
  displayManagerGet,
  displayManagerListDisplays,

-- * Attributes
  displayManagerDefaultDisplay,

-- * Signals
  displayManagerOpened,

  ) where

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import System.Glib.GList
import Graphics.UI.Gtk.Types
{-# LINE 70 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}
import Graphics.UI.Gtk.Signals
{-# LINE 71 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}


{-# LINE 73 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}


--------------------
-- Methods

-- | Returns the global 'DisplayManager' singleton; 'parsePargs', 'init', or
-- 'initCheck' must have been called first.
--
displayManagerGet :: IO DisplayManager -- ^ returns the singleton 'DisplayManager' object.
displayManagerGet :: IO DisplayManager
displayManagerGet =
  (ForeignPtr DisplayManager -> DisplayManager,
 FinalizerPtr DisplayManager)
-> IO (Ptr DisplayManager) -> IO DisplayManager
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
constructNewGObject (ForeignPtr DisplayManager -> DisplayManager,
 FinalizerPtr DisplayManager)
forall {a}.
(ForeignPtr DisplayManager -> DisplayManager, FinalizerPtr a)
mkDisplayManager (IO (Ptr DisplayManager) -> IO DisplayManager)
-> IO (Ptr DisplayManager) -> IO DisplayManager
forall a b. (a -> b) -> a -> b
$
  IO (Ptr DisplayManager)
gdk_display_manager_get
{-# LINE 85 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}

-- | List all currently open displays.
--
displayManagerListDisplays :: DisplayManagerClass self => self
 -> IO [Display] -- ^ returns a newly allocated list of 'Display' objects.
displayManagerListDisplays :: forall self. DisplayManagerClass self => self -> IO [Display]
displayManagerListDisplays self
self =
  (\(DisplayManager ForeignPtr DisplayManager
arg1) -> ForeignPtr DisplayManager
-> (Ptr DisplayManager -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr DisplayManager
arg1 ((Ptr DisplayManager -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr DisplayManager -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr DisplayManager
argPtr1 ->Ptr DisplayManager -> IO (Ptr ())
gdk_display_manager_list_displays Ptr DisplayManager
argPtr1)
{-# LINE 92 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}
    (toDisplayManager self)
  IO (Ptr ()) -> (Ptr () -> IO [Ptr Display]) -> IO [Ptr Display]
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr () -> IO [Ptr Display]
forall a. Ptr () -> IO [Ptr a]
fromGSList
  IO [Ptr Display] -> ([Ptr Display] -> IO [Display]) -> IO [Display]
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Ptr Display -> IO Display) -> [Ptr Display] -> IO [Display]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ForeignPtr Display -> Display, FinalizerPtr Display)
-> IO (Ptr Display) -> IO Display
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr Display -> Display, FinalizerPtr Display)
forall {a}. (ForeignPtr Display -> Display, FinalizerPtr a)
mkDisplay (IO (Ptr Display) -> IO Display)
-> (Ptr Display -> IO (Ptr Display)) -> Ptr Display -> IO Display
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Display -> IO (Ptr Display)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return)

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

-- | The default display.
--
displayManagerDefaultDisplay :: DisplayManagerClass self => Attr self Display
displayManagerDefaultDisplay :: forall self. DisplayManagerClass self => Attr self Display
displayManagerDefaultDisplay = String -> GType -> ReadWriteAttr self Display Display
forall gobj gobj' gobj''.
(GObjectClass gobj, GObjectClass gobj', GObjectClass gobj'') =>
String -> GType -> ReadWriteAttr gobj gobj' gobj''
newAttrFromObjectProperty String
"default-display"
                                 GType
gdk_display_get_type
{-# LINE 104 "./Graphics/UI/Gtk/Gdk/DisplayManager.chs" #-}

--------------------
-- Signals

-- | The 'displayManagerOpened' signal is emitted when a display is opened.
--
displayManagerOpened :: DisplayManagerClass self => Signal self (Display -> IO ())
displayManagerOpened :: forall self.
DisplayManagerClass self =>
Signal self (Display -> IO ())
displayManagerOpened = (Bool -> self -> (Display -> IO ()) -> IO (ConnectId self))
-> Signal self (Display -> IO ())
forall object handler.
(Bool -> object -> handler -> IO (ConnectId object))
-> Signal object handler
Signal (String -> Bool -> self -> (Display -> IO ()) -> IO (ConnectId self)
forall a' obj.
(GObjectClass a', GObjectClass obj) =>
String -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
connect_OBJECT__NONE String
"display_opened")

foreign import ccall safe "gdk_display_manager_get"
  gdk_display_manager_get :: (IO (Ptr DisplayManager))

foreign import ccall safe "gdk_display_manager_list_displays"
  gdk_display_manager_list_displays :: ((Ptr DisplayManager) -> (IO (Ptr ())))

foreign import ccall unsafe "gdk_display_get_type"
  gdk_display_get_type :: CUInt