{-# LINE 2 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget WindowGroup
--
-- Author : Duncan Coutts
--
-- Created: 25 March 2005
--
-- Copyright (C) 2005 Duncan Coutts
--
-- 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)
--
-- Limit the effect of grabs
--
module Graphics.UI.Gtk.Windows.WindowGroup (

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

-- * Types
  WindowGroup,
  WindowGroupClass,
  castToWindowGroup, gTypeWindowGroup,
  toWindowGroup,

-- * Constructors
  windowGroupNew,

-- * Methods
  windowGroupAddWindow,
  windowGroupRemoveWindow,

  windowGroupListWindows,

  ) where

import System.Glib.FFI
import System.Glib.GList (fromGList)
import Graphics.UI.Gtk.Types
{-# LINE 57 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}


{-# LINE 59 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}

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

-- | Creates a new 'WindowGroup' object. Grabs added with
-- 'Graphics.UI.Gtk.General.General.grabAdd' only affect windows within the
-- same 'WindowGroup'.
--
windowGroupNew :: IO WindowGroup
windowGroupNew :: IO WindowGroup
windowGroupNew =
  (ForeignPtr WindowGroup -> WindowGroup, FinalizerPtr WindowGroup)
-> IO (Ptr WindowGroup) -> IO WindowGroup
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr WindowGroup -> WindowGroup, FinalizerPtr WindowGroup)
forall {a}. (ForeignPtr WindowGroup -> WindowGroup, FinalizerPtr a)
mkWindowGroup (IO (Ptr WindowGroup) -> IO WindowGroup)
-> IO (Ptr WindowGroup) -> IO WindowGroup
forall a b. (a -> b) -> a -> b
$
  IO (Ptr WindowGroup)
gtk_window_group_new
{-# LINE 71 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}

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

-- | Adds a window to a 'WindowGroup'.
--
windowGroupAddWindow :: (WindowGroupClass self, WindowClass window) => self
 -> window -- ^ @window@ - the 'Window' to add
 -> IO ()
windowGroupAddWindow :: forall self window.
(WindowGroupClass self, WindowClass window) =>
self -> window -> IO ()
windowGroupAddWindow self
self window
window =
  (\(WindowGroup ForeignPtr WindowGroup
arg1) (Window ForeignPtr Window
arg2) -> ForeignPtr WindowGroup -> (Ptr WindowGroup -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr WindowGroup
arg1 ((Ptr WindowGroup -> IO ()) -> IO ())
-> (Ptr WindowGroup -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr WindowGroup
argPtr1 ->ForeignPtr Window -> (Ptr Window -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Window
arg2 ((Ptr Window -> IO ()) -> IO ()) -> (Ptr Window -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Window
argPtr2 ->Ptr WindowGroup -> Ptr Window -> IO ()
gtk_window_group_add_window Ptr WindowGroup
argPtr1 Ptr Window
argPtr2)
{-# LINE 82 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}
    (toWindowGroup self)
    (window -> Window
forall o. WindowClass o => o -> Window
toWindow window
window)

-- | Removes a window from a 'WindowGroup'.
--
windowGroupRemoveWindow :: (WindowGroupClass self, WindowClass window) => self
 -> window -- ^ @window@ - the 'Window' to remove
 -> IO ()
windowGroupRemoveWindow :: forall self window.
(WindowGroupClass self, WindowClass window) =>
self -> window -> IO ()
windowGroupRemoveWindow self
self window
window =
  (\(WindowGroup ForeignPtr WindowGroup
arg1) (Window ForeignPtr Window
arg2) -> ForeignPtr WindowGroup -> (Ptr WindowGroup -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr WindowGroup
arg1 ((Ptr WindowGroup -> IO ()) -> IO ())
-> (Ptr WindowGroup -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr WindowGroup
argPtr1 ->ForeignPtr Window -> (Ptr Window -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Window
arg2 ((Ptr Window -> IO ()) -> IO ()) -> (Ptr Window -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Window
argPtr2 ->Ptr WindowGroup -> Ptr Window -> IO ()
gtk_window_group_remove_window Ptr WindowGroup
argPtr1 Ptr Window
argPtr2)
{-# LINE 92 "./Graphics/UI/Gtk/Windows/WindowGroup.chs" #-}
    (toWindowGroup self)
    (window -> Window
forall o. WindowClass o => o -> Window
toWindow window
window)


-- | Returns a list of the 'Window's that belong to @windowGroup@.
--
-- * Available since Gtk+ version 2.14
--
windowGroupListWindows :: WindowGroupClass self
  => self -- ^ @windowGroup@ - the window group
 -> IO [Window] -- ^ returns the list of windows inside this group
windowGroupListWindows :: forall self. WindowGroupClass self => self -> IO [Window]
windowGroupListWindows self
self = do
  Ptr ()
glist <- (\(WindowGroup ForeignPtr WindowGroup
arg1) -> ForeignPtr WindowGroup
-> (Ptr WindowGroup -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr WindowGroup
arg1 ((Ptr WindowGroup -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr WindowGroup -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr WindowGroup
argPtr1 ->Ptr WindowGroup -> IO (Ptr ())
gtk_window_group_list_windows Ptr WindowGroup
argPtr1) (self -> WindowGroup
forall o. WindowGroupClass o => o -> WindowGroup
toWindowGroup self
self)
  [Ptr Window]
ptrList <- Ptr () -> IO [Ptr Window]
forall a. Ptr () -> IO [Ptr a]
fromGList Ptr ()
glist
  (Ptr Window -> IO Window) -> [Ptr Window] -> IO [Window]
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 Window -> Window, FinalizerPtr Window)
-> IO (Ptr Window) -> IO Window
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr Window -> Window, FinalizerPtr Window)
forall {a}. (ForeignPtr Window -> Window, FinalizerPtr a)
mkWindow (IO (Ptr Window) -> IO Window)
-> (Ptr Window -> IO (Ptr Window)) -> Ptr Window -> IO Window
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Window -> IO (Ptr Window)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return) [Ptr Window]
ptrList

foreign import ccall safe "gtk_window_group_new"
  gtk_window_group_new :: (IO (Ptr WindowGroup))

foreign import ccall safe "gtk_window_group_add_window"
  gtk_window_group_add_window :: ((Ptr WindowGroup) -> ((Ptr Window) -> (IO ())))

foreign import ccall safe "gtk_window_group_remove_window"
  gtk_window_group_remove_window :: ((Ptr WindowGroup) -> ((Ptr Window) -> (IO ())))

foreign import ccall safe "gtk_window_group_list_windows"
  gtk_window_group_list_windows :: ((Ptr WindowGroup) -> (IO (Ptr ())))