From: Duncan C. <dun...@us...> - 2005-03-26 00:12:22
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3333/gtk/Graphics/UI/Gtk/Windows Modified Files: Dialog.chs Window.chs.pp Log Message: Documentation changes and code formatting changes. Index: Dialog.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Windows/Dialog.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Dialog.chs 13 Mar 2005 19:34:39 -0000 1.4 +++ Dialog.chs 26 Mar 2005 00:11:42 -0000 1.5 @@ -24,13 +24,13 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A dialog is a smaller window that is used to ask the user for input. +-- Create popup windows -- module Graphics.UI.Gtk.Windows.Dialog ( --- * Description +-- * Detail -- -- | Dialog boxes are a convenient way to prompt the user for a small amount --- of input, eg. to display a message, ask a question, or anything else that +-- of input, e.g. to display a message, ask a question, or anything else that -- does not require extensive effort on the user's part. -- -- Gtk+ treats a dialog as a window split vertically. The top section is a @@ -45,7 +45,7 @@ -- -- If \'dialog\' is a newly created dialog, the two primary areas of the -- window can be accessed using 'dialogGetUpper' and --- 'dialogGetActionArea', as can be seen from the example, below. +-- 'dialogGetActionArea'. -- -- A \'modal\' dialog (that is, one which freezes the rest of the -- application from user input), can be created by calling 'windowSetModal' on @@ -81,6 +81,7 @@ -- | +----'Bin' -- | +----'Window' -- | +----Dialog +-- | +----'AboutDialog' -- | +----'ColorSelectionDialog' -- | +----'FileChooserDialog' -- | +----'FileSelection' @@ -126,98 +127,149 @@ import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} -import Graphics.UI.Gtk.General.Structs (dialogGetUpper, dialogGetActionArea, ResponseId(..), fromResponse, toResponse) +import Graphics.UI.Gtk.General.Structs (dialogGetUpper, dialogGetActionArea, + ResponseId(..), fromResponse, toResponse) {# context lib="gtk" prefix="gtk" #} -------------------- -- Constructors --- | Create a new Dialog. +-- | Creates a new dialog box. Widgets should not be packed into this 'Window' +-- directly, but into the \"upper\" and \"action area\", which are obtained +-- using 'dialogGetUpper' and 'dialogGetActionArea'. -- dialogNew :: IO Dialog -dialogNew = makeNewObject mkDialog $ liftM castPtr {#call unsafe dialog_new#} +dialogNew = + makeNewObject mkDialog $ + liftM (castPtr :: Ptr Widget -> Ptr Dialog) $ + {# call unsafe dialog_new #} -------------------- -- Methods --- | Run the dialog by entering a new main loop. +-- | Blocks in a recursive main loop until the dialog either emits the +-- response signal, or is destroyed. If the dialog is destroyed during the call +-- to 'dialogRun', it returns 'ResponseNone'. Otherwise, it returns the +-- response ID from the \"response\" signal emission. Before entering the +-- recursive main loop, 'dialogRun' calls 'widgetShow' on the dialog for you. +-- Note that you still need to show any children of the dialog yourself. -- --- * The dialog is run until it is either forced to quit (-1 will be returned) --- or until the user clicks a button (or other widget) in the action area --- that makes the dialog emit the @response@ signal (the response id --- of the pressed button will be returned). +-- During 'dialogRun', the default behavior of \"delete_event\" is disabled; +-- if the dialog receives \"delete_event\", it will not be destroyed as windows +-- usually are, and 'dialogRun' will return 'ResponseDeleteEvent'. Also, during +-- 'dialogRun' the dialog will be modal. You can force 'dialogRun' to return at +-- any time by calling 'dialogResponse' to emit the \"response\" signal. +-- Destroying the dialog during 'dialogRun' is a very bad idea, because your +-- post-run code won't know whether the dialog was destroyed or not. -- --- * To force a dialog to quit, call 'dialogResponse' on it. +-- After 'dialogRun' returns, you are responsible for hiding or destroying +-- the dialog if you wish to do so. -- --- * If this function returns the dialog still needs to be destroyed. +-- Note that even though the recursive main loop gives the effect of a modal +-- dialog (it prevents the user from interacting with other windows while the +-- dialog is run), callbacks such as timeouts, IO channel watches, DND drops, +-- etc, /will/ be triggered during a 'dialogRun' call. -- -dialogRun :: DialogClass dc => dc -> IO ResponseId -dialogRun dc = liftM toResponse $ {#call dialog_run#} (toDialog dc) +dialogRun :: DialogClass self => self + -> IO ResponseId +dialogRun self = + liftM toResponse $ + {# call dialog_run #} + (toDialog self) --- | Emit the @response@ signal on the dialog. +-- | Emits the \"response\" signal with the given response ID. Used to +-- indicate that the user has responded to the dialog in some way; typically +-- either you or 'dialogRun' will be monitoring the \"response\" signal and +-- take appropriate action. -- --- * This function can be used to add a custom widget to the action area that --- should close the dialog when activated or to close the dialog otherwise. +-- This function can be used to add a custom widget to the action area that +-- should close the dialog when activated or to close the dialog otherwise. -- -dialogResponse :: DialogClass dc => dc -> ResponseId -> IO () -dialogResponse dc resId = - {#call dialog_response#} (toDialog dc) (fromResponse resId) +dialogResponse :: DialogClass self => self + -> ResponseId + -> IO () +dialogResponse self responseId = + {# call dialog_response #} + (toDialog self) + (fromResponse responseId) --- | Add a button with a label to the action area. --- --- * The text may as well refer to a stock object. If such an object exists it --- is taken as widget. --- --- * The function returns the Button that resulted from the call. +-- | Adds a button with the given text (or a stock button, if @buttonText@ is +-- a stock ID) and sets things up so that clicking the button will emit the +-- \"response\" signal with the given @responseId@. The button is appended to +-- the end of the dialog's action area. The button widget is returned, but +-- usually you don't need it. -- -dialogAddButton :: DialogClass dc => dc -> String -> ResponseId -> IO Button -dialogAddButton dc button resId = withUTFString button $ \strPtr -> - makeNewObject mkButton $ liftM castPtr $ {#call dialog_add_button#} - (toDialog dc) strPtr (fromResponse resId) +dialogAddButton :: DialogClass self => self + -> String -- ^ @buttonText@ - text of button, or stock ID + -> ResponseId -- ^ @responseId@ - response ID for the button + -> IO Button -- ^ returns the button widget that was added +dialogAddButton self buttonText responseId = + makeNewObject mkButton $ liftM castPtr $ + withUTFString buttonText $ \buttonTextPtr -> + {# call dialog_add_button #} + (toDialog self) + buttonTextPtr + (fromResponse responseId) --- | Add a widget to the action area. If the --- widget is put into the activated state @resId@ will be transmitted --- by the @response@ signal. --- --- * A widget that cannot be activated and therefore has to emit the response --- signal manually must be added by packing it into the action area. +-- | Adds an activatable widget to the action area of a 'Dialog', connecting a +-- signal handler that will emit the \"response\" signal on the dialog when the +-- widget is activated. The widget is appended to the end of the dialog's +-- action area. If you want to add a non-activatable widget, simply pack it +-- into the action area. -- -dialogAddActionWidget :: (DialogClass dc, WidgetClass w) => dc -> w -> - ResponseId -> IO () -dialogAddActionWidget dc child resId = {#call dialog_add_action_widget#} - (toDialog dc) (toWidget child) (fromResponse resId) +dialogAddActionWidget :: (DialogClass self, WidgetClass child) => self + -> child -- ^ @child@ - an activatable widget + -> ResponseId -- ^ @responseId@ - response ID for @child@ + -> IO () +dialogAddActionWidget self child responseId = + {# call dialog_add_action_widget #} + (toDialog self) + (toWidget child) + (fromResponse responseId) --- | Query if the dialog has a visible horizontal --- separator. +-- | Query if the dialog has a visible horizontal separator. -- -dialogGetHasSeparator :: DialogClass dc => dc -> IO Bool -dialogGetHasSeparator dc = liftM toBool $ - {#call unsafe dialog_get_has_separator#} (toDialog dc) +dialogGetHasSeparator :: DialogClass self => self -> IO Bool +dialogGetHasSeparator self = + liftM toBool $ + {# call unsafe dialog_get_has_separator #} + (toDialog self) --- | Set the default widget that is to be --- activated if the user pressed enter. The object is specified by the --- ResponseId. +-- | Sets the last widget in the dialog's action area with the given +-- 'ResponseId' as the default widget for the dialog. Pressing \"Enter\" +-- normally activates the default widget. -- -dialogSetDefaultResponse :: DialogClass dc => dc -> ResponseId -> IO () -dialogSetDefaultResponse dc resId = {#call dialog_set_default_response#} - (toDialog dc) (fromResponse resId) +dialogSetDefaultResponse :: DialogClass self => self + -> ResponseId + -> IO () +dialogSetDefaultResponse self responseId = + {# call dialog_set_default_response #} + (toDialog self) + (fromResponse responseId) --- | Set the visibility of the horizontal --- separator. +-- | Sets whether the dialog has a separator above the buttons. @True@ by +-- default. -- -dialogSetHasSeparator :: DialogClass dc => dc -> Bool -> IO () -dialogSetHasSeparator dc set = {#call dialog_set_has_separator#} - (toDialog dc) (fromBool set) +dialogSetHasSeparator :: DialogClass self => self -> Bool -> IO () +dialogSetHasSeparator self setting = + {# call dialog_set_has_separator #} + (toDialog self) + (fromBool setting) --- | Set widgets in the action are to be --- sensitive or not. +-- | Calls @'widgetSetSensitive' widget setting@ for each widget in the +-- dialog's action area with the given @responseId@. A convenient way to +-- sensitize\/desensitize dialog buttons. -- -dialogSetResponseSensitive :: DialogClass dc => dc -> ResponseId -> Bool -> - IO () -dialogSetResponseSensitive dc resId sensitive = - {#call dialog_set_response_sensitive#} (toDialog dc) (fromResponse resId) - (fromBool sensitive) +dialogSetResponseSensitive :: DialogClass self => self + -> Int -- ^ @responseId@ - a response ID + -> Bool -- ^ @setting@ - @True@ for sensitive + -> IO () +dialogSetResponseSensitive self responseId setting = + {# call dialog_set_response_sensitive #} + (toDialog self) + (fromResponse responseId) + (fromBool setting) -------------------- -- Properties @@ -226,7 +278,7 @@ -- -- Default value: @True@ -- -dialogHasSeparator :: Attr Dialog Bool +dialogHasSeparator :: DialogClass self => Attr self Bool dialogHasSeparator = Attr dialogGetHasSeparator dialogSetHasSeparator @@ -234,12 +286,13 @@ -------------------- -- Signals --- | This signal is sent when a widget in the action --- area was activated, the dialog is received a destory event or the user --- calls dialogResponse. It is usually used to terminate the dialog (by --- dialogRun for example). +-- | Emitted when an action widget is clicked, the dialog receives a delete +-- event, or the application programmer calls 'dialogResponse'. On a delete +-- event, the response ID is 'ResponseNone'. Otherwise, it depends on which +-- action widget was clicked. -- -onResponse, afterResponse :: DialogClass dc => dc -> (ResponseId -> IO ()) -> - IO (ConnectId dc) +onResponse, afterResponse :: DialogClass self => self + -> (ResponseId -> IO ()) + -> IO (ConnectId self) onResponse dia act = connect_INT__NONE "response" False dia (act . toResponse) afterResponse dia act = connect_INT__NONE "response" True dia (act . toResponse) Index: Window.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Windows/Window.chs.pp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Window.chs.pp 13 Mar 2005 19:34:39 -0000 1.4 +++ Window.chs.pp 26 Mar 2005 00:11:42 -0000 1.5 @@ -109,164 +109,330 @@ -------------------- -- Constructors --- | Create a new window of the given type. +-- | Create a new top level window. -- windowNew :: IO Window -windowNew = makeNewObject mkWindow $ liftM castPtr $ - {#call window_new#} ((fromIntegral.fromEnum) WindowToplevel) +windowNew = + makeNewObject mkWindow $ + liftM (castPtr :: Ptr Widget -> Ptr Window) $ + {# call window_new #} + ((fromIntegral . fromEnum) WindowToplevel) -------------------- -- Methods --- | set the title string of the given window +-- | Sets the title of the 'Window'. The title of a window will be displayed +-- in its title bar; on the X Window System, the title bar is rendered by the +-- window manager, so exactly how the title appears to users may vary according +-- to a user's exact configuration. The title should help a user distinguish +-- this window from other windows they may have open. A good title might +-- include the application name and current document filename, for example. -- -windowSetTitle :: WindowClass w => w -> String -> IO () -windowSetTitle w str = - withUTFString str ({#call window_set_title#} (toWindow w)) +windowSetTitle :: WindowClass self => self -> String -> IO () +windowSetTitle self title = + withUTFString title $ \titlePtr -> + {# call gtk_window_set_title #} + (toWindow self) + titlePtr --- | Sets whether the user can resize a window. --- --- * Windows are user resizable by default. +-- | Sets whether the user can resize a window. Windows are user resizable by +-- default. -- -windowSetResizable :: WindowClass w => w -> Bool -> IO () -windowSetResizable w res = - {#call window_set_resizable#} (toWindow w) (fromBool res) +windowSetResizable :: WindowClass self => self -> Bool -> IO () +windowSetResizable self resizable = + {# call window_set_resizable #} + (toWindow self) + (fromBool resizable) --- | Retrieve the value set by --- 'windowSetResizable'. +-- | Gets the value set by 'windowSetResizable'. -- -windowGetResizable :: WindowClass w => w -> IO Bool -windowGetResizable w = liftM toBool $ - {#call unsafe window_get_resizable#} (toWindow w) +windowGetResizable :: WindowClass self => self + -> IO Bool -- ^ returns @True@ if the user can resize the window +windowGetResizable self = + liftM toBool $ + {# call unsafe window_get_resizable #} + (toWindow self) --- | dunno +-- | Activates the current focused widget within the window. -- -windowActivateFocus :: WindowClass w => w -> IO Bool -windowActivateFocus w = - liftM toBool $ {#call window_activate_focus#} (toWindow w) +windowActivateFocus :: WindowClass self => self + -> IO Bool -- ^ returns @True@ if a widget got activated. +windowActivateFocus self = + liftM toBool $ + {# call window_activate_focus #} + (toWindow self) --- | dunno +-- | Activates the default widget for the window, unless the current focused +-- widget has been configured to receive the default action (see +-- 'ReceivesDefault' in 'WidgetFlags'), in which case the focused widget is +-- activated. -- -windowActivateDefault :: WindowClass w => w -> IO Bool -windowActivateDefault w = - liftM toBool $ {#call window_activate_default#} (toWindow w) +windowActivateDefault :: WindowClass self => self + -> IO Bool -- ^ returns @True@ if a widget got activated. +windowActivateDefault self = + liftM toBool $ + {# call window_activate_default #} + (toWindow self) #ifndef DISABLE_DEPRECATED {-# DEPRECATED windowSetPolicy "Use windowSetResizable instead." #-} --- windowSetPolicy: set the window policy +-- | Sets the window resizing policy. -- -windowSetPolicy :: WindowClass w => w -> Bool -> Bool -> Bool -> IO () -windowSetPolicy w shrink grow auto = {#call window_set_policy#} - (toWindow w) (fromBool shrink) (fromBool grow) (fromBool auto) +-- * Warning: this function is deprecated and should not be used in +-- newly-written code. Use 'windowSetResizable' instead. +-- +windowSetPolicy :: WindowClass self => self -> Bool -> Bool -> Bool -> IO () +windowSetPolicy self allowShrink allowGrow autoShrink = + {# call window_set_policy #} + (toWindow self) + (fromBool allowShrink) + (fromBool allowGrow) + (fromBool autoShrink) #endif --- | make a window application modal +-- | Sets a window modal or non-modal. Modal windows prevent interaction with +-- other windows in the same application. To keep modal dialogs on top of main +-- application windows, use 'windowSetTransientFor' to make the dialog +-- transient for the parent; most window managers will then disallow lowering +-- the dialog below the parent. -- -windowSetModal :: WindowClass w => w -> Bool -> IO () -windowSetModal w m = {#call window_set_modal#} (toWindow w) (fromBool m) +windowSetModal :: WindowClass self => self + -> Bool -- ^ @modal@ - whether the window is modal + -> IO () +windowSetModal self modal = + {# call window_set_modal #} + (toWindow self) + (fromBool modal) --- | set window default size +-- | Sets the default size of a window. If the window's \"natural\" size (its +-- size request) is larger than the default, the default will be ignored. More +-- generally, if the default size does not obey the geometry hints for the +-- window ('windowSetGeometryHints' can be used to set these explicitly), the +-- default size will be clamped to the nearest permitted size. -- --- * Sets the default size of a window. If the window's \"natural\" size (its --- size request) is larger than the default, the default will be ignored. --- More generally, if the default size does not obey the geometry hints for --- the window ('windowSetGeometryHints' can be used to set these --- explicitly), the default size will be clamped to the nearest permitted --- size. +-- Unlike 'widgetSetSizeRequest', which sets a size request for a widget and +-- thus would keep users from shrinking the window, this function only sets the +-- initial size, just as if the user had resized the window themselves. Users +-- can still shrink the window again as they normally would. Setting a default +-- size of -1 means to use the \"natural\" default size (the size request of +-- the window). -- --- * Unlike @widgetSetSizeRequest@, which sets a size request for a --- widget and thus would keep users from shrinking the window, this function --- only sets the initial size, just as if the user had resized the window --- themselves. Users can still shrink the window again as they normally --- would. Setting a default size of -1 means to use the \"natural\" default --- size (the size request of the window). +-- For more control over a window's initial size and how resizing works, +-- investigate 'windowSetGeometryHints'. -- --- * For more control over a window's initial size and how resizing works, --- investigate 'windowSetGeometryHints'. +-- For some uses, 'windowResize' is a more appropriate function. +-- 'windowResize' changes the current size of the window, rather than the size +-- to be used on initial display. 'windowResize' always affects the window +-- itself, not the geometry widget. -- --- * For some uses, 'windowResize' is a more appropriate function. --- 'windowResize' changes the current size of the window, rather --- than the size to be used on initial display. 'windowResize' --- always affects the window itself, not the geometry widget.The default --- size of a window only affects the first time a window is shown; if a --- window is hidden and re-shown, it will remember the size it had prior to --- hiding, rather than using the default size. Windows can't actually be 0x0 --- in size, they must be at least 1x1, but passing 0 for width and height is --- OK, resulting in a 1x1 default size. +-- The default size of a window only affects the first time a window is +-- shown; if a window is hidden and re-shown, it will remember the size it had +-- prior to hiding, rather than using the default size. -- -windowSetDefaultSize :: WindowClass w => w -> Int -> Int -> IO () -windowSetDefaultSize w height width = - {#call window_set_default_size#} (toWindow w) (fromIntegral height) - (fromIntegral width) +-- Windows can't actually be 0x0 in size, they must be at least 1x1, but +-- passing 0 for @width@ and @height@ is OK, resulting in a 1x1 default size. +-- +windowSetDefaultSize :: WindowClass self => self + -> Int -- ^ @height@ - height in pixels, or -1 to unset the default height + -> Int -- ^ @width@ - width in pixels, or -1 to unset the default width + -> IO () +windowSetDefaultSize self height width = + {# call window_set_default_size #} + (toWindow self) + (fromIntegral height) + (fromIntegral width) --- | set the window position policy +-- | Sets a position constraint for this window. If the old or new constraint +-- is 'WinPosCenterAlways', this will also cause the window to be repositioned +-- to satisfy the new constraint. -- -windowSetPosition :: WindowClass w => w -> WindowPosition -> IO () -windowSetPosition w pos = - {#call window_set_position#} (toWindow w) ((fromIntegral.fromEnum) pos) +windowSetPosition :: WindowClass self => self -> WindowPosition -> IO () +windowSetPosition self position = + {# call window_set_position #} + (toWindow self) + ((fromIntegral . fromEnum) position) --- | set transient window +-- | Dialog windows should be set transient for the main application window +-- they were spawned from. This allows window managers to e.g. keep the dialog +-- on top of the main window, or center the dialog over the main window. +-- 'dialogNewWithButtons' and other convenience functions in Gtk+ will +-- sometimes call 'windowSetTransientFor' on your behalf. -- -windowSetTransientFor :: (WindowClass win, WindowClass parent) => win -> - parent -> IO () -windowSetTransientFor w p = - {#call window_set_transient_for#} (toWindow w) (toWindow p) +-- On Windows, this function will and put the child window on top of the +-- parent, much as the window manager would have done on X. +-- +windowSetTransientFor :: (WindowClass self, WindowClass parent) => self + -> parent -- ^ @parent@ - parent window + -> IO () +windowSetTransientFor self parent = + {# call window_set_transient_for #} + (toWindow self) + (toWindow parent) --- | destory transient window with parent +-- | If this setting is @True@, then destroying the transient parent of the +-- window will also destroy the window itself. This is useful for dialogs that +-- shouldn't persist beyond the lifetime of the main window they\'re associated +-- with, for example. -- -windowSetDestroyWithParent :: WindowClass w => w -> Bool -> IO () -windowSetDestroyWithParent w b = - {#call window_set_destroy_with_parent#} (toWindow w) (fromBool b) +windowSetDestroyWithParent :: WindowClass self => self -> Bool -> IO () +windowSetDestroyWithParent self setting = + {# call window_set_destroy_with_parent #} + (toWindow self) + (fromBool setting) --- | restore the window +-- | Asks to deiconify (i.e. unminimize) the specified @window@. Note that you +-- shouldn't assume the window is definitely deiconified afterward, because +-- other entities (e.g. the user or window manager) could iconify it again +-- before your code which assumes deiconification gets to run. -- -windowDeiconify :: WindowClass w => w -> IO () -windowDeiconify w = {#call window_deiconify#} (toWindow w) +-- You can track iconification via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowDeiconify :: WindowClass self => self -> IO () +windowDeiconify self = + {# call window_deiconify #} + (toWindow self) --- | minimize the window +-- | Asks to iconify (i.e. minimize) the specified @window@. Note that you +-- shouldn't assume the window is definitely iconified afterward, because other +-- entities (e.g. the user or window manager) could deiconify it again, or +-- there may not be a window manager in which case iconification isn't +-- possible, etc. But normally the window will end up iconified. Just don't +-- write code that crashes if not. -- -windowIconify :: WindowClass w => w -> IO () -windowIconify w = {#call window_iconify#} (toWindow w) +-- It's permitted to call this function before showing a window, in which +-- case the window will be iconified before it ever appears onscreen. +-- +-- You can track iconification via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowIconify :: WindowClass self => self -> IO () +windowIconify self = + {# call window_iconify #} + (toWindow self) --- | maximize the window +-- | Asks to maximize the window, so that it becomes full-screen. Note that you +-- shouldn't assume the window is definitely maximized afterward, because other +-- entities (e.g. the user or window manager) could unmaximize it again, and +-- not all window managers support maximization. But normally the window will +-- end up maximized. Just don't write code that crashes if not. -- -windowMaximize :: WindowClass w => w -> IO () -windowMaximize w = {#call window_maximize#} (toWindow w) +-- It's permitted to call this function before showing a window, in which +-- case the window will be maximized when it appears onscreen initially. +-- +-- You can track maximization via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowMaximize :: WindowClass self => self -> IO () +windowMaximize self = + {# call window_maximize #} + (toWindow self) --- | unmaximize the window +-- | Asks to unmaximize the window. Note that you shouldn't assume the window is +-- definitely unmaximized afterward, because other entities (e.g. the user or +-- window manager) could maximize it again, and not all window managers honor +-- requests to unmaximize. But normally the window will end up unmaximized. +-- Just don't write code that crashes if not. -- -windowUnmaximize :: WindowClass w => w -> IO () -windowUnmaximize w = {#call window_unmaximize#} (toWindow w) +-- You can track maximization via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowUnmaximize :: WindowClass self => self -> IO () +windowUnmaximize self = + {# call window_unmaximize #} + (toWindow self) --- | remove the border +-- | By default, windows are decorated with a title bar, resize controls, etc. +-- Some window managers allow Gtk+ to disable these decorations, creating a +-- borderless window. If you set the decorated property to @False@ using this +-- function, Gtk+ will do its best to convince the window manager not to +-- decorate the window. Depending on the system, this function may not have any +-- effect when called on a window that is already visible, so you should call +-- it before calling 'windowShow'. -- -windowSetDecorated :: WindowClass w => w -> Bool -> IO () -windowSetDecorated w b = - {#call window_set_decorated#} (toWindow w) (fromBool b) +-- On Windows, this function always works, since there's no window manager +-- policy involved. +-- +windowSetDecorated :: WindowClass self => self -> Bool -> IO () +windowSetDecorated self setting = + {# call window_set_decorated #} + (toWindow self) + (fromBool setting) --- | set border widths +-- | (Note: this is a special-purpose function intended for the framebuffer +-- port; see 'windowSetHasFrame'. It will have no effect on the window border +-- drawn by the window manager, which is the normal case when using the X +-- Window system.) -- -windowSetFrameDimensions :: WindowClass w => w -> Int -> Int -> Int -> Int -> - IO () -windowSetFrameDimensions w left top right bottom = - {#call window_set_frame_dimensions#} (toWindow w) (fromIntegral left) - (fromIntegral top) (fromIntegral right) (fromIntegral bottom) +-- For windows with frames (see 'windowSetHasFrame') this function can be +-- used to change the size of the frame border. +-- +windowSetFrameDimensions :: WindowClass self => self + -> Int -- ^ @left@ - The width of the left border + -> Int -- ^ @top@ - The height of the top border + -> Int -- ^ @right@ - The width of the right border + -> Int -- ^ @bottom@ - The height of the bottom border + -> IO () +windowSetFrameDimensions self left top right bottom = + {# call window_set_frame_dimensions #} + (toWindow self) + (fromIntegral left) + (fromIntegral top) + (fromIntegral right) + (fromIntegral bottom) --- | set role (additional window name for the WM) +-- | This function is only useful on X11, not with other Gtk+ targets. -- -windowSetRole :: WindowClass w => w -> String -> IO () -windowSetRole w str = - withUTFString str ({#call window_set_role#} (toWindow w)) +-- In combination with the window title, the window role allows a window +-- manager to identify \"the same\" window when an application is restarted. So +-- for example you might set the \"toolbox\" role on your app's toolbox window, +-- so that when the user restarts their session, the window manager can put the +-- toolbox back in the same place. +-- +-- If a window already has a unique title, you don't need to set the role, +-- since the WM can use the title to identify the window when restoring the +-- session. +-- +windowSetRole :: WindowClass self => self + -> String -- ^ @role@ - unique identifier for the window to be used when + -- restoring a session + -> IO () +windowSetRole self role = + withUTFString role $ \rolePtr -> + {# call window_set_role #} + (toWindow self) + rolePtr --- | show the window on every workspace +-- | Asks to stick @window@, which means that it will appear on all user +-- desktops. Note that you shouldn't assume the window is definitely stuck +-- afterward, because other entities (e.g. the user or window manager) could +-- unstick it again, and some window managers do not support sticking windows. +-- But normally the window will end up stuck. Just don't write code that +-- crashes if not. -- -windowStick :: WindowClass w => w -> IO () -windowStick w = {#call window_stick#} (toWindow w) +-- It's permitted to call this function before showing a window. +-- +-- You can track stickiness via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowStick :: WindowClass self => self -> IO () +windowStick self = + {# call window_stick #} + (toWindow self) --- | do not show the window on every workspace +-- | Asks to unstick @window@, which means that it will appear on only one of +-- the user's desktops. Note that you shouldn't assume the window is definitely +-- unstuck afterward, because other entities (e.g. the user or window manager) +-- could stick it again. But normally the window will end up stuck. Just don't +-- write code that crashes if not. -- -windowUnstick :: WindowClass w => w -> IO () -windowUnstick w = {#call window_unstick#} (toWindow w) +-- You can track stickiness via the \"window_state_event\" signal on +-- 'Widget'. +-- +windowUnstick :: WindowClass self => self -> IO () +windowUnstick self = + {# call window_unstick #} + (toWindow self) -------------------- -- Properties @@ -275,7 +441,7 @@ -- -- Default value: @True@ -- -windowResizable :: Attr Window Bool +windowResizable :: WindowClass self => Attr self Bool windowResizable = Attr windowGetResizable windowSetResizable @@ -285,17 +451,16 @@ -- | -- -onFrameEvent, afterFrameEvent :: WindowClass w => w -> (Event -> IO Bool) -> - IO (ConnectId w) +onFrameEvent, afterFrameEvent :: WindowClass self => self + -> (Event -> IO Bool) + -> IO (ConnectId self) onFrameEvent = connect_BOXED__BOOL "frame_event" marshalEvent False afterFrameEvent = connect_BOXED__BOOL "frame_event" marshalEvent True -- | -- -onSetFocus, afterSetFocus :: (WindowClass w, WidgetClass foc) => w -> - (foc -> IO ()) -> IO (ConnectId w) +onSetFocus, afterSetFocus :: (WindowClass self, WidgetClass foc) => self + -> (foc -> IO ()) + -> IO (ConnectId self) onSetFocus = connect_OBJECT__NONE "set_focus" False afterSetFocus = connect_OBJECT__NONE "set_focus" True - - - |