From: Andy S. <And...@co...> - 2010-03-22 12:13:53
|
Mon Mar 22 08:04:28 EDT 2010 Andy Stewart <laz...@gm...> * Update all `Windows` modules to Gtk+ 2.18.3 Ignore-this: 7f37b40f96e4bb0f7ddc58e93319a58 hunk ./ApiUpdateTodoList.txt 25 -*** TODO Assistant.chs +*** DONE Assistant.chs hunk ./ApiUpdateTodoList.txt 339 -** TODO Directory: gtk-modules/Graphics/UI/Gtk/Windows -*** TODO AboutDialog.chs.pp -*** TODO Dialog.chs.pp -*** TODO MessageDialog.chs.pp -*** TODO Window.chs.pp -*** TODO WindowGroup.chs +** DONE Directory: gtk-modules/Graphics/UI/Gtk/Windows +*** DONE AboutDialog.chs.pp +*** DONE Dialog.chs.pp +*** DONE MessageDialog.chs.pp +*** DONE Window.chs.pp +*** DONE WindowGroup.chs hunk ./Makefile.am 770 + gtk/Graphics/UI/Gtk/Windows/Assistant.chs.pp \ hunk ./gtk/Graphics/UI/Gtk.hs.pp 77 + module Graphics.UI.Gtk.Windows.Assistant, hunk ./gtk/Graphics/UI/Gtk.hs.pp 269 +import Graphics.UI.Gtk.Windows.Assistant hiding (close) hunk ./gtk/Graphics/UI/Gtk/Windows/AboutDialog.chs.pp 8 --- Copyright (C) 2005 Duncan Coutts +-- Copyright (C) 2005-2009 Duncan Coutts hunk ./gtk/Graphics/UI/Gtk/Windows/AboutDialog.chs.pp 29 +-- Note: +-- Use attributes instead below functions, so we con't bind them for simple: +-- gtk_about_dialog_get_program_name +-- gtk_about_dialog_set_program_name +-- Current FFI don't support varage functions: +-- gtk_show_about_dialog +-- hunk ./gtk/Graphics/UI/Gtk/Windows/AboutDialog.chs.pp 37 + hunk ./gtk/Graphics/UI/Gtk/Windows/AboutDialog.chs.pp 67 +-- addfile ./gtk/Graphics/UI/Gtk/Windows/Assistant.chs.pp hunk ./gtk/Graphics/UI/Gtk/Windows/Assistant.chs.pp 1 +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget Assistant +-- +-- Author : Andy Stewart +-- +-- Created: 22 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 : gtk...@li... +-- Stability : provisional +-- Portability : portable (depends on GHC) +-- +-- A widget used to guide users through multi-step operations +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Windows.Assistant ( hunk ./gtk/Graphics/UI/Gtk/Windows/Assistant.chs.pp 31 +-- * Detail +-- +-- | A 'Assistant' is a widget used to represent a generally complex operation +-- splitted in several steps, guiding the user through its pages and +-- controlling the page flow to collect the necessary data. + +-- ** GtkAssistant as GtkBuildable +-- +-- | The 'Assistant' implementation of the 'Buildable' interface exposes the +-- @actionArea@ as internal children with the name \"action_area\". +-- +-- To add pages to an assistant in 'Builder', simply add it as a \<child> to +-- the 'Assistant' object, and set its child properties as necessary. + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----'Object' +-- | +----'Widget' +-- | +----'Container' +-- | +----'Bin' +-- | +----'Window' +-- | +----Assistant +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + Assistant, + AssistantClass, + AssistantPage, + castToAssistant, + toAssistant, + +-- * Enums. + AssistantPageType(..), + +-- * Constructors + assistantNew, + +-- * Methods + assistantGetNPages, + assistantGetNthPage, + assistantPrependPage, + assistantAppendPage, + assistantInsertPage, + assistantSetForwardPageFunc, + assistantSetPageType, + assistantGetPageType, + assistantSetPageTitle, + assistantGetPageTitle, + assistantSetPageHeaderImage, + assistantGetPageHeaderImage, + assistantSetPageSideImage, + assistantGetPageSideImage, + assistantSetPageComplete, + assistantGetPageComplete, + assistantAddActionWidget, + assistantRemoveActionWidget, + assistantUpdateButtonsState, + assistantGetCurrentPage, + assistantSetCurrentPage, + +-- * Attributes + assistantCurrentPage, + +-- * Child Attributes + assistantChildPageType, + assistantChildTitle, + assistantChildHeaderImage, + assistantChildSidebarImage, + assistantChildComplete, + +-- * Signals + cancel, + prepare, + apply, + close, +#endif + ) where + +import Control.Monad (liftM, unless) + +import System.Glib.FFI +import System.Glib.UTFString +import System.Glib.Attributes +import System.Glib.Properties +import Graphics.UI.Gtk.Abstract.Object (makeNewObject) +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Types [_$_] +type AssistantPage = Int -> Int + +{#pointer AssistantPageFunc#} + +foreign import ccall "wrapper" mkAssistantPageFunc :: + (Ptr Assistant -> {#type glong#} -> Ptr () -> IO {#type glong#}) + -> IO AssistantPageFunc + +-------------------- +-- Interfaces + +-- instance BuildableClass Assistant + +-------------------- +-- Enum +{#enum GtkAssistantPageType as AssistantPageType {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-------------------- +-- Constructors + +-- | Creates a new 'Assistant'. +-- +assistantNew :: IO Assistant +assistantNew = + makeNewObject mkAssistant $ + liftM (castPtr :: Ptr Widget -> Ptr Assistant) $ + {# call gtk_assistant_new #} + +-------------------- +-- Methods + +assistantGetCurrentPage :: AssistantClass self => self + -> IO Int -- ^ returns The index (starting from 0) of the current page in the + -- @assistant@, if the @assistant@ has no pages, -1 will be returned +assistantGetCurrentPage self = + liftM fromIntegral $ + {# call gtk_assistant_get_current_page #} + (toAssistant self) + +assistantSetCurrentPage :: AssistantClass self => self + -> Int -- ^ @pageNum@ - index of the page to switch to, starting from 0. If + -- negative, the last page will be used. If greater than the number of + -- pages in the @assistant@, nothing will be done. + -> IO () +assistantSetCurrentPage self pageNum = + {# call gtk_assistant_set_current_page #} + (toAssistant self) + (fromIntegral pageNum) + +-- | Returns the number of pages in the @assistant@ +-- +assistantGetNPages :: AssistantClass self => self + -> IO Int -- ^ returns The number of pages in the @assistant@. +assistantGetNPages self = + liftM fromIntegral $ + {# call gtk_assistant_get_n_pages #} + (toAssistant self) + +-- | Returns the child widget contained in page number @pageNum@. +-- +assistantGetNthPage :: AssistantClass self => self + -> Int -- ^ @pageNum@ - The index of a page in the @assistant@, or -1 + -- to get the last page; + -> IO Widget -- ^ returns The child widget +assistantGetNthPage self pageNum = + makeNewObject mkWidget $ + {# call gtk_assistant_get_nth_page #} + (toAssistant self) + (fromIntegral pageNum) + +-- | Prepends a page to the @assistant@. +-- +assistantPrependPage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a 'Widget' + -> IO Int -- ^ returns the index (starting at 0) of the inserted page +assistantPrependPage self page = + liftM fromIntegral $ + {# call gtk_assistant_prepend_page #} + (toAssistant self) + (toWidget page) + +-- | Appends a page to the @assistant@. +-- +assistantAppendPage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a 'Widget' + -> IO Int -- ^ returns the index (starting at 0) of the inserted page +assistantAppendPage self page = + liftM fromIntegral $ + {# call gtk_assistant_append_page #} + (toAssistant self) + (toWidget page) + +-- | Inserts a page in the @assistant@ at a given position. +-- +assistantInsertPage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a 'Widget' + -> Int -- ^ @position@ - the index (starting at 0) at which to insert the + -- page, or -1 to append the page to the @assistant@ + -> IO Int -- ^ returns the index (starting from 0) of the inserted page +assistantInsertPage self page position = + liftM fromIntegral $ + {# call gtk_assistant_insert_page #} + (toAssistant self) + (toWidget page) + (fromIntegral position) + +-- | Sets the page forwarding function to be @pageFunc@, this function will be +-- used to determine what will be the next page when the user presses the +-- forward button. Setting @pageFunc@ to will make the assistant to use the +-- default forward function, which just goes to the next visible page. +-- +assistantSetForwardPageFunc :: AssistantClass self => self + -> Maybe AssistantPage -- ^ @pageFunc@ - the 'AssistantPage' + -> DestroyNotify -- ^ @destroy@ - destroy notifier for @data@ + -> IO () +assistantSetForwardPageFunc self pageFunc destroy = do + pfPtr <- case pageFunc of + Just pf -> mkAssistantPageFunc $ \_ c _ -> + return (fromIntegral (pf (fromIntegral c))) + Nothing -> return nullFunPtr + {# call gtk_assistant_set_forward_page_func #} + (toAssistant self) + pfPtr + nullPtr + destroy + unless (pfPtr == nullFunPtr) $ freeHaskellFunPtr pfPtr + +-- | Sets the page type for @page@. The page type determines the page behavior +-- in the @assistant@. +-- +assistantSetPageType :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> AssistantPageType -- ^ @type@ - the new type for @page@ + -> IO () +assistantSetPageType self page type_ = + {# call gtk_assistant_set_page_type #} + (toAssistant self) + (toWidget page) + ((fromIntegral . fromEnum) type_) + +-- | Gets the page type of @page@. +-- +assistantGetPageType :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO AssistantPageType -- ^ returns the page type of @page@. +assistantGetPageType self page = + liftM (toEnum . fromIntegral) $ + {# call gtk_assistant_get_page_type #} + (toAssistant self) + (toWidget page) + +-- | Sets a title for @page@. The title is displayed in the header area of the +-- assistant when @page@ is the current page. +-- +assistantSetPageTitle :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> String -- ^ @title@ - the new title for @page@ + -> IO () +assistantSetPageTitle self page title = + withUTFString title $ \titlePtr -> + {# call gtk_assistant_set_page_title #} + (toAssistant self) + (toWidget page) + titlePtr + +-- | Gets the title for @page@. +-- +assistantGetPageTitle :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO String -- ^ returns the title for @page@. +assistantGetPageTitle self page = + {# call gtk_assistant_get_page_title #} + (toAssistant self) + (toWidget page) + >>= peekUTFString + +-- | Sets a header image for @page@. This image is displayed in the header +-- area of the assistant when @page@ is the current page. +-- +assistantSetPageHeaderImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> Pixbuf -- ^ @pixbuf@ - the new header image @page@ + -> IO () +assistantSetPageHeaderImage self page pixbuf = + {# call gtk_assistant_set_page_header_image #} + (toAssistant self) + (toWidget page) + pixbuf + +-- | Gets the header image for @page@. +-- +assistantGetPageHeaderImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO Pixbuf -- ^ returns the header image for @page@ +assistantGetPageHeaderImage self page = + makeNewGObject mkPixbuf $ + {# call gtk_assistant_get_page_header_image #} + (toAssistant self) + (toWidget page) + +-- | Sets a header image for @page@. This image is displayed in the side area +-- of the assistant when @page@ is the current page. +-- +assistantSetPageSideImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> Pixbuf -- ^ @pixbuf@ - the new header image @page@ + -> IO () +assistantSetPageSideImage self page pixbuf = + {# call gtk_assistant_set_page_side_image #} + (toAssistant self) + (toWidget page) + pixbuf + +-- | Gets the header image for @page@. +-- +assistantGetPageSideImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO Pixbuf -- ^ returns the side image for @page@ +assistantGetPageSideImage self page = + makeNewGObject mkPixbuf $ + {# call gtk_assistant_get_page_side_image #} + (toAssistant self) + (toWidget page) + +-- | Sets whether @page@ contents are complete. This will make @assistant@ +-- update the buttons state to be able to continue the task. +-- +assistantSetPageComplete :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> Bool -- ^ @complete@ - the completeness status of the page + -> IO () +assistantSetPageComplete self page complete = + {# call gtk_assistant_set_page_complete #} + (toAssistant self) + (toWidget page) + (fromBool complete) + +-- | Gets whether @page@ is complete. +-- +assistantGetPageComplete :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO Bool -- ^ returns @True@ if @page@ is complete. +assistantGetPageComplete self page = + liftM toBool $ + {# call gtk_assistant_get_page_complete #} + (toAssistant self) + (toWidget page) + +-- | Adds a widget to the action area of a 'Assistant'. +-- +assistantAddActionWidget :: (AssistantClass self, WidgetClass child) => self + -> child -- ^ @child@ - a 'Widget' + -> IO () +assistantAddActionWidget self child = + {# call gtk_assistant_add_action_widget #} + (toAssistant self) + (toWidget child) + +-- | Removes a widget from the action area of a 'Assistant'. +-- +assistantRemoveActionWidget :: (AssistantClass self, WidgetClass child) => self + -> child -- ^ @child@ - a 'Widget' + -> IO () +assistantRemoveActionWidget self child = + {# call gtk_assistant_remove_action_widget #} + (toAssistant self) + (toWidget child) + +-- | Forces @assistant@ to recompute the buttons state. +-- +-- Gtk+ automatically takes care of this in most situations, e.g. when the +-- user goes to a different page, or when the visibility or completeness of a +-- page changes. +-- +-- One situation where it can be necessary to call this function is when +-- changing a value on the current page affects the future page flow of the +-- assistant. +-- +assistantUpdateButtonsState :: AssistantClass self => self -> IO () +assistantUpdateButtonsState self = + {# call gtk_assistant_update_buttons_state #} + (toAssistant self) + +-------------------- +-- Attributes + +-- | Switches the page to @pageNum@. Note that this will only be necessary in +-- custom buttons, as the @assistant@ flow can be set with +-- 'assistantSetForwardPageFunc'. +-- +-- Returns the page number of the current page +-- +-- TODO: merge attr docs from those of the setter and getter methods +-- +assistantCurrentPage :: AssistantClass self => Attr self Int +assistantCurrentPage = newAttr + assistantGetCurrentPage + assistantSetCurrentPage + +-------------------- +-- Child Attributes + +-- | The type of the assistant page. +-- +-- Default value: 'AssistantPageContent' +-- +assistantChildPageType :: AssistantClass self => Attr self AssistantPageType +assistantChildPageType = [_$_] + newAttrFromEnumProperty "page-type" {#call pure unsafe assistant_page_type_get_type#} + +-- | The title that is displayed in the page header. +-- +-- If title and header-image are both, no header is displayed. +-- +assistantChildTitle :: AssistantClass self => Attr self String +assistantChildTitle = newAttrFromStringProperty "title" + +-- | The image that is displayed next to the page. +-- +assistantChildHeaderImage :: AssistantClass self => Attr self Pixbuf +assistantChildHeaderImage = newAttrFromObjectProperty "header-image" + {# call pure unsafe gdk_pixbuf_get_type #} + +-- | Sidebar image for the assistant page. +-- +assistantChildSidebarImage :: AssistantClass self => Attr self Pixbuf +assistantChildSidebarImage = newAttrFromObjectProperty "sidebar-image" + {# call pure unsafe gdk_pixbuf_get_type #} + +-- | Setting the \"complete\" child property to @True@ marks a page as +-- complete (i.e.: all the required fields are filled out). Gtk+ uses this +-- information to control the sensitivity of the navigation buttons. +-- +-- Default value: @False@ +-- +assistantChildComplete :: AssistantClass self => Attr self Bool +assistantChildComplete = newAttrFromBoolProperty "complete" + +-------------------- +-- Signals + +-- | The ::cancel signal is emitted when then the cancel button is clicked. +-- +cancel :: AssistantClass self => Signal self (IO ()) +cancel = Signal (connect_NONE__NONE "cancel") + +-- | The ::prepare signal is emitted when a new page is set as the assistant's +-- current page, before making the new page visible. A handler for this signal +-- can do any preparation which are necessary before showing @page@. +-- +prepare :: AssistantClass self => Signal self (Widget -> IO ()) +prepare = Signal (connect_OBJECT__NONE "prepare") + +-- | The ::apply signal is emitted when the apply button is clicked. The +-- default behavior of the 'Assistant' is to switch to the page after the +-- current page, unless the current page is the last one. +-- +-- A handler for the ::apply signal should carry out the actions for which +-- the wizard has collected data. If the action takes a long time to complete, +-- you might consider to put a page of type 'AssistantPageProgress' after the +-- confirmation page and handle this operation within the 'prepare' signal of the progress page. +-- +apply :: AssistantClass self => Signal self (IO ()) +apply = Signal (connect_NONE__NONE "apply") + +-- | The ::close signal is emitted either when the close button of a summary +-- page is clicked, or when the apply button in the last page in the flow (of +-- type 'AssistantPageConfirm') is clicked. +-- +close :: AssistantClass self => Signal self (IO ()) +close = Signal (connect_NONE__NONE "close") +#endif hunk ./gtk/Graphics/UI/Gtk/Windows/Dialog.chs.pp 29 --- Now FFI haven't support variadic function `gtk_dialog_set_alternative_button_order` +-- Now FFI haven't support variadic function, below are functons list: [_$_] +-- gtk_dialog_new_with_buttons +-- gtk_dialog_add_buttons +-- gtk_dialog_set_alternative_button_order hunk ./gtk/Graphics/UI/Gtk/Windows/Dialog.chs.pp 111 +#if GTK_CHECK_VERSION(2,14,0) + dialogGetContentArea, +#endif hunk ./gtk/Graphics/UI/Gtk/Windows/Dialog.chs.pp 207 +#if GTK_CHECK_VERSION(2,14,0) +-- | Returns the content area of @dialog@. +-- +-- * Available since Gtk+ version 2.14 +-- +dialogGetContentArea :: DialogClass self => self + -> IO Widget -- ^ returns the content area 'VBox'. +dialogGetContentArea self = + makeNewObject mkWidget $ + {# call gtk_dialog_get_content_area #} + (toDialog self) +#endif + hunk ./gtk/Graphics/UI/Gtk/Windows/Dialog.chs.pp 433 + hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 32 +-- hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 43 + InvisibleClass, + castToInvisible, + toInvisible, hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 48 - invisibleNew, [_$_] + invisibleNew, +#if GTK_CHECK_VERSION(2,2,0) hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 51 +#endif + +-- * Attributes + invisibleScreen, hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 87 +#if GTK_CHECK_VERSION(2,2,0) hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 99 - [_$_] +#endif [_$_] + hunk ./gtk/Graphics/UI/Gtk/Windows/Invisible.chs.pp 121 +-------------------- +-- Attributes + +-- | +-- +invisibleScreen :: InvisibleClass self => Attr self Screen +invisibleScreen = newAttrFromObjectProperty "screen" + {# call pure unsafe gdk_screen_get_type #} hunk ./gtk/Graphics/UI/Gtk/Windows/MessageDialog.chs.pp 8 --- Copyright (C) 2006 Axel Simon +-- Copyright (C) 2006-2009 Axel Simon hunk ./gtk/Graphics/UI/Gtk/Windows/MessageDialog.chs.pp 29 + hunk ./gtk/Graphics/UI/Gtk/Windows/MessageDialog.chs.pp 43 +-- hunk ./gtk/Graphics/UI/Gtk/Windows/Window.chs.pp 31 +-- hunk ./gtk/Graphics/UI/Gtk/Windows/WindowGroup.chs.pp 8 --- Copyright (C) 2005 Duncan Coutts +-- Copyright (C) 2005-2009 Duncan Coutts hunk ./gtk/Graphics/UI/Gtk/Windows/WindowGroup.chs.pp 30 +-- hunk ./tools/hierarchyGen/hierarchy.list 83 + GtkAssistant |