You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
(68) |
Aug
(4) |
Sep
|
Oct
(23) |
Nov
(95) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
|
Mar
|
Apr
(51) |
May
(81) |
Jun
(2) |
Jul
(86) |
Aug
(143) |
Sep
(3) |
Oct
(31) |
Nov
(63) |
Dec
(90) |
2005 |
Jan
(277) |
Feb
(157) |
Mar
(99) |
Apr
(195) |
May
(151) |
Jun
(148) |
Jul
(98) |
Aug
(123) |
Sep
(20) |
Oct
(174) |
Nov
(155) |
Dec
(26) |
2006 |
Jan
(51) |
Feb
(19) |
Mar
(16) |
Apr
(12) |
May
(5) |
Jun
|
Jul
(11) |
Aug
(7) |
Sep
(10) |
Oct
(31) |
Nov
(174) |
Dec
(56) |
2007 |
Jan
(45) |
Feb
(52) |
Mar
(10) |
Apr
(5) |
May
(47) |
Jun
(16) |
Jul
(80) |
Aug
(29) |
Sep
(14) |
Oct
(59) |
Nov
(46) |
Dec
(16) |
2008 |
Jan
(10) |
Feb
(1) |
Mar
|
Apr
|
May
(49) |
Jun
(26) |
Jul
(8) |
Aug
(4) |
Sep
(25) |
Oct
(53) |
Nov
(9) |
Dec
(1) |
2009 |
Jan
(66) |
Feb
(11) |
Mar
(1) |
Apr
(14) |
May
(8) |
Jun
(1) |
Jul
(2) |
Aug
(2) |
Sep
(9) |
Oct
(23) |
Nov
(35) |
Dec
|
2010 |
Jan
(7) |
Feb
(2) |
Mar
(39) |
Apr
(19) |
May
(161) |
Jun
(19) |
Jul
(32) |
Aug
(65) |
Sep
(113) |
Oct
(120) |
Nov
(2) |
Dec
|
2012 |
Jan
|
Feb
(5) |
Mar
(4) |
Apr
(7) |
May
(9) |
Jun
(14) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(12) |
Dec
(2) |
2013 |
Jan
(1) |
Feb
(17) |
Mar
(4) |
Apr
(4) |
May
(9) |
Jun
|
Jul
(8) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Andy S. <And...@co...> - 2010-09-23 02:06:54
|
diffing dir... Wed Sep 22 22:02:54 EDT 2010 Andy Stewart <laz...@gm...> * Update TODO info Ignore-this: 1689fc10b19b72ef8a69fbaf8f83fa9d { hunk ./TODO 1 -Missing modules in GTK+-2.18: - -gtk/Graphics/UI/Gtk/Gdk/PixbufLoader.chs - -Missing functions in GTK+-2.20: - -gtk_tool_palette_add_drag_dest, function in GtkToolPalette -gtk_tool_palette_get_drag_item, function in GtkToolPalette -gtk_tool_palette_get_drag_target_group, function in GtkToolPalette -gtk_tool_palette_get_drag_target_item, function in GtkToolPalette -gtk_tool_palette_get_drop_group, function in GtkToolPalette -gtk_tool_palette_get_drop_item, function in GtkToolPalette rmfile ./TODO hunk ./gtk/Graphics/UI/Gtk/MenuComboToolbar/ToolPalette.chs 30 +-- TODO: +-- +-- gtk_tool_palette_add_drag_dest +-- gtk_tool_palette_get_drag_item +-- gtk_tool_palette_get_drag_target_group +-- gtk_tool_palette_get_drag_target_item +-- gtk_tool_palette_get_drop_group +-- gtk_tool_palette_get_drop_item +-- } |
From: Andy S. <And...@co...> - 2010-09-23 01:59:01
|
diffing dir... Wed Sep 22 21:58:15 EDT 2010 Andy Stewart <laz...@gm...> * Use g_free free array pointer Ignore-this: 5517e2a623d17112c76ae6f1208e697 { hunk ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs 238 --- mask. The returned array should be freed with 'gFree'. +-- mask. [_$_] hunk ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs 258 + {#call unsafe g_free#} (castPtr keysPtr) hunk ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs 263 --- in @keys@ is bound to the Nth keyval in @keyvals@. Free --- the returned arrays with 'gFree'. When a keycode is pressed by the user, the +-- in @keys@ is bound to the Nth keyval in @keyvals@. [_$_] +-- When a keycode is pressed by the user, the hunk ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs 289 + {#call unsafe g_free#} (castPtr keysPtr) + {#call unsafe g_free#} (castPtr keyvalsPtr) } |
From: Andy S. <And...@co...> - 2010-09-23 01:58:57
|
diffing dir... Wed Sep 22 21:54:28 EDT 2010 Andy Stewart <laz...@gm...> * Update module Gdk.Keys Ignore-this: f82a54d2436d284cd0c7709cbfd942eb { hunk ./gtk/Graphics/UI/Gtk/Gdk/Keys.chs 40 + keyvalConvertCase, + keyvalToUpper, + keyvalToLower, + keyvalIsUpper, + keyvalIsLower, hunk ./gtk/Graphics/UI/Gtk/Gdk/Keys.chs 95 + +-- | Obtains the upper- and lower-case versions of the keyval symbol. Examples of keyvals are GDK_a, +-- 'Enter', 'F1', etc. +keyvalConvertCase :: KeyVal -- ^ @symbol@ a keyval [_$_] + -> (KeyVal, KeyVal) -- ^ @(lower, upper)@ [_$_] + -- ^ lower is the lowercase version of symbol. [_$_] + -- ^ upper is uppercase version of symbol. [_$_] +keyvalConvertCase keyval = [_$_] + unsafePerformIO $ + alloca $ \ lowerPtr -> [_$_] + alloca $ \ upperPtr -> do + {#call gdk_keyval_convert_case #} + (fromIntegral keyval) + lowerPtr + upperPtr + lower <- peek lowerPtr + upper <- peek upperPtr + return (fromIntegral lower, fromIntegral upper) + +-- | Converts a key value to upper case, if applicable. +keyvalToUpper :: KeyVal -- ^ @keyval@ a key value. + -> KeyVal -- ^ returns the upper case form of keyval, [_$_] + -- or keyval itself if it is already in upper case or it is not subject to case [_$_] +keyvalToUpper keyval = + unsafePerformIO $ + liftM fromIntegral $ + {#call gdk_keyval_to_upper #} + (fromIntegral keyval) + +-- | Converts a key value to lower case, if applicable. +keyvalToLower :: KeyVal -- ^ @keyval@ a key value. + -> KeyVal -- ^ returns the lower case form of keyval, [_$_] + -- or keyval itself if it is already in lower case or it is not subject to case [_$_] +keyvalToLower keyval = + unsafePerformIO $ + liftM fromIntegral $ + {#call gdk_keyval_to_lower #} + (fromIntegral keyval) + +-- | Returns 'True' if the given key value is in upper case. +keyvalIsLower :: KeyVal [_$_] + -> Bool -- ^ returns 'True' if keyval is in upper case, or if keyval is not subject to case conversion. +keyvalIsLower keyval = + unsafePerformIO $ + liftM toBool $ + {#call gdk_keyval_is_lower #} + (fromIntegral keyval) + +-- | Returns 'True' if the given key value is in upper case. +keyvalIsUpper :: KeyVal [_$_] + -> Bool -- ^ returns 'True' if keyval is in upper case, or if keyval is not subject to case conversion. +keyvalIsUpper keyval = + unsafePerformIO $ + liftM toBool $ + {#call gdk_keyval_is_upper #} + (fromIntegral keyval) + } |
From: Andy S. <And...@co...> - 2010-09-23 01:58:56
|
diffing dir... Wed Sep 22 21:53:44 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Gdk.Keymap Ignore-this: 6c227925f91e0cc6d598f7c03fb5e1ff { hunk ./TODO 3 -gtk/Graphics/UI/Gtk/Gdk/Keymap.chs hunk ./TODO 4 -gtk/Graphics/UI/Gtk/Gdk/Visual.chs hunk ./gtk/Graphics/UI/Gtk.chs 66 + module Graphics.UI.Gtk.Gdk.Keymap, hunk ./gtk/Graphics/UI/Gtk.chs 295 +import Graphics.UI.Gtk.Gdk.Keymap addfile ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs hunk ./gtk/Graphics/UI/Gtk/Gdk/Keymap.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget Keymap +-- +-- Author : Andy Stewart +-- +-- Created: 30 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) +-- +-- Functions for manipulating keyboard codes +-- +module Graphics.UI.Gtk.Gdk.Keymap ( + +-- * Details +-- [_$_] +-- | Key values are the codes which are sent whenever a key is pressed or released. They appear in the +-- keyval field of the 'EventKey' structure, which is passed to signal handlers for the +-- 'keyPressEvent' and 'keyReleaseEvent' signals. [_$_] +-- [_$_] +-- Key values are regularly updated from the upstream X.org X11 implementation, so new values are added +-- regularly. They will be prefixed with GDK_ rather than XF86XK_ or ' (for older symbols)'. +-- [_$_] +-- Key values can be converted into a string representation using 'keyvalName'. The reverse +-- function, converting a string to a key value, is provided by 'keyvalFromName'. +-- [_$_] +-- The case of key values can be determined using 'keyvalIsUpper'. Key +-- values can be converted to upper or lower case using 'keyvalToUpper' and +-- 'keyvalToLower'. +-- [_$_] +-- When it makes sense, key values can be converted to and from Unicode characters with +-- 'keyvalToUnicode'. +-- [_$_] +-- One 'Keymap' object exists for each user display. 'keymapGetDefault' returns the 'Keymap' +-- for the default display; to obtain keymaps for other displays, use 'keymapGetForDisplay'. A +-- keymap is a mapping from 'KeymapKey' to key values. You can think of a 'KeymapKey' as a +-- representation of a symbol printed on a physical keyboard key. That is, it contains three pieces of +-- information. First, it contains the hardware keycode; this is an identifying number for a physical +-- key. Second, it contains the level of the key. The level indicates which symbol on the key will be +-- used, in a vertical direction. So on a standard US keyboard, the key with the number \"1\" on it also +-- has the exclamation point \"!\" character on it. The level indicates whether to use the \"1\" or the +-- \"!\" symbol. The letter keys are considered to have a lowercase letter at level 0, and an uppercase +-- letter at level 1, though only the uppercase letter is printed. Third, the 'KeymapKey' contains a +-- group; groups are not used on standard US keyboards, but are used in many other countries. On a +-- keyboard with groups, there can be 3 or 4 symbols printed on a single key. The group indicates +-- movement in a horizontal direction. Usually groups are used for two different languages. In group 0, +-- a key might have two English characters, and in group 1 it might have two Hebrew characters. The +-- Hebrew characters will be printed on the key next to the English characters. +-- [_$_] +-- In order to use a keymap to interpret a key event, it's necessary to first convert the keyboard +-- state into an effective group and level. This is done via a set of rules that varies widely +-- according to type of keyboard and user configuration. The function +-- 'keymapTranslateKeyboardState' accepts a keyboard state -- consisting of hardware keycode +-- pressed, active modifiers, and active group -- applies the appropriate rules, and returns the +-- group/level to be used to index the keymap, along with the modifiers which did not affect the group +-- and level. i.e. it returns "unconsumed modifiers." The keyboard group may differ from the effective +-- group used for keymap lookups because some keys don't have multiple groups - e.g. the Enter key is +-- always in group 0 regardless of keyboard state. +-- [_$_] +-- Note that 'keymapTranslateKeyboardState' also returns the keyval, i.e. it goes ahead and +-- performs the keymap lookup in addition to telling you which effective group/level values were used +-- for the lookup. 'EventKey' already contains this keyval, however, so you don't normally need to +-- call 'keymapTranslateKeyboardState' just to get the keyval. + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----Keymap +-- @ + +-- * Types + Keymap, + KeymapClass, + castToKeymap, + toKeymap, + KeymapKey, + +-- * Methods + keymapGetDefault, +#if GTK_CHECK_VERSION(2,2,0) + keymapGetForDisplay, +#endif + keymapLookupKey, + keymapTranslateKeyboardState, + keymapGetEntriesForKeyval, + keymapGetEntriesForKeycode, + keymapGetDirection, +#if GTK_CHECK_VERSION(2,12,0) + keymapHaveBidiLayouts, +#endif +#if GTK_CHECK_VERSION(2,16,0) + keymapGetCapsLockState, +#endif + +-- * Signals +#if GTK_CHECK_VERSION(2,0,0) + keymapDirectionChanged, +#if GTK_CHECK_VERSION(2,2,0) + keymapKeysChanged, +#if GTK_CHECK_VERSION(2,16,0) + keymapStateChanged, +#endif +#endif +#endif + ) where + +import Control.Monad (liftM) +import Data.Maybe (fromMaybe) +import System.Glib.FFI +import System.Glib.UTFString +import Graphics.UI.Gtk.Gdk.Enums (Modifier(..)) +import Graphics.UI.Gtk.Gdk.Keys (KeyVal (..)) +{#import Graphics.Rendering.Pango.Enums#} +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} +import Graphics.UI.Gtk.General.Structs (KeymapKey (..)) + +{# context lib="gdk" prefix="gdk" #} + +-------------------- +-- Methods + +-- | Returns the 'Keymap' attached to the default display. +-- +keymapGetDefault :: + IO Keymap -- ^ returns the 'Keymap' attached to the default display. +keymapGetDefault = + constructNewGObject mkKeymap $ + {# call gdk_keymap_get_default #} + +#if GTK_CHECK_VERSION(2,2,0) +-- | Returns the 'Keymap' attached to @display@. +-- +-- * Available since Gdk version 2.2 +-- +keymapGetForDisplay :: + Display -- ^ @display@ - the 'Display'. + -> IO Keymap -- ^ returns the 'Keymap' attached to @display@. +keymapGetForDisplay display = + makeNewGObject mkKeymap $ + {# call gdk_keymap_get_for_display #} + display +#endif + +-- | Looks up the keyval mapped to a keycode\/group\/level triplet. If no +-- keyval is bound to @key@, returns 0. For normal user input, you want to use +-- 'keymapTranslateKeyboardState' instead of this function, since the effective +-- group\/level may not be the same as the current keyboard state. +-- +keymapLookupKey :: KeymapClass self [_$_] + => (Maybe self) -- ^ @keymap@ a 'Keymap' or 'Nothing' to use the default keymap [_$_] + -> KeymapKey -- ^ @key@ - a 'KeymapKey' + -- with keycode, group, and level initialized + -> IO Int -- ^ returns a keyval, or 0 if none was mapped to + -- the given @key@ +keymapLookupKey Nothing key = [_$_] + liftM fromIntegral $ + allocaBytes {# sizeof GdkKeymapKey #} $ \ keyPtr -> do + poke keyPtr key + {# call gdk_keymap_lookup_key #} + (Keymap nullForeignPtr) + (castPtr keyPtr) [_$_] +keymapLookupKey (Just self) key = + liftM fromIntegral $ + allocaBytes {# sizeof GdkKeymapKey #} $ \ keyPtr -> do + poke keyPtr key + {# call gdk_keymap_lookup_key #} + (toKeymap self) + (castPtr keyPtr) [_$_] + +-- | Translates the contents of a 'EventKey' into a +-- keyval, effective group, and level. Modifiers that affected the translation +-- and are thus unavailable for application use are returned in +-- @consumedModifiers@. See 'keyvalGetKeys' for an explanation of groups and +-- levels. The @effectiveGroup@ is the group that was actually used for the +-- translation; some keys such as Enter are not affected by the active keyboard +-- group. The @level@ is derived from @state@. For convenience, 'EventKey' +-- already contains the translated keyval, so this function +-- isn't as useful as you might think. +-- +keymapTranslateKeyboardState :: KeymapClass self => self + -> Int -- ^ @hardwareKeycode@ - a keycode + -> Modifier -- ^ @state@ - a modifier state + -> Int -- ^ @group@ - active keyboard group + -> IO (Maybe (Int, Int, Int, Modifier)) +keymapTranslateKeyboardState self hardwareKeycode state group = + alloca $ \keyvalPtr -> + alloca $ \effectiveGroupPtr -> + alloca $ \levelPtr -> [_$_] + alloca $ \modifierPtr -> do + success <- liftM toBool $ + {# call gdk_keymap_translate_keyboard_state #} + (toKeymap self) + (fromIntegral hardwareKeycode) + ((fromIntegral . fromEnum) state) + (fromIntegral group) + keyvalPtr + effectiveGroupPtr + levelPtr + modifierPtr + if success [_$_] + then do + keyval <- peek keyvalPtr + effectiveGroup <- peek effectiveGroupPtr + level <- peek levelPtr + modifier <- peek modifierPtr + return (Just (fromIntegral keyval + ,fromIntegral effectiveGroup + ,fromIntegral level + ,toEnum $ fromIntegral modifier)) + else return Nothing + +-- | Obtains a list of keycode\/group\/level combinations that will generate +-- @keyval@. Groups and levels are two kinds of keyboard mode; in general, the +-- level determines whether the top or bottom symbol on a key is used, and the +-- group determines whether the left or right symbol is used. On US keyboards, +-- the shift key changes the keyboard level, and there are no groups. A group +-- switch key might convert a keyboard between Hebrew to English modes, for +-- example. 'EventKey' contains a @group@ field that +-- indicates the active keyboard group. The level is computed from the modifier +-- mask. The returned array should be freed with 'gFree'. +-- +keymapGetEntriesForKeyval :: KeymapClass self => self + -> KeyVal -- ^ @keyval@ - a keyval, such as @GDK_a@, @GDK_Up@, + -- @GDK_Return@, etc. + -> IO (Maybe [KeymapKey]) +keymapGetEntriesForKeyval self keyval = + alloca $ \nKeysPtr -> + allocaArray 0 $ \ keysPtr -> do + success <- liftM toBool $ + {# call gdk_keymap_get_entries_for_keyval #} + (toKeymap self) + (fromIntegral keyval) + (castPtr keysPtr) + nKeysPtr + if success + then do + nKeys <- liftM fromIntegral $ peek nKeysPtr + keys <- peekArray nKeys keysPtr + keyList <- mapM peek keys + return (Just keyList) + else return Nothing + +-- | Returns the keyvals bound to @hardwareKeycode@. The Nth 'KeymapKey' +-- in @keys@ is bound to the Nth keyval in @keyvals@. Free +-- the returned arrays with 'gFree'. When a keycode is pressed by the user, the +-- keyval from this list of entries is selected by considering the effective +-- keyboard group and level. See 'keymapTranslateKeyboardState'. +-- +keymapGetEntriesForKeycode :: KeymapClass self => self + -> Int -- ^ @hardwareKeycode@ - a keycode + -> IO (Maybe ([KeymapKey], [KeyVal])) +keymapGetEntriesForKeycode self hardwareKeycode = + alloca $ \nEntriesPtr -> + allocaArray 0 $ \ keysPtr -> [_$_] + allocaArray 0 $ \ keyvalsPtr -> do + success <- liftM toBool $ + {# call gdk_keymap_get_entries_for_keycode #} + (toKeymap self) + (fromIntegral hardwareKeycode) + (castPtr keysPtr) + keyvalsPtr + nEntriesPtr + if success + then do + nEntries <- liftM fromIntegral $ peek nEntriesPtr + keys <- peekArray nEntries keysPtr + keyvals <- peekArray nEntries keyvalsPtr + keyvalsList <- mapM (\x -> liftM fromIntegral $ peek x) keyvals + keysList <- mapM peek keys + return (Just (keysList, keyvalsList)) + else return Nothing + +-- | Returns the direction of effective layout of the keymap. +-- +-- Returns the direction of the keymap. +-- +keymapGetDirection :: KeymapClass self => self + -> IO PangoDirection -- ^ returns 'DirectionLtr' or 'DirectionRtl' if it can + -- determine the direction. 'DirectionNeutral' otherwise. +keymapGetDirection self = + liftM (toEnum . fromIntegral) $ + {# call gdk_keymap_get_direction #} + (toKeymap self) + +#if GTK_CHECK_VERSION(2,12,0) +-- | Determines if keyboard layouts for both right-to-left and left-to-right +-- languages are in use. +-- +-- * Available since Gdk version 2.12 +-- +keymapHaveBidiLayouts :: KeymapClass self => self + -> IO Bool -- ^ returns @True@ if there are layouts in both directions, + -- @False@ otherwise +keymapHaveBidiLayouts self = + liftM toBool $ + {# call gdk_keymap_have_bidi_layouts #} + (toKeymap self) +#endif + +#if GTK_CHECK_VERSION(2,16,0) +-- | Returns whether the Caps Lock modifer is locked. +-- +-- * Available since Gdk version 2.16 +-- +keymapGetCapsLockState :: KeymapClass self => self + -> IO Bool -- ^ returns @True@ if Caps Lock is on +keymapGetCapsLockState self = + liftM toBool $ + {# call gdk_keymap_get_caps_lock_state #} + (toKeymap self) +#endif + +-------------------- +-- Signals + +#if GTK_CHECK_VERSION(2,0,0) +-- | The 'keymapDirectionChanged' signal gets emitted when the direction of the +-- keymap changes. +-- +-- * Available since Gdk version 2.0 +-- +keymapDirectionChanged :: KeymapClass self => Signal self (IO ()) +keymapDirectionChanged = Signal (connect_NONE__NONE "direction_changed") + +#if GTK_CHECK_VERSION(2,2,0) +-- | The 'keymapKeysChanged' signal is emitted when the mapping represented by +-- @keymap@ changes. +-- +-- * Available since Gdk version 2.2 +-- +keymapKeysChanged :: KeymapClass self => Signal self (IO ()) +keymapKeysChanged = Signal (connect_NONE__NONE "keys_changed") + +#if GTK_CHECK_VERSION(2,16,0) +-- | The 'keymapStateChanged' signal is emitted when the state of the keyboard +-- changes, e.g when Caps Lock is turned on or off. See +-- 'keymapGetCapsLockState'. +-- +-- * Available since Gdk version 2.16 +-- +keymapStateChanged :: KeymapClass self => Signal self (IO ()) +keymapStateChanged = Signal (connect_NONE__NONE "state_changed") +#endif +#endif +#endif + hunk ./gtk/Graphics/UI/Gtk/General/Structs.hsc 103 - withTargetEntries + withTargetEntries, + KeymapKey (..) hunk ./gtk/Graphics/UI/Gtk/General/Structs.hsc 1006 +-- | A 'KeymapKey' is a hardware key that can be mapped to a keyval. +data KeymapKey = KeymapKey { + keycode :: Int -- ^ @keycode@ the hardware keycode. This is an identifying number for a physical key. + ,group :: Int -- ^ @group@ indicates movement in a horizontal direction. [_$_] + -- Usually groups are used for two different languages. [_$_] + -- In group 0, a key might have two English characters, [_$_] + -- and in group 1 it might have two Hebrew characters. [_$_] + -- The Hebrew characters will be printed on the key next to the English characters. [_$_] + -- indicates which symbol on the key will be used, [_$_] + -- in a vertical direction. So on a standard US keyboard, the [_$_] + ,level :: Int -- ^ @level@ key with the number "1" on it also has the exclamation [_$_] + -- point ("!") character on it. The level + -- indicates whether to use the "1" or the "!" symbol. The letter keys are considered to + -- have a lowercase letter at level 0, and an uppercase letter at level 1, though only + -- the uppercase letter is printed. + } deriving (Eq, Show) [_$_] + [_$_] +instance Storable KeymapKey where + sizeOf _ = #{const sizeof(GdkKeymapKey)} + alignment _ = alignment (undefined::#gtk2hs_type gint) + peek ptr = do + (keycode_ ::#gtk2hs_type guint) <- #{peek GdkKeymapKey, keycode} ptr + (group_ ::#gtk2hs_type gint) <- #{peek GdkKeymapKey, group} ptr + (level_ ::#gtk2hs_type gint) <- #{peek GdkKeymapKey, level} ptr + return $ KeymapKey (fromIntegral keycode_) (fromIntegral group_) (fromIntegral level_) + poke ptr (KeymapKey keycode group level) = do + #{poke GdkKeymapKey, keycode} ptr ((fromIntegral keycode)::#gtk2hs_type guint) + #{poke GdkKeymapKey, group} ptr ((fromIntegral group)::#gtk2hs_type gint) + #{poke GdkKeymapKey, level} ptr ((fromIntegral level)::#gtk2hs_type gint) + [_$_] + [_$_] hunk ./gtk/gtk.cabal 187 + Graphics.UI.Gtk.Gdk.Keymap hunk ./gtk/hierarchy.list 25 + GdkKeymap if gtk-2.2 } |
From: Andy S. <And...@co...> - 2010-09-23 00:17:53
|
diffing dir... Wed Sep 22 19:59:39 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Gdk.DisplayManager Ignore-this: d74b9f04264c03c88e6a1778085745ac { hunk ./TODO 3 -gtk/Graphics/UI/Gtk/Gdk/DisplayManager.chs hunk ./gtk/Graphics/UI/Gtk.chs 67 + module Graphics.UI.Gtk.Gdk.DisplayManager, hunk ./gtk/Graphics/UI/Gtk.chs 295 +import Graphics.UI.Gtk.Gdk.DisplayManager addfile ./gtk/Graphics/UI/Gtk/Gdk/DisplayManager.chs hunk ./gtk/Graphics/UI/Gtk/Gdk/DisplayManager.chs 1 +{-# LANGUAGE CPP #-} +-- -*-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 : gtk...@li... +-- 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 ( hunk ./gtk/Graphics/UI/Gtk/Gdk/DisplayManager.chs 32 +-- * 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 +-- @ + +#if GTK_CHECK_VERSION(2,2,0) +-- * Types + DisplayManager, + DisplayManagerClass, + castToDisplayManager, + toDisplayManager, + +-- * Methods + displayManagerGet, + displayManagerListDisplays, + +-- * Attributes + displayManagerDefaultDisplay, + +-- * Signals + displayManagerOpened, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.GList +import System.Glib.GObject (constructNewGObject, makeNewGObject) +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} + +{# context lib="gdk" prefix="gdk" #} + +#if GTK_CHECK_VERSION(2,2,0) +-------------------- +-- Methods + +-- | Returns the global 'DisplayManager' singleton; 'parsePargs', 'init', or +-- 'initCheck' must have been called first. +-- +displayManagerGet :: IO DisplayManager -- ^ returns the singleton 'DisplayManager' object. +displayManagerGet = + constructNewGObject mkDisplayManager $ + {# call gdk_display_manager_get #} + +-- | List all currently open displays. +-- +displayManagerListDisplays :: DisplayManagerClass self => self + -> IO [Display] -- ^ returns a newly allocated list of 'Display' objects. [_$_] +displayManagerListDisplays self = + {# call gdk_display_manager_list_displays #} + (toDisplayManager self) + >>= fromGSList + >>= mapM (makeNewGObject mkDisplay . return) + +-------------------- +-- Attributes + +-- | The default display. +-- +displayManagerDefaultDisplay :: DisplayManagerClass self => Attr self Display +displayManagerDefaultDisplay = newAttrFromObjectProperty "default-display" + {# call pure unsafe gdk_display_get_type #} + +-------------------- +-- Signals + +-- | The 'displayManagerOpened' signal is emitted when a display is opened. +-- +displayManagerOpened :: DisplayManagerClass self => Signal self (Display -> IO ()) +displayManagerOpened = Signal (connect_OBJECT__NONE "display_opened") +#endif hunk ./gtk/gtk.cabal 188 + Graphics.UI.Gtk.Gdk.DisplayManager hunk ./gtk/hierarchy.list 25 + GdkDisplayManager if gtk-2.2 } |
From: Andy S. <And...@co...> - 2010-09-22 23:48:49
|
diffing dir... Wed Sep 22 19:48:30 EDT 2010 Andy Stewart <laz...@gm...> * Add printOpt prefix for PrintOperation signal Ignore-this: b83b481f7e52270e93c14a853c058c29 { hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 136 - done, - beginPrint, - paginate, - requestPageSetup, - drawPage, - endPrint, - statusChanged, - createCustomWidget, + printOptDone, + printOptBeginPrint, + printOptPaginate, + printOptRequestPageSetup, + printOptDrawPage, + printOptEndPrint, + printOptStatusChanged, + printOptCreateCustomWidget, hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 145 - updateCustomWidget, + printOptUpdateCustomWidget, hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 147 - customWidgetApply, - preview, - ready, - gotPageSize, + printOptCustomWidgetApply, + printOptPreview, + printOptReady, + printOptGotPageSize, hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 798 -done :: PrintOperationClass self => Signal self (PrintOperationResult -> IO ()) -done = Signal (connect_ENUM__NONE "done") +printOptDone :: PrintOperationClass self => Signal self (PrintOperationResult -> IO ()) +printOptDone = Signal (connect_ENUM__NONE "done") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 808 -beginPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) -beginPrint = Signal (connect_OBJECT__NONE "begin_print") +printOptBeginPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) +printOptBeginPrint = Signal (connect_OBJECT__NONE "begin_print") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 824 -paginate :: PrintOperationClass self => Signal self (PrintContext -> IO Bool) -paginate = Signal (connect_OBJECT__BOOL "paginate") +printOptPaginate :: PrintOperationClass self => Signal self (PrintContext -> IO Bool) +printOptPaginate = Signal (connect_OBJECT__BOOL "paginate") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 831 -requestPageSetup :: PrintOperationClass self => Signal self (PrintContext -> Int -> PageSetup -> IO ()) -requestPageSetup = Signal (connect_OBJECT_INT_OBJECT__NONE "request_page_setup") +printOptRequestPageSetup :: PrintOperationClass self => Signal self (PrintContext -> Int -> PageSetup -> IO ()) +printOptRequestPageSetup = Signal (connect_OBJECT_INT_OBJECT__NONE "request_page_setup") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 842 -drawPage :: PrintOperationClass self => Signal self (PrintContext -> Int -> IO ()) -drawPage = Signal (connect_OBJECT_INT__NONE "draw_page") +printOptDrawPage :: PrintOperationClass self => Signal self (PrintContext -> Int -> IO ()) +printOptDrawPage = Signal (connect_OBJECT_INT__NONE "draw_page") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 848 -endPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) -endPrint = Signal (connect_OBJECT__NONE "end_print") +printOptEndPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) +printOptEndPrint = Signal (connect_OBJECT__NONE "end_print") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 855 -statusChanged :: PrintOperationClass self => Signal self (IO ()) -statusChanged = Signal (connect_NONE__NONE "status_changed") +printOptStatusChanged :: PrintOperationClass self => Signal self (IO ()) +printOptStatusChanged = Signal (connect_NONE__NONE "status_changed") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 868 -createCustomWidget :: PrintOperationClass self => Signal self (IO Widget) -createCustomWidget = Signal (connect_NONE__OBJECTPTR "create_custom_widget") +printOptCreateCustomWidget :: PrintOperationClass self => Signal self (IO Widget) +printOptCreateCustomWidget = Signal (connect_NONE__OBJECTPTR "create_custom_widget") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 892 -updateCustomWidget :: PrintOperationClass self => Signal self (Widget -> PageSetup -> PrintSettings -> IO ()) -updateCustomWidget = Signal (connect_OBJECT_OBJECT_OBJECT__NONE "update_custom_widget") +printOptUpdateCustomWidget :: PrintOperationClass self => Signal self (Widget -> PageSetup -> PrintSettings -> IO ()) +printOptUpdateCustomWidget = Signal (connect_OBJECT_OBJECT_OBJECT__NONE "update_custom_widget") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 901 -customWidgetApply :: PrintOperationClass self => Signal self (Widget -> IO ()) -customWidgetApply = Signal (connect_OBJECT__NONE "custom_widget_apply") +printOptCustomWidgetApply :: PrintOperationClass self => Signal self (Widget -> IO ()) +printOptCustomWidgetApply = Signal (connect_OBJECT__NONE "custom_widget_apply") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 920 -preview :: PrintOperationClass self => Signal self (PrintOperationPreview -> PrintContext -> Window -> IO Bool) -preview = Signal (connect_OBJECT_OBJECT_OBJECT__BOOL "preview") +printOptPreview :: PrintOperationClass self => Signal self (PrintOperationPreview -> PrintContext -> Window -> IO Bool) +printOptPreview = Signal (connect_OBJECT_OBJECT_OBJECT__BOOL "preview") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 926 -ready :: PrintOperationPreviewClass self => Signal self (PrintContext -> IO ()) -ready = Signal (connect_OBJECT__NONE "ready") +printOptReady :: PrintOperationPreviewClass self => Signal self (PrintContext -> IO ()) +printOptReady = Signal (connect_OBJECT__NONE "ready") hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 933 -gotPageSize :: PrintOperationPreviewClass self => Signal self (PrintContext -> PageSetup -> IO ()) -gotPageSize = Signal (connect_OBJECT_OBJECT__NONE "got_page_size") +printOptGotPageSize :: PrintOperationPreviewClass self => Signal self (PrintContext -> PageSetup -> IO ()) +printOptGotPageSize = Signal (connect_OBJECT_OBJECT__NONE "got_page_size") } |
From: Andy S. <And...@co...> - 2010-09-22 23:44:19
|
diffing dir... Wed Sep 22 19:43:14 EDT 2010 Andy Stewart <laz...@gm...> * Use constructNewGObject create GdkAppLaunchContext Ignore-this: 1d9d67e6665f74134326e0aa0e8dd8b { hunk ./TODO 3 -gtk/Graphics/UI/Gtk/Gdk/Colormap.chs -gtk/Graphics/UI/Gtk/Gdk/Device.chs hunk ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs 31 - mkAppLaunchContext, + AppLaunchContextClass, + castToAppLaunchContext, [_$_] + gTypeAppLaunchContext, + toAppLaunchContext, hunk ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs 59 -{#import System.GIO.Types#} hiding (AppLaunchContext, mkAppLaunchContext) +{#import System.GIO.Types#} (Icon (..), IconClass, toIcon) hunk ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs 65 --------------------- --- Types -{#pointer *AppLaunchContext foreign newtype#} - hunk ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs 70 -appLaunchContextNew = do - ptr <- {# call gdk_app_launch_context_new #} - mkAppLaunchContext ptr - -mkAppLaunchContext :: Ptr AppLaunchContext -> IO AppLaunchContext -mkAppLaunchContext rPtr = do - ptr <- newForeignPtr rPtr objectUnref - return (AppLaunchContext ptr) +appLaunchContextNew = [_$_] + constructNewGObject mkAppLaunchContext $ + {# call gdk_app_launch_context_new #} hunk ./gtk/hierarchy.list 25 + GdkAppLaunchContext if gtk-2.14 } |
From: Andy S. <And...@co...> - 2010-09-22 13:43:09
|
diffing dir... Wed Sep 22 09:39:24 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Gdk.AppLaunchContext Ignore-this: a34a9d25d00164d1f6b1eddea60ade5b { hunk ./TODO 3 -gtk/Graphics/UI/Gtk/General/AccelGroup.chs -gtk/Graphics/UI/Gtk/General/AccelMap.chs - -gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs hunk ./gtk/Graphics/UI/Gtk.chs 56 + module Graphics.UI.Gtk.Gdk.AppLaunchContext, hunk ./gtk/Graphics/UI/Gtk.chs 283 +import Graphics.UI.Gtk.Gdk.AppLaunchContext addfile ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs hunk ./gtk/Graphics/UI/Gtk/Gdk/AppLaunchContext.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget AppLaunchContext +-- +-- Author : Andy Stewart +-- +-- Created: 30 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) +-- +-- +module Graphics.UI.Gtk.Gdk.AppLaunchContext ( +#if GTK_CHECK_VERSION(2,14,0) +-- * Types + AppLaunchContext, + mkAppLaunchContext, + +-- * Constructors + appLaunchContextNew, + +-- * Methods + appLaunchContextSetDisplay, + appLaunchContextSetScreen, + appLaunchContextSetDesktop, + appLaunchContextSetTimestamp, + appLaunchContextSetIconName, +#ifdef HAVE_GIO + appLaunchContextSetIcon, +#endif +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.UTFString +import System.Glib.GObject (constructNewGObject, makeNewGObject) +import Graphics.UI.Gtk.Gdk.EventM (TimeStamp) +{#import Graphics.UI.Gtk.Types#} +#ifdef HAVE_GIO +{#import System.GIO.Types#} hiding (AppLaunchContext, mkAppLaunchContext) +#endif + +{# context lib="gdk" prefix="gdk" #} + +#if GTK_CHECK_VERSION(2,14,0) +-------------------- +-- Types +{#pointer *AppLaunchContext foreign newtype#} + +-------------------- +-- Constructors + +-- | Creates a new 'AppLaunchContext'. +appLaunchContextNew :: IO AppLaunchContext +appLaunchContextNew = do + ptr <- {# call gdk_app_launch_context_new #} + mkAppLaunchContext ptr + +mkAppLaunchContext :: Ptr AppLaunchContext -> IO AppLaunchContext +mkAppLaunchContext rPtr = do + ptr <- newForeignPtr rPtr objectUnref + return (AppLaunchContext ptr) + +-------------------- +-- Methods + +-- | Sets the workspace on which applications will be launched when using this context when running under +-- a window manager that supports multiple workspaces, as described in the Extended Window Manager +-- Hints. +-- [_$_] +-- When the workspace is not specified or desktop is set to -1, it is up to the window manager to pick +-- one, typically it will be the current workspace. +appLaunchContextSetDesktop :: AppLaunchContext -> Int -> IO () +appLaunchContextSetDesktop self desktop = + {# call gdk_app_launch_context_set_desktop #} + self + (fromIntegral desktop) + +-- | Sets the display on which applications will be launched when using this context. See also +-- 'appLaunchContextSetScreen'. +appLaunchContextSetDisplay :: AppLaunchContext -> Display -> IO () +appLaunchContextSetDisplay self display = + {# call gdk_app_launch_context_set_display #} + self + display + +#ifdef HAVE_GIO +-- | Sets the icon for applications that are launched with this context. +-- [_$_] +-- Window Managers can use this information when displaying startup notification. +appLaunchContextSetIcon :: IconClass icon => AppLaunchContext -> icon -> IO () +appLaunchContextSetIcon self icon = + {# call gdk_app_launch_context_set_icon #} + self + (toIcon icon) +#endif + +-- | Sets the icon for applications that are launched with this context. The @iconName@ will be +-- interpreted in the same way as the Icon field in desktop files. See also +-- 'appLaunchContextSetIcon'. +-- [_$_] +-- If both icon and @iconName@ are set, the @iconName@ takes priority. If neither icon or @iconName@ is +-- set, the icon is taken from either the file that is passed to launched application or from the +-- GAppInfo for the launched application itself. +appLaunchContextSetIconName :: AppLaunchContext -> String -> IO () +appLaunchContextSetIconName self iconName = + withUTFString iconName $ \iconNamePtr -> + {# call gdk_app_launch_context_set_icon_name #} + self + iconNamePtr + +-- | Sets the screen on which applications will be launched when using this context. See also +-- 'appLaunchContextSetDisplay'. +-- [_$_] +-- If both screen and display are set, the screen takes priority. If neither screen or display are set, +-- the default screen and display are used. +appLaunchContextSetScreen :: AppLaunchContext -> Screen -> IO () +appLaunchContextSetScreen self screen = + {# call gdk_app_launch_context_set_screen #} + self + screen + +-- | Sets the timestamp of context. The timestamp should ideally be taken from the event that triggered +-- the launch. +-- [_$_] +-- Window managers can use this information to avoid moving the focus to the newly launched application +-- when the user is busy typing in another window. This is also known as 'focus stealing prevention'. +appLaunchContextSetTimestamp :: AppLaunchContext -> TimeStamp -> IO () +appLaunchContextSetTimestamp self timestamp = + {# call gdk_app_launch_context_set_timestamp #} + self + (fromIntegral timestamp) +#endif hunk ./gtk/gtk.cabal 185 + Graphics.UI.Gtk.Gdk.AppLaunchContext } |
From: Andy S. <And...@co...> - 2010-09-22 12:44:30
|
diffing dir... Wed Sep 22 08:42:46 EDT 2010 Andy Stewart <laz...@gm...> * Fix docs Ignore-this: 9bafbbf1fa72f94a9cabd3e97e87aba0 { hunk ./gtk/Graphics/UI/Gtk/Printing/PrintContext.chs 40 --- 'PrintContext' objects gets passed to the ::begin-print, ::end-print, --- ::request-page-setup and ::draw-page signals on the 'PrintOperation'. +-- 'PrintContext' objects gets passed to the 'beginPrint', 'endPrint', +-- 'requestPageSetup' and 'drawPage' signals on the 'PrintOperation'. hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 600 --- Default value: "" +-- Default value: \"\" hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 721 --- See the "status" property for a status value that is suitable for programmatic use. +-- See the 'printOperationStatus' property for a status value that is suitable for programmatic use. hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 723 --- Default value: "" +-- Default value: \"\" } |
From: Andy S. <And...@co...> - 2010-09-22 12:44:28
|
diffing dir... Wed Sep 22 08:37:59 EDT 2010 Andy Stewart <laz...@gm...> * Add function printContextGetHardMargins in GTK+2.20 Ignore-this: fc97d38cbc5a27c3aae599e2520de742 { hunk ./TODO 16 -gtk_paint_spinner, function in GtkStyle -gtk_printer_get_hard_margins, function in GtkPrinter -gtk_print_context_get_hard_margins, function in GtkPrintContext - [_$_] hunk ./gtk/Graphics/UI/Gtk/Printing/PrintContext.chs 71 +#if GTK_CHECK_VERSION(2,20,0) + printContextGetHardMargins, +#endif hunk ./gtk/Graphics/UI/Gtk/Printing/PrintContext.chs 195 + +#if GTK_CHECK_VERSION(2,20,0) +printContextGetHardMargins :: PrintContextClass self => self + -> IO (Maybe (Double, Double, Double, Double)) + -- ^ returns @(top, bottom, left, right)@ [_$_] + -- @top@ top hardware printer margin [_$_] + -- @bottom@ bottom hardware printer margin [_$_] + -- @left@ left hardware printer margin [_$_] + -- @right@ right hardware printer margin [_$_] +printContextGetHardMargins self = + alloca $ \ topPtr -> + alloca $ \ bottomPtr -> + alloca $ \ leftPtr -> + alloca $ \ rightPtr -> do + success <- liftM toBool $ {#call gtk_print_context_get_hard_margins #} + (toPrintContext self) + topPtr + bottomPtr + leftPtr + rightPtr + if success + then do + top <- liftM realToFrac $ peek topPtr + bottom <- liftM realToFrac $ peek bottomPtr + left <- liftM realToFrac $ peek leftPtr + right <- liftM realToFrac $ peek rightPtr + return $ Just (top, bottom, left, right) + else return Nothing +#endif + } |
From: Andy S. <And...@co...> - 2010-09-22 12:25:06
|
diffing dir... Wed Sep 22 08:18:54 EDT 2010 Andy Stewart <laz...@gm...> * Add new modules : Printing.PrintOperation and Printing.PrintSetttings Ignore-this: b43e5a4c5f6b3afad88a438840ddab41 { hunk ./TODO 6 -gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs -gtk/Graphics/UI/Gtk/Printing/PrintOperationPreview.chs -gtk/Graphics/UI/Gtk/Printing/PrintSettings.chs - hunk ./gtk/Graphics/UI/Gtk.chs 212 + module Graphics.UI.Gtk.Printing.PrintOperation, + module Graphics.UI.Gtk.Printing.PrintSettings, hunk ./gtk/Graphics/UI/Gtk.chs 443 +import Graphics.UI.Gtk.Printing.PrintOperation +import Graphics.UI.Gtk.Printing.PrintSettings hunk ./gtk/Graphics/UI/Gtk/General/Enums.chs 87 -#if GTK_CHECK_VERSION(2,10,0) - PageOrientation (..), -#endif hunk ./gtk/Graphics/UI/Gtk/General/Enums.chs 429 - -#if GTK_CHECK_VERSION(2,10,0) -{#enum PageOrientation {underscoreToCase} deriving (Eq,Show)#} -#endif - hunk ./gtk/Graphics/UI/Gtk/Printing/PageSetup.chs 110 -import Graphics.UI.Gtk.General.Enums (PageOrientation(..)) +{#import Graphics.UI.Gtk.Printing.PrintSettings#} (PageOrientation (..)) addfile ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs hunk ./gtk/Graphics/UI/Gtk/Printing/PrintOperation.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget PrintOperation +-- +-- Author : Andy Stewart +-- +-- Created: 28 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) +-- +-- High-level Printing API +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Printing.PrintOperation ( + +-- * Detail +-- +-- | 'PrintOperation' is the high-level, portable printing API. It looks a bit +-- different than other Gtk+ dialogs such as the 'FileChooser', since some +-- platforms don't expose enough infrastructure to implement a good print +-- dialog. On such platforms, 'PrintOperation' uses the native print dialog. On +-- platforms which do not provide a native print dialog, Gtk+ uses its own, see +-- 'PrintUnixDialog'. +-- +-- The typical way to use the high-level printing API is to create a +-- 'PrintOperation' object with 'printOperationNew' when the user selects to +-- print. Then you set some properties on it, e.g. the page size, any +-- 'PrintSettings' from previous print operations, the number of pages, the +-- current page, etc. +-- +-- Then you start the print operation by calling 'printOperationRun'. It +-- will then show a dialog, let the user select a printer and options. When the +-- user finished the dialog various signals will be emitted on the +-- 'PrintOperation', the main one being 'draw-page' signal, which you are supposed to +-- catch and render the page on the provided 'PrintContext' using Cairo. +-- +-- By default 'PrintOperation' uses an external application to do print +-- preview. To implement a custom print preview, an application must connect to +-- the preview signal. The functions 'printOperationPrintPreviewRenderPage', +-- 'printOperationPreviewEndPreview' and 'printOperationPreviewIsSelected' are +-- useful when implementing a print preview. +-- +-- Printing support was added in Gtk+ 2.10. +-- + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----PrintOperation +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + PrintOperation, + PrintOperationClass, + castToPrintOperation, + toPrintOperation, + + PrintOperationPreview, + PrintOperationPreviewClass, + castToPrintOperationPreview, + toPrintOperationPreview, + +-- * Enums + PrintStatus(..), + PrintOperationAction(..), + PrintOperationResult(..), + PrintError(..), + +-- * Constructors + printOperationNew, + +-- * Methods + printOperationSetAllowAsync, + printOperationGetError, +#if GTK_CHECK_VERSION(2,18,0) + printOperationGetNPagesToPrint, +#endif + printOperationRun, + printOperationCancel, +#if GTK_CHECK_VERSION(2,16,0) + printOperationDrawPageFinish, + printOperationSetDeferDrawing, +#endif + printOperationGetStatus, + printOperationGetStatusString, + printOperationIsFinished, + printRunPageSetupDialog, + printRunPageSetupDialogAsync, + + printOperationPreviewEndPreview, + printOperationPreviewIsSelected, + printOperationPreviewRenderPage, + +-- * Attributes + printOperationDefaultPageSetup, + printOperationPrintSettings, + printOperationJobName, + printOperationNPages, + printOperationCurrentPage, + printOperationUseFullPage, + printOperationTrackPrintStatus, + printOperationUnit, + printOperationShowProgress, + printOperationAllowAsync, + printOperationExportFilename, + printOperationStatus, + printOperationStatusString, + printOperationCustomTabLabel, +#if GTK_CHECK_VERSION(2,18,0) + printOperationSupportSelection, + printOperationHasSelection, + printOperationEmbedPageSetup, + printOperationNPagesToPrint, +#endif + +-- * Signals + done, + beginPrint, + paginate, + requestPageSetup, + drawPage, + endPrint, + statusChanged, + createCustomWidget, +#if GTK_CHECK_VERSION(2,18,0) + updateCustomWidget, +#endif + customWidgetApply, + preview, + ready, + gotPageSize, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.UTFString +import System.Glib.GError +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} +import Graphics.UI.Gtk.Printing.PaperSize (Unit(..)) + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Interfaces + +instance PrintOperationPreviewClass PrintOperation + +-------------------- +-- Enums +-- | The status gives a rough indication of the completion of a running print operation. +{#enum PrintStatus {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-- | The action parameter to 'printOperationRun' determines what action the print operation should +-- perform. +{#enum PrintOperationAction {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-- | A value of this type is returned by 'printOperationRun'. +{#enum PrintOperationResult {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-- | Error codes that identify various errors that can occur while using the GTK+ printing support. +{#enum PrintError {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-------------------- +-- Constructors + +-- | Creates a new 'PrintOperation'. +-- +printOperationNew :: IO PrintOperation +printOperationNew = + constructNewGObject mkPrintOperation $ + {# call gtk_print_operation_new #} + +-------------------- +-- Methods + +-- | Sets whether the 'printOperationRun' may return before the print +-- operation is completed. Note that some platforms may not allow asynchronous +-- operation. +-- +printOperationSetAllowAsync :: PrintOperationClass self => self + -> Bool -- ^ @allowAsync@ - @True@ to allow asynchronous operation + -> IO () +printOperationSetAllowAsync self allowAsync = + {# call gtk_print_operation_set_allow_async #} + (toPrintOperation self) + (fromBool allowAsync) + +-- | Call this when the result of a print operation is +-- 'PrintOperationResultError', either as returned by 'printOperationRun', or +-- in the 'done' signal handler. The returned +-- 'GError' will contain more details on what went wrong. +-- +printOperationGetError :: PrintOperationClass self => self -> IO () +printOperationGetError self = + propagateGError $ \errorPtr -> + {# call gtk_print_operation_get_error #} + (toPrintOperation self) + errorPtr + +-- | Sets the name of the print job. The name is used to identify the job +-- (e.g. in monitoring applications like eggcups). +-- +-- If you don't set a job name, Gtk+ picks a default one by numbering +-- successive print jobs. +-- +printOperationSetJobName :: PrintOperationClass self => self + -> String -- ^ @jobName@ - a string that identifies the print job + -> IO () +printOperationSetJobName self jobName = + withUTFString jobName $ \jobNamePtr -> + {# call gtk_print_operation_set_job_name #} + (toPrintOperation self) + jobNamePtr + +-- | Sets the number of pages in the document. +-- +-- This /must/ be set to a positive number before the rendering starts. It +-- may be set in a 'beginPrint' signal hander. +-- +-- Note that the page numbers passed to the 'requestPageSetup' [_$_] +-- and 'drawPage' signals +-- are 0-based, i.e. if the user chooses to print all pages, the last +-- 'draw-page' signal will be for page @nPages@ - 1. +-- +printOperationSetNPages :: PrintOperationClass self => self + -> Int -- ^ @nPages@ - the number of pages + -> IO () +printOperationSetNPages self nPages = + {# call gtk_print_operation_set_n_pages #} + (toPrintOperation self) + (fromIntegral nPages) + +#if GTK_CHECK_VERSION(2,18,0) +-- | Returns the number of pages that will be printed. +-- +-- Note that this value is set during print preparation phase +-- ('PrintStatusPreparing'), so this function should never be called before the +-- data generation phase ('PrintStatusGeneratingData'). You can connect to the +-- 'statusChanged' signal and call +-- 'printOperationGetNPagesToPrint' when print status is +-- 'PrintStatusGeneratingData'. This is typically used to track the progress of +-- print operation. +-- +-- * Available since Gtk+ version 2.18 +-- +printOperationGetNPagesToPrint :: PrintOperationClass self => self + -> IO Int -- ^ returns the number of pages that will be printed +printOperationGetNPagesToPrint self = + liftM fromIntegral $ + {# call gtk_print_operation_get_n_pages_to_print #} + (toPrintOperation self) +#endif + +-- | Sets the current page. +-- +-- If this is called before 'printOperationRun', the user will be able to +-- select to print only the current page. +-- +-- Note that this only makes sense for pre-paginated documents. +-- +printOperationSetCurrentPage :: PrintOperationClass self => self + -> Int -- ^ @currentPage@ - the current page, 0-based + -> IO () +printOperationSetCurrentPage self currentPage = + {# call gtk_print_operation_set_current_page #} + (toPrintOperation self) + (fromIntegral currentPage) + +-- | If @fullPage@ is @True@, the transformation for the cairo context +-- obtained from 'PrintContext' puts the origin at the top left corner of the +-- page (which may not be the top left corner of the sheet, depending on page +-- orientation and the number of pages per sheet). Otherwise, the origin is at +-- the top left corner of the imageable area (i.e. inside the margins). +-- +printOperationSetUseFullPage :: PrintOperationClass self => self + -> Bool -- ^ @fullPage@ - @True@ to set up the 'PrintContext' for the full + -- page + -> IO () +printOperationSetUseFullPage self fullPage = + {# call gtk_print_operation_set_use_full_page #} + (toPrintOperation self) + (fromBool fullPage) + +-- | Sets up the transformation for the cairo context obtained from +-- 'PrintContext' in such a way that distances are measured in units of @unit@. +-- +printOperationSetUnit :: PrintOperationClass self => self + -> Unit -- ^ @unit@ - the unit to use + -> IO () +printOperationSetUnit self unit = + {# call gtk_print_operation_set_unit #} + (toPrintOperation self) + ((fromIntegral . fromEnum) unit) + +-- | Sets up the 'PrintOperation' to generate a file instead of showing the +-- print dialog. The indended use of this function is for implementing \"Export +-- to PDF\" actions. Currently, PDF is the only supported format. +-- +-- \"Print to PDF\" support is independent of this and is done by letting +-- the user pick the \"Print to PDF\" item from the list of printers in the +-- print dialog. +-- +printOperationSetExportFilename :: PrintOperationClass self => self + -> String -- ^ @filename@ - the filename for the exported file + -> IO () +printOperationSetExportFilename self filename = + withUTFString filename $ \filenamePtr -> + {# call gtk_print_operation_set_export_filename #} + (toPrintOperation self) + filenamePtr + +-- | If @showProgress@ is @True@, the print operation will show a progress +-- dialog during the print operation. +-- +printOperationSetShowProgress :: PrintOperationClass self => self + -> Bool -- ^ @showProgress@ - @True@ to show a progress dialog + -> IO () +printOperationSetShowProgress self showProgress = + {# call gtk_print_operation_set_show_progress #} + (toPrintOperation self) + (fromBool showProgress) + +-- | If track_status is @True@, the print operation will try to continue +-- report on the status of the print job in the printer queues and printer. +-- This can allow your application to show things like \"out of paper\" issues, +-- and when the print job actually reaches the printer. +-- +-- This function is often implemented using some form of polling, so it +-- should not be enabled unless needed. +-- +printOperationSetTrackPrintStatus :: PrintOperationClass self => self + -> Bool -- ^ @trackStatus@ - @True@ to track status after printing + -> IO () +printOperationSetTrackPrintStatus self trackStatus = + {# call gtk_print_operation_set_track_print_status #} + (toPrintOperation self) + (fromBool trackStatus) + +-- | Sets the label for the tab holding custom widgets. +-- +printOperationSetCustomTabLabel :: PrintOperationClass self => self + -> String -- ^ @label@ - the label to use, or empty to use the default + -- label + -> IO () +printOperationSetCustomTabLabel self label = + withUTFString label $ \labelPtr -> + {# call gtk_print_operation_set_custom_tab_label #} + (toPrintOperation self) + labelPtr + +-- | Runs the print operation, by first letting the user modify print settings +-- in the print dialog, and then print the document. +-- +-- Normally that this function does not return until the rendering of all +-- pages is complete. You can connect to the 'statusChanged' signal on @op@ to obtain some information about the +-- progress of the print operation. Furthermore, it may use a recursive +-- mainloop to show the print dialog. +-- +-- If you call 'printOperationSetAllowAsync' or set the 'allowAsync' [_$_] +-- property the operation will run asynchronously +-- if this is supported on the platform. The 'done' signal will be emitted with the result of the operation when +-- the it is done (i.e. when the dialog is canceled, or when the print succeeds +-- or fails). +-- +printOperationRun :: (PrintOperationClass self, WindowClass parent) => self + -> PrintOperationAction -- ^ @action@ - the action to start + -> parent -- ^ @parent@ - Transient parent of the dialog + -> IO PrintOperationResult -- ^ returns the result of the print operation. A + -- return value of 'PrintOperationResultApply' + -- indicates that the printing was completed + -- successfully. In this case, it is a good idea to + -- obtain the used print settings with + -- 'printOperationGetPrintSettings' and store them + -- for reuse with the next print operation. A value + -- of 'PrintOperationResultInProgress' means the + -- operation is running asynchronously, and will + -- emit the 'done' signal when done. +printOperationRun self action parent = + liftM (toEnum . fromIntegral) $ + propagateGError $ \errorPtr -> + {# call gtk_print_operation_run #} + (toPrintOperation self) + ((fromIntegral . fromEnum) action) + (toWindow parent) + errorPtr + +-- | Cancels a running print operation. This function may be called from a +-- 'beginPrint', 'paginate' or 'drawPage' signal handler +-- to stop the currently running print operation. +-- +printOperationCancel :: PrintOperationClass self => self -> IO () +printOperationCancel self = + {# call gtk_print_operation_cancel #} + (toPrintOperation self) + +#if GTK_CHECK_VERSION(2,16,0) +-- | Signalize that drawing of particular page is complete. +-- +-- It is called after completion of page drawing (e.g. drawing in another +-- thread). If 'printOperationSetDeferDrawing' was called before, then this +-- function has to be called by application. In another case it is called by +-- the library itself. +-- +-- * Available since Gtk+ version 2.16 +-- +printOperationDrawPageFinish :: PrintOperationClass self => self -> IO () +printOperationDrawPageFinish self = + {# call gtk_print_operation_draw_page_finish #} + (toPrintOperation self) + +-- | Sets up the 'PrintOperation' to wait for calling of +-- 'printOperationDrawPageFinish' from application. It can be used for drawing +-- page in another thread. +-- +-- This function must be called in the callback of \"draw-page\" signal. +-- +-- * Available since Gtk+ version 2.16 +-- +printOperationSetDeferDrawing :: PrintOperationClass self => self -> IO () +printOperationSetDeferDrawing self = + {# call gtk_print_operation_set_defer_drawing #} + (toPrintOperation self) +#endif + +-- | Returns the status of the print operation. Also see +-- 'printOperationGetStatusString'. +-- +printOperationGetStatus :: PrintOperationClass self => self + -> IO PrintStatus -- ^ returns the status of the print operation +printOperationGetStatus self = + liftM (toEnum . fromIntegral) $ + {# call gtk_print_operation_get_status #} + (toPrintOperation self) + +-- | Returns a string representation of the status of the print operation. The +-- string is translated and suitable for displaying the print status e.g. in a +-- 'Statusbar'. +-- +-- Use 'printOperationGetStatus' to obtain a status value that is suitable +-- for programmatic use. +-- +printOperationGetStatusString :: PrintOperationClass self => self + -> IO String -- ^ returns a string representation of the status of the print + -- operation +printOperationGetStatusString self = + {# call gtk_print_operation_get_status_string #} + (toPrintOperation self) + >>= peekUTFString + +-- | A convenience function to find out if the print operation is finished, +-- either successfully ('PrintStatusFinished') or unsuccessfully +-- ('PrintStatusFinishedAborted'). +-- +-- Note: when you enable print status tracking the print operation can be in +-- a non-finished state even after done has been called, as the operation +-- status then tracks the print job status on the printer. +-- +printOperationIsFinished :: PrintOperationClass self => self + -> IO Bool -- ^ returns @True@, if the print operation is finished. +printOperationIsFinished self = + liftM toBool $ + {# call gtk_print_operation_is_finished #} + (toPrintOperation self) + +-- | Runs a page setup dialog, letting the user modify the values from @pageSetup@. If the user cancels +-- the dialog, the returned 'PageSetup' is identical to the passed in @pageSetup@, otherwise it +-- contains the modifications done in the dialog. +-- [_$_] +-- Note that this function may use a recursive mainloop to show the page setup dialog. See +-- 'printRunPageSetupDialogAsync' if this is a problem. +printRunPageSetupDialog :: (WindowClass window, PageSetupClass pageSetup, PrintSettingsClass setting) [_$_] + => window -- ^ @parent@ transient parent. [_$_] + -> pageSetup -- ^ @pageSetup@ an existing 'PageSetup'. [_$_] + -> setting -- ^ @settings@ a 'PrintSettings' [_$_] + -> IO PageSetup -- ^ returns a new 'PageSetup' [_$_] +printRunPageSetupDialog window pageSetup setting = [_$_] + makeNewGObject mkPageSetup $ + {#call gtk_print_run_page_setup_dialog #} + (toWindow window) + (toPageSetup pageSetup) + (toPrintSettings setting) + +{#pointer PageSetupDoneFunc#} + +foreign import ccall "wrapper" mkGtkPageSetupDoneFunc :: + (Ptr PageSetup -> Ptr () -> IO ()) + -> IO PageSetupDoneFunc + +-- | Runs a page setup dialog, letting the user modify the values from @pageSetup@. +-- [_$_] +-- In contrast to 'printRunPageSetupDialog', this function returns after showing the page setup +-- dialog on platforms that support this, and calls @doneCb@ from a signal handler for the 'response' +-- signal of the dialog. +printRunPageSetupDialogAsync :: (WindowClass window, PageSetupClass pageSetup, PrintSettingsClass setting) + => window -- ^ @parent@ transient parent. [_$_] + -> pageSetup -- ^ @pageSetup@ an existing 'PageSetup'. [_$_] + -> setting -- ^ @settings@ a 'PrintSettings' [_$_] + -> (PageSetup -> IO ()) -- ^ @doneCb@ a function to call when the user saves the modified page setup + -> IO () +printRunPageSetupDialogAsync window pageSetup setting doneCb = do + funcPtr <- mkGtkPageSetupDoneFunc $ \setupPtr _ -> do + setup <- makeNewGObject mkPageSetup (return setupPtr) + doneCb setup + {#call gtk_print_run_page_setup_dialog_async #} + (toWindow window) + (toPageSetup pageSetup) + (toPrintSettings setting) + funcPtr + nullPtr + +-- | Ends a preview. +-- [_$_] +-- This function must be called to finish a custom print preview. +printOperationPreviewEndPreview :: PrintOperationPreviewClass self [_$_] + => self [_$_] + -> IO () +printOperationPreviewEndPreview self = + {# call gtk_print_operation_preview_end_preview #} + (toPrintOperationPreview self) + +-- | Returns whether the given page is included in the set of pages that have been selected for printing. +printOperationPreviewIsSelected :: PrintOperationPreviewClass self [_$_] + => self -- ^ @preview@ a 'PrintOperationPreview' [_$_] + -> Int -- ^ @pageNr@ a page number [_$_] + -> IO Bool -- ^ returns 'True' if the page has been selected for printing [_$_] +printOperationPreviewIsSelected self pageNr = + liftM toBool $ + {# call gtk_print_operation_preview_is_selected #} + (toPrintOperationPreview self) + (fromIntegral pageNr) + +-- | Renders a page to the preview, using the print context that was passed to the "preview" handler +-- together with preview. +-- [_$_] +-- A custom iprint preview should use this function in its 'expose' handler to render the currently +-- selected page. +-- [_$_] +-- Note that this function requires a suitable cairo context to be associated with the print context. +printOperationPreviewRenderPage :: PrintOperationPreviewClass self [_$_] + => self -- ^ @preview@ a 'PrintOperationPreview' [_$_] + -> Int -- ^ @pageNr@ the page to render [_$_] + -> IO () +printOperationPreviewRenderPage self pageNr = + {# call gtk_print_operation_preview_render_page #} + (toPrintOperationPreview self) + (fromIntegral pageNr) + +-------------------- +-- Attributes + +-- | The 'PageSetup' used by default. +-- [_$_] +-- This page setup will be used by 'printOperationRun', but it can be overridden on a per-page +-- basis by connecting to the 'requestPageSetup' signal. +-- [_$_] +-- Since 2.10 +printOperationDefaultPageSetup :: (PrintOperationClass self, PageSetupClass pageSetup) => ReadWriteAttr self PageSetup pageSetup +printOperationDefaultPageSetup = newAttrFromObjectProperty "default-page-setup" + {# call pure unsafe gtk_page_setup_get_type #} + +-- | The 'PrintSettings' used for initializing the dialog. +-- [_$_] +-- Setting this property is typically used to re-establish print settings from a previous print +-- operation, see 'printOperationRun'. +-- [_$_] +-- Since 2.10 +printOperationPrintSettings :: (PrintOperationClass self, PrintSettingsClass printSettings) => ReadWriteAttr self PrintSettings printSettings +printOperationPrintSettings = newAttrFromObjectProperty "print-settings" + {# call pure unsafe gtk_print_settings_get_type #} + +-- | A string used to identify the job (e.g. in monitoring applications like eggcups). +-- [_$_] +-- If you don't set a job name, GTK+ picks a default one by numbering successive print jobs. +-- [_$_] +-- Default value: "" +-- [_$_] +-- Since 2.10 +printOperationJobName :: PrintOperationClass self => Attr self String +printOperationJobName = newAttrFromStringProperty "job-name" + +-- | The number of pages in the document. +-- [_$_] +-- This must be set to a positive number before the rendering starts. It may be set in a 'beginPrint' +-- signal hander. +-- [_$_] +-- Note that the page numbers passed to the 'requestPageSetup' and 'drawPage' signals are 0-based, +-- i.e. if the user chooses to print all pages, the last 'drawPage' signal will be for page @nPages@ - +-- 1. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: -1 +-- [_$_] +-- Since 2.10 +printOperationNPages :: PrintOperationClass self => Attr self Int +printOperationNPages = newAttrFromIntProperty "n-pages" + +-- | The current page in the document. +-- [_$_] +-- If this is set before 'printOperationRun', the user will be able to select to print only the +-- current page. +-- [_$_] +-- Note that this only makes sense for pre-paginated documents. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: -1 +-- [_$_] +-- Since 2.10 +printOperationCurrentPage :: PrintOperationClass self => Attr self Int +printOperationCurrentPage = newAttrFromIntProperty "current-page" + +-- | If 'True', the transformation for the cairo context obtained from 'PrintContext' puts the origin at +-- the top left corner of the page (which may not be the top left corner of the sheet, depending on +-- page orientation and the number of pages per sheet). Otherwise, the origin is at the top left corner +-- of the imageable area (i.e. inside the margins). +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.10 +printOperationUseFullPage :: PrintOperationClass self => Attr self Bool +printOperationUseFullPage = newAttrFromBoolProperty "use-full-page" + +-- | If 'True', the print operation will try to continue report on the status of the print job in the +-- printer queues and printer. This can allow your application to show things like "out of paper" +-- issues, and when the print job actually reaches the printer. However, this is often implemented +-- using polling, and should not be enabled unless needed. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.10 +printOperationTrackPrintStatus :: PrintOperationClass self => Attr self Bool +printOperationTrackPrintStatus = newAttrFromBoolProperty "track-print-status" + +-- | The transformation for the cairo context obtained from 'PrintContext' is set up in such a way that +-- distances are measured in units of unit. +-- [_$_] +-- Default value: ''UnitPixel'' +-- [_$_] +-- Since 2.10 +-- [_$_] +printOperationUnit :: PrintOperationClass self => Attr self Unit +printOperationUnit = newAttrFromEnumProperty "unit" + {# call pure unsafe gtk_unit_get_type #} + +-- | Determines whether to show a progress dialog during the print operation. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.10 +printOperationShowProgress :: PrintOperationClass self => Attr self Bool +printOperationShowProgress = newAttrFromBoolProperty "show-progress" + +-- | Determines whether the print operation may run asynchronously or not. +-- [_$_] +-- Some systems don't support asynchronous printing, but those that do will return +-- ''PrintOperationResultInProgress'' as the status, and emit the "done" signal when the operation +-- is actually done. +-- [_$_] +-- The Windows port does not support asynchronous operation at all (this is unlikely to change). On +-- other platforms, all actions except for ''PrintOperationActionExport'' support asynchronous +-- operation. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.10 +printOperationAllowAsync :: PrintOperationClass self => Attr self Bool +printOperationAllowAsync = newAttrFromBoolProperty "allow-async" + +-- | The name of a file to generate instead of showing the print dialog. Currently, PDF is the only +-- supported format. +-- [_$_] +-- The intended use of this property is for implementing "Export to PDF" actions. +-- [_$_] +-- "Print to PDF" support is independent of this and is done by letting the user pick the "Print to +-- PDF" item from the list of printers in the print dialog. +-- [_$_] +-- Default value: 'Nothing' +-- [_$_] +-- Since 2.10 +printOperationExportFilename :: PrintOperationClass self => Attr self String +printOperationExportFilename = newAttrFromStringProperty "export-filename" + +-- | The status of the print operation. +-- [_$_] +-- Default value: ''PrintStatusInitial'' +-- [_$_] +-- Since 2.10 +printOperationStatus :: PrintOperationClass self => ReadAttr self PrintStatus +printOperationStatus = readAttrFromEnumProperty "status" + {# call pure unsafe gtk_print_status_get_type #} + +-- | A string representation of the status of the print operation. The string is translated and suitable +-- for displaying the print status e.g. in a 'Statusbar'. +-- [_$_] +-- See the "status" property for a status value that is suitable for programmatic use. +-- [_$_] +-- Default value: "" +-- [_$_] +-- Since 2.10 +printOperationStatusString :: PrintOperationClass self => ReadAttr self String +printOperationStatusString = readAttrFromStringProperty "status-string" + +-- | Used as the label of the tab containing custom widgets. Note that this property may be ignored on +-- some platforms. +-- [_$_] +-- If this is 'Nothing', GTK+ uses a default label. +-- [_$_] +-- Default value: 'Nothing' +-- [_$_] +-- Since 2.10 +printOperationCustomTabLabel :: PrintOperationClass self => Attr self String +printOperationCustomTabLabel = newAttrFromStringProperty "custom-tab-label" + +#if GTK_CHECK_VERSION(2,18,0) +-- | If 'True', the print operation will support print of selection. This allows the print dialog to show a +-- "Selection" button. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.18 +printOperationSupportSelection :: PrintOperationClass self => Attr self Bool +printOperationSupportSelection = newAttrFromBoolProperty "support-selection" + +-- | Determines whether there is a selection in your application. This can allow your application to +-- print the selection. This is typically used to make a "Selection" button sensitive. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.18 +printOperationHasSelection :: PrintOperationClass self => Attr self Bool +printOperationHasSelection = newAttrFromBoolProperty "has-selection" + +-- | If 'True', page size combo box and orientation combo box are embedded into page setup page. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- Since 2.18 +printOperationEmbedPageSetup :: PrintOperationClass self => Attr self Bool +printOperationEmbedPageSetup = newAttrFromBoolProperty "embed-page-setup" + +-- | The number of pages that will be printed. +-- [_$_] +-- Note that this value is set during print preparation phase (''PrintStatusPreparing''), so this +-- value should never be get before the data generation phase (''PrintStatusGeneratingData''). You +-- can connect to the 'statusChanged' signal and call 'printOperationGetNPagesToPrint' when +-- print status is ''PrintStatusGeneratingData''. This is typically used to track the progress of +-- print operation. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: -1 +-- [_$_] +-- Since 2.18 +printOperationNPagesToPrint :: PrintOperationClass self => ReadAttr self Int +printOperationNPagesToPrint = readAttrFromIntProperty "n-pages-to-print" +#endif + +-------------------- +-- Signals + +-- | Emitted when the print operation run has finished doing everything +-- required for printing. +-- +-- @result@ gives you information about what happened during the run. If +-- @result@ is 'PrintOperationResultError' then you can call +-- 'printOperationGetError' for more information. +-- +-- If you enabled print status tracking then 'printOperationIsFinished' may +-- still return @False@ after 'done' was +-- emitted. +-- +done :: PrintOperationClass self => Signal self (PrintOperationResult -> IO ()) +done = Signal (connect_ENUM__NONE "done") + +-- | Emitted after the user has finished changing print settings in the +-- dialog, before the actual rendering starts. +-- +-- A typical use for 'begin-print' is to use the parameters from the +-- 'PrintContext' and paginate the document accordingly, and then set the +-- number of pages with 'printOperationSetNPages'. +-- +beginPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) +beginPrint = Signal (connect_OBJECT__NONE "begin_print") + +-- | Emitted after the 'beginPrint' signal, +-- but before the actual rendering starts. It keeps getting emitted until a +-- connected signal handler returns @True@. +-- +-- The 'paginate' signal is intended to be used for paginating a document in +-- small chunks, to avoid blocking the user interface for a long time. The +-- signal handler should update the number of pages using +-- 'printOperationSetNPages', and return @True@ if the document has been +-- completely paginated. +-- +-- If you don't need to do pagination in chunks, you can simply do it all in +-- the 'begin-print handler', and set the number of pages from there. +-- +paginate :: PrintOperationClass self => Signal self (PrintContext -> IO Bool) +paginate = Signal (connect_OBJECT__BOOL "paginate") + +-- | Emitted once for every page that is printed, to give the application a +-- chance to modify the page setup. Any changes done to @setup@ will be in +-- force only for printing this page. +-- +requestPageSetup :: PrintOperationClass self => Signal self (PrintContext -> Int -> PageSetup -> IO ()) +requestPageSetup = Signal (connect_OBJECT_INT_OBJECT__NONE "request_page_setup") + +-- | Emitted for every page that is printed. The signal handler must render +-- the @pageNr@'s page onto the cairo context obtained from @context@ using +-- 'printContextGetCairoContext'. +-- +-- Use 'printOperationSetUseFullPage' and 'printOperationSetUnit' before +-- starting the print operation to set up the transformation of the cairo +-- context according to your needs. +-- +drawPage :: PrintOperationClass self => Signal self (PrintContext -> Int -> IO ()) +drawPage = Signal (connect_OBJECT_INT__NONE "draw_page") + +-- | Emitted after all pages have been rendered. A handler for this signal can +-- clean up any resources that have been allocated in the 'beginPrint' handler. +-- +endPrint :: PrintOperationClass self => Signal self (PrintContext -> IO ()) +endPrint = Signal (connect_OBJECT__NONE "end_print") + +-- | Emitted at between the various phases of the print operation. See +-- 'PrintStatus' for the phases that are being discriminated. Use +-- 'printOperationGetStatus' to find out the current status. +-- +statusChanged :: PrintOperationClass self => Signal self (IO ()) +statusChanged = Signal (connect_NONE__NONE "status_changed") + +-- | Emitted when displaying the print dialog. If you return a widget in a +-- handler for this signal it will be added to a custom tab in the print +-- dialog. You typically return a container widget with multiple widgets in it. +-- +-- The print dialog owns the returned widget, and its lifetime is not +-- controlled by the application. However, the widget is guaranteed to stay +-- around until the 'customWidgetApply' +-- signal is emitted on the operation. Then you can read out any information +-- you need from the widgets. +-- +createCustomWidget :: PrintOperationClass self => Signal self (IO Widget) +createCustomWidget = Signal (connect_NONE__OBJECTPTR "create_custom_widget") + +-- | Signal helper functions. +connect_NONE__OBJECTPTR :: + GObjectClass obj => SignalName -> + ConnectAfter -> obj -> + (IO Widget) -> + IO (ConnectId obj) +connect_NONE__OBJECTPTR signal after obj user = + connectGeneric signal after obj action + where action :: Ptr GObject -> IO (Ptr Widget) + action _ = + failOnGError $ do + x <- user + return $ unsafeForeignPtrToPtr (unWidget (toWidget x)) + +#if GTK_CHECK_VERSION(2,18,0) +-- | Emitted after change of selected printer. The actual page setup and print +-- settings are passed to the custom widget, which can actualize itself +-- according to this change. +-- +-- * Available since Gtk+ version 2.18 +-- +updateCustomWidget :: PrintOperationClass self => Signal self (Widget -> PageSetup -> PrintSettings -> IO ()) +updateCustomWidget = Signal (connect_OBJECT_OBJECT_OBJECT__NONE "update_custom_widget") +#endif + +-- | Emitted right before 'beginPrint' if you +-- added a custom widget in the 'createCustomWidtet' handler. When you get this signal you should read the +-- information from the custom widgets, as the widgets are not guaraneed to be +-- around at a later time. +-- +customWidgetApply :: PrintOperationClass self => Signal self (Widget -> IO ()) +customWidgetApply = Signal (connect_OBJECT__NONE "custom_widget_apply") + +-- | Gets emitted when a preview is requested from the native dialog. +-- +-- The default handler for this signal uses an external viewer application +-- to preview. +-- +-- To implement a custom print preview, an application must return @True@ +-- from its handler for this signal. In order to use the provided @context@ for +-- the preview implementation, it must be given a suitable cairo context with +-- 'printContextSetCairoContext'. +-- +-- The custom preview implementation can use +-- 'printOperationPreviewIsSelected' and 'printOperationPreviewRenderPage' to +-- find pages which are selected for print and render them. The preview must be +-- finished by calling 'printOperationPreviewEndPreview' (typically in response +-- to the user clicking a close button). +-- +preview :: PrintOperationClass self => Signal self (PrintOperationPreview -> PrintContext -> Window -> IO Bool) +preview = Signal (connect_OBJECT_OBJECT_OBJECT__BOOL "preview") + +-- | The 'ready' signal gets emitted once per preview operation, before the first page is rendered. +-- [_$_] +-- A handler for this signal can be used for setup tasks. +ready :: PrintOperationPreviewClass self => Signal self (PrintContext -> IO ()) +ready = Signal (connect_OBJECT__NONE "ready") + +-- | The 'gotPageSize' signal is emitted once for each page that gets rendered to the preview. +-- [_$_] +-- A handler for this signal should update the context according to @pageSetup@ and set up a suitable +-- cairo context, using 'printContextSetCairoContext'. +gotPageSize :: PrintOperationPreviewClass self => Signal self (PrintContext -> PageSetup -> IO ()) +gotPageSize = Signal (connect_OBJECT_OBJECT__NONE "got_page_size") +#endif addfile ./gtk/Graphics/UI/Gtk/Printing/PrintSettings.chs hunk ./gtk/Graphics/UI/Gtk/Printing/PrintSettings.chs 1 +{-# LANGUAGE CPP #-} +{-# LANGUAGE ScopedTypeVariables #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget PrintSettings +-- +-- Author : Andy Stewart +-- +-- Created: 28 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) +-- +-- Stores print settings +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Printing.PrintSettings ( + +-- * Detail +-- +-- | A 'PrintSettings' object represents the settings of a print dialog in a +-- system-independent way. The main use for this object is that once you\'ve +-- printed you can get a settings object that represents the settings the user +-- chose, and the next time you print you can pass that object in so that the +-- user doesn't have to re-set all his settings. +-- +-- Its also possible to enumerate the settings so that you can easily save +-- the settings for the next time your app runs, or even store them in a +-- document. The predefined keys try to use shared values as much as possible +-- so that moving such a document between systems still works. +-- +-- Printing support was added in Gtk+ 2.10. +-- + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----PrintSettings +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + PrintSettings, + PrintSettingsClass, + castToPrintSettings, + toPrintSettings, + -- PageRange, + +-- * Enums + PageOrientation(..), +#if GTK_CHECK_VERSION(2,14,0) + NumberUpLayout(..), +#endif + PrintQuality(..), + PrintDuplex(..), + PrintPages(..), + PageSet(..), + +-- * Constructors + printSettingsNew, +#if GTK_CHECK_VERSION(2,12,0) + printSettingsNewFromFile, +#endif + +-- * Methods + printSettingsCopy, + printSettingsHasKey, + printSettingsGet, + printSettingsSet, + printSettingsUnset, + printSettingsForeach, + printSettingsGetBool, + printSettingsSetBool, + printSettingsGetDouble, + printSettingsGetDoubleWithDefault, + printSettingsSetDouble, + printSettingsGetLength, + printSettingsSetLength, + printSettingsGetInt, + printSettingsGetIntWithDefault, + printSettingsSetInt, + printSettingsGetPaperWidth, + printSettingsSetPaperWidth, + printSettingsGetPaperHeight, + printSettingsSetPaperHeight, +#if GTK_CHECK_VERSION(2,16,0) + printSettingsSetResolutionXy, + printSettingsGetResolutionX, + printSettingsGetResolutionY, +#endif + -- printSettingsGetPageRanges, + -- printSettingsSetPageRanges, +#if GTK_CHECK_VERSION(2,14,0) + printSettingsLoadFile, +#endif +#if GTK_CHECK_VERSION(2,12,0) + printSettingsToFile, +#endif + +-- * Attributes + printSettingsPrinter, [_$_] + printSettingsOrientation, + printSettingsPaperSize, + printSettingsUseColor, + printSettingsCollate, + printSettingsReverse, + printSettingsDuplex, + printSettingsQuality, + printSettingsNCopies, + printSettingsNumberUp, + printSettingsResolution, + printSettingsScale, + printSettingsPrintPages, + printSettingsPageSet, + printSettingsDefaultSource, + printSettingsMediaType, + printSettingsDither, + printSettingsFinishings, + printSettingsOutputBin, +#if GTK_CHECK_VERSION(2,14,0) + printSettingsNumberUpLayout, +#endif +#if GTK_CHECK_VERSION(2,16,0) + printSettingsPrinterLpi, +#endif +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.UTFString +import System.Glib.GError +{#import Graphics.UI.Gtk.Types#} +import Graphics.UI.Gtk.Printing.PaperSize (PaperSize(PaperSize), mkPaperSize, Unit(..)) + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Enums +{#enum PageOrientation {underscoreToCase} deriving (Bounded,Eq,Show)#} + +{#enum PrintQuality {underscoreToCase} deriving (Bounded,Eq,Show)#} + +{#enum PrintDuplex {underscoreToCase} deriving (Bounded,Eq,Show)#} + +{#enum PrintPages {underscoreToCase} deriving (Bounded,Eq,Show)#} + +{#enum PageSet {underscoreToCase} deriving (Bounded,Eq,Show)#} + +#if GTK_CHECK_VERSION(2,14,0) +-- | Used to determine the layout of pages on a sheet when printing multiple pages per sheet. +{#enum NumberUpLayout {underscoreToCase} deriving (Bounded,Eq,Show)#} +#endif + +-------------------- +-- Constructors + +-- | Creates a new 'PrintSettings' object. +-- +printSettingsNew :: IO PrintSettings +printSettingsNew = + constructNewGObject mkPrintSettings $ + {# call gtk_print_settings_new #} + +#if GTK_CHECK_VERSION(2,12,0) +-- | Reads the print settings from @fileName@. Returns a new 'PrintSettings' +-- object with the restored settings. +-- +-- * Available since Gtk+ version 2.12 +-- +printSettingsNewFromFile :: + String -- ^ @fileName@ - the filename to read the settings from + -> IO PrintSettings +printSettingsNewFromFile fileName = + constructNewGObject mkPrintSettings $ + propagateGError $ \errorPtr -> + withUTFString fileName $ \fileNamePtr -> [_$_] + {# call gtk_print_settings_new_from_file #} + fileNamePtr + errorPtr + +#endif + +-------------------- +-- Methods + +-- | Copies a 'PrintSettings' object. +-- +printSettingsCopy :: PrintSettingsClass self => self + -> IO PrintSettings -- ^ returns a newly allocated copy of @other@ +printSettingsCopy self = + makeNewGObject mkPrintSettings $ + {# call gtk_print_settings_copy #} + (toPrintSettings self) + +-- | Returns @True@, if a value is associated with @key@. +-- +printSettingsHasKey :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO Bool -- ^ returns @True@, if @key@ has a value +printSettingsHasKey self key = + liftM toBool $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_has_key #} + (toPrintSettings self) + keyPtr + +-- | Looks up the string value associated with @key@. +-- +printSettingsGet :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO String -- ^ returns the string value for @key@ +printSettingsGet self key = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get #} + (toPrintSettings self) + keyPtr + >>= peekUTFString + +-- | Associates @value@ with @key@. +-- +printSettingsSet :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> String -- ^ @value@ - a string value + -> IO () +printSettingsSet self key value = + withUTFString value $ \valuePtr -> + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_set #} + (toPrintSettings self) + keyPtr + valuePtr + +-- | Removes any value associated with @key@ +-- +printSettingsUnset :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO () +printSettingsUnset self key = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_unset #} + (toPrintSettings self) + keyPtr + +-- | Calls @func@ for each key-value pair of @settings@. +-- +printSettingsForeach :: PrintSettingsClass self => self + -> (String -> IO ()) -- ^ @func@ - the function to call + -> IO () +printSettingsForeach self func = do + funcPtr <- mkPrintSettingsFunc $ \_ strPtr _ -> do + str <- peekCString strPtr + func str + {# call gtk_print_settings_foreach #} + (toPrintSettings self) + funcPtr + (castFunPtrToPtr funcPtr) + +{#pointer PrintSettingsFunc#} + +foreign import ccall "wrapper" mkPrintSettingsFunc :: [_$_] + (CString -> CString -> Ptr () -> IO ()) + -> IO PrintSettingsFunc [_$_] + +-- | Returns the boolean represented by the value that is associated with +-- @key@. +-- +-- The string \"true\" represents @True@, any other string @False@. +-- +printSettingsGetBool :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO Bool -- ^ returns @True@, if @key@ maps to a true value. +printSettingsGetBool self key = + liftM toBool $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_bool #} + (toPrintSettings self) + keyPtr + +-- | Sets @key@ to a boolean value. +-- +printSettingsSetBool :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Bool -- ^ @value@ - a boolean + -> IO () +printSettingsSetBool self key value = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_set_bool #} + (toPrintSettings self) + keyPtr + (fromBool value) + +-- | Returns the double value associated with @key@, or 0. +-- +printSettingsGetDouble :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO Double -- ^ returns the double value of @key@ +printSettingsGetDouble self key = + liftM realToFrac $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_double #} + (toPrintSettings self) + keyPtr + +-- | Returns the floating point number represented by the value that is +-- associated with @key@, or @defaultVal@ if the value does not represent a +-- floating point number. +-- +-- Floating point numbers are parsed with 'gAsciiStrtod'. +-- +printSettingsGetDoubleWithDefault :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Double -- ^ @def@ - the default value + -> IO Double -- ^ returns the floating point number associated with @key@ +printSettingsGetDoubleWithDefault self key def = + liftM realToFrac $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_double_with_default #} + (toPrintSettings self) + keyPtr + (realToFrac def) + +-- | Sets @key@ to a double value. +-- +printSettingsSetDouble :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Double -- ^ @value@ - a double value + -> IO () +printSettingsSetDouble self key value = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_set_double #} + (toPrintSettings self) + keyPtr + (realToFrac value) + +-- | Returns the value associated with @key@, interpreted as a length. The +-- returned value is converted to @units@. +-- +printSettingsGetLength :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Unit -- ^ @unit@ - the unit of the return value + -> IO Double -- ^ returns the length value of @key@, converted to @unit@ +printSettingsGetLength self key unit = + liftM realToFrac $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_length #} + (toPrintSettings self) + keyPtr + ((fromIntegral . fromEnum) unit) + +-- | Associates a length in units of @unit@ with @key@. +-- +printSettingsSetLength :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Double -- ^ @value@ - a length + -> Unit -- ^ @unit@ - the unit of @length@ + -> IO () +printSettingsSetLength self key value unit = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_set_length #} + (toPrintSettings self) + keyPtr + (realToFrac value) + ((fromIntegral . fromEnum) unit) + +-- | Returns the integer value of @key@, or 0. +-- +printSettingsGetInt :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> IO Int -- ^ returns the integer value of @key@ +printSettingsGetInt self key = + liftM fromIntegral $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_int #} + (toPrintSettings self) + keyPtr + +-- | Returns the value of @key@, interpreted as an integer, or the default +-- value. +-- +printSettingsGetIntWithDefault :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Int -- ^ @def@ - the default value + -> IO Int -- ^ returns the integer value of @key@ +printSettingsGetIntWithDefault self key def = + liftM fromIntegral $ + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_get_int_with_default #} + (toPrintSettings self) + keyPtr + (fromIntegral def) + +-- | Sets @key@ to an integer value. +-- +printSettingsSetInt :: PrintSettingsClass self => self + -> String -- ^ @key@ - a key + -> Int -- ^ @value@ - an integer + -> IO () +printSettingsSetInt self key value = + withUTFString key $ \keyPtr -> + {# call gtk_print_settings_set_int #} + (toPrintSettings self) + keyPtr + (fromIntegral value) + +-- | Convenience function to obtain the value of ''PrintSettingsPrinter''. +printSettingsGetPrinter :: PrintSettingsClass self => self + -> IO String -- ^ returns the printer name +printSettingsGetPrinter self = + {# call gtk_print_settings_get_printer #} + (toPrintSettings self) + >>= peekUTFString + +-- | Convenience function to obtain the value of ''PrintSettingsPrinter''. +printSettingsSetPrinter :: PrintSettingsClass self => self + -> String -- ^ @printer@ - the printer name + -> IO () +printSettingsSetPrinter self printer = + withUTFString printer $ \printerPtr -> + {# call gtk_print_settings_set_printer #} + (toPrintSettings self) + printerPtr + +-- | Get the value of ''PrintSettingsOrientation'', converted to a 'PageOrientation'. +printSettingsGetOrientation :: PrintSettingsClass self => self + -> IO PageOrientation -- ^ returns the orientation +printSettingsGetOrientation self = + liftM (toEnum . fromIntegral) $ + {# call gtk_print_settings_get_orientation #} + (toPrintSettings self) + +-- | Sets the value of ''PrintSettingsOrientation''. +printSettingsSetOrientation :: PrintSettingsClass self => self + -> PageOrientation -- ^ @orientation@ - a page orientation + -> IO () +printSettingsSetOrientation self orientation = + {# call gtk_print_settings_set_orientation #} + (toPrintSettings self) + ((fromIntegral . fromEnum) orientation) + +-- | Gets the value of 'PrintSettingsPaperFormat', converted to a 'PaperSize'. +printSettingsGetPaperSize :: PrintSettingsClass self => self + -> IO PaperSize -- ^ returns the paper size +printSettingsGetPaperSize self = [_$_] + {# call gtk_print_settings_get_paper_size #} + (toPrintSettings self) + >>= mkPaperSize . castPtr + +-- | Sets the value of 'PrintSettingsPaperFormat', 'PrintSettingsPaperWidth' and +-- 'PrintSettingsPaperHeight'. +printSettingsSetPaperSize :: PrintSettingsClass self => self + -> PaperSize -- ^ @paperSize@ - a paper size + -> IO () +printSettingsSetPaperSize self (PaperSize paperSize) = + {# call gtk_print_settings_set_paper_size #} + (toPrintSettings self) + (castPtr $ unsafeForeignPtrToPtr $ paperSize) + +-- | Gets the value of 'PrintSettingsPaperWidth', converted to unit. +-- +printSettingsGetPaperWidth :: PrintSettingsClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the paper width, in units of @unit@ +printSettingsGetPaperWidth self unit = + liftM realToFrac $ + {# call gtk_print_settings_get_paper_width #} + (toPrintSettings self) + ((fromIntegral . fromEnum)... [truncated message content] |
From: Andy S. <And...@co...> - 2010-09-22 08:28:15
|
diffing dir... Wed Sep 22 04:24:24 EDT 2010 Andy Stewart <laz...@gm...> * Fix / docs with haddock style Ignore-this: 8e06132c9e89bef09e785eaab18ff336 { hunk ./gtk/Graphics/UI/Gtk/Abstract/Range.chs 463 --- | Get/Set sliders range along the long dimension, in 'DrawWindow' coordinates. +-- | Get\/Set sliders range along the long dimension, in 'DrawWindow' coordinates. hunk ./gtk/Graphics/UI/Gtk/Entry/Entry.chs 637 --- * Arrow keys move by individual characters/lines [_$_] --- * Ctrl-arrow key combinations move by words/paragraphs [_$_] --- * Home/End keys move to the ends of the buffer +-- * Arrow keys move by individual characters\/lines [_$_] +-- * Ctrl-arrow key combinations move by words\/paragraphs [_$_] +-- * Home\/End keys move to the ends of the buffer hunk ./gtk/Graphics/UI/Gtk/General/General.chs 260 --- 1. Compress enter/leave notify events. If the event passed build an enter/leave pair together with +-- 1. Compress enter\/leave notify events. If the event passed build an enter\/leave pair together with } |
From: Andy S. <And...@co...> - 2010-09-22 08:28:08
|
diffing dir... Tue Sep 21 23:07:20 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Printing.PrintContext Ignore-this: 7fd46cc3a7cf17f4390a6dac9423969c { hunk ./TODO 6 -gtk/Graphics/UI/Gtk/Printing/PrintContext.chs hunk ./gtk/Graphics/UI/Gtk.chs 211 + module Graphics.UI.Gtk.Printing.PrintContext, hunk ./gtk/Graphics/UI/Gtk.chs 440 +import Graphics.UI.Gtk.Printing.PrintContext addfile ./gtk/Graphics/UI/Gtk/Printing/PrintContext.chs hunk ./gtk/Graphics/UI/Gtk/Printing/PrintContext.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget PrintContext +-- +-- Author : Andy Stewart +-- +-- Created: 28 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) +-- +-- Encapsulates context for drawing pages +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Printing.PrintContext ( + +-- * Detail +-- +-- | A 'PrintContext' encapsulates context information that is required when +-- drawing pages for printing, such as the cairo context and important +-- parameters like page size and resolution. It also lets you easily create +-- 'PangoLayout' and 'Context' objects that match the font metrics of the cairo +-- surface. +-- +-- 'PrintContext' objects gets passed to the ::begin-print, ::end-print, +-- ::request-page-setup and ::draw-page signals on the 'PrintOperation'. +-- +-- Printing support was added in Gtk+ 2.10. + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----PrintContext +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + PrintContext, + PrintContextClass, + castToPrintContext, + toPrintContext, + +-- * Methods + printContextGetCairoContext, + printContextSetCairoContext, + printContextGetPageSetup, + printContextGetWidth, + printContextGetHeight, + printContextGetDpiX, + printContextGetDpiY, + printContextGetPangoFontmap, + printContextCreatePangoContext, + printContextCreatePangoLayout, +#endif + ) where + +import Control.Monad (liftM) +import Data.IORef (newIORef) + +import System.Glib.FFI +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.Rendering.Pango.Types#} +{#import Graphics.Rendering.Pango.BasicTypes#} +{#import Graphics.Rendering.Cairo.Types#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Methods + +-- | Obtains the cairo context that is associated with the 'PrintContext'. +-- +printContextGetCairoContext :: PrintContextClass self => self + -> IO Cairo -- ^ returns the cairo context of @context@ +printContextGetCairoContext self = [_$_] + liftM Cairo $ + {# call gtk_print_context_get_cairo_context #} (toPrintContext self) + +-- | Sets a new cairo context on a print context. +-- +-- This function is intended to be used when implementing an internal print +-- preview, it is not needed for printing, since Gtk+ itself creates a suitable +-- cairo context in that case. +-- +printContextSetCairoContext :: PrintContextClass self => self + -> Cairo -- ^ @cr@ - the cairo context + -> Double -- ^ @dpiX@ - the horizontal resolution to use with @cr@ + -> Double -- ^ @dpiY@ - the vertical resolution to use with @cr@ + -> IO () +printContextSetCairoContext self cr dpiX dpiY = + {# call gtk_print_context_set_cairo_context #} + (toPrintContext self) + cr + (realToFrac dpiX) + (realToFrac dpiY) + +-- | Obtains the 'PageSetup' that determines the page dimensions of the +-- 'PrintContext'. +-- +printContextGetPageSetup :: PrintContextClass self => self + -> IO PageSetup -- ^ returns the page setup of @context@ +printContextGetPageSetup self = + makeNewGObject mkPageSetup $ + {# call gtk_print_context_get_page_setup #} + (toPrintContext self) + +-- | Obtains the width of the 'PrintContext', in pixels. +-- +printContextGetWidth :: PrintContextClass self => self + -> IO Double -- ^ returns the width of @context@ +printContextGetWidth self = + liftM realToFrac $ + {# call gtk_print_context_get_width #} + (toPrintContext self) + +-- | Obtains the height of the 'PrintContext', in pixels. +-- +printContextGetHeight :: PrintContextClass self => self + -> IO Double -- ^ returns the height of @context@ +printContextGetHeight self = + liftM realToFrac $ + {# call gtk_print_context_get_height #} + (toPrintContext self) + +-- | Obtains the horizontal resolution of the 'PrintContext', in dots per +-- inch. +-- +printContextGetDpiX :: PrintContextClass self => self + -> IO Double -- ^ returns the horizontal resolution of @context@ +printContextGetDpiX self = + liftM realToFrac $ + {# call gtk_print_context_get_dpi_x #} + (toPrintContext self) + +-- | Obtains the vertical resolution of the 'PrintContext', in dots per inch. +-- +printContextGetDpiY :: PrintContextClass self => self + -> IO Double -- ^ returns the vertical resolution of @context@ +printContextGetDpiY self = + liftM realToFrac $ + {# call gtk_print_context_get_dpi_y #} + (toPrintContext self) + +-- | Returns a 'FontMap' that is suitable for use with the 'PrintContext'. +-- +printContextGetPangoFontmap :: PrintContextClass self => self + -> IO FontMap -- ^ returns the font map of @context@ +printContextGetPangoFontmap self = + makeNewGObject mkFontMap $ + {# call gtk_print_context_get_pango_fontmap #} + (toPrintContext self) + +-- | Creates a new 'Context' that can be used with the 'PrintContext'. +-- +printContextCreatePangoContext :: PrintContextClass self => self + -> IO PangoContext -- ^ returns a new Pango context for @context@ +printContextCreatePangoContext self = + makeNewGObject mkPangoContext $ + {# call gtk_print_context_create_pango_context #} + (toPrintContext self) + +-- | Creates a new 'PangoLayout' that is suitable for use with the +-- 'PrintContext'. +-- +printContextCreatePangoLayout :: PrintContextClass self => self + -> IO PangoLayout -- ^ returns a new Pango layout for @context@ +printContextCreatePangoLayout self = do + pl <- constructNewGObject mkPangoLayoutRaw $ + {# call gtk_print_context_create_pango_layout #} + (toPrintContext self) + ps <- makeNewPangoString "" + psRef <- newIORef ps + return (PangoLayout psRef pl) +#endif hunk ./gtk/gtk.cabal 292 + Graphics.UI.Gtk.Printing.PrintContext hunk ./gtk/hierarchy.list 26 + GtkPrintContext if gtk-2.10 } |
From: Andy S. <And...@co...> - 2010-09-22 00:24:59
|
diffing dir... Tue Sep 21 20:23:56 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Printing.PageSetup Ignore-this: 8c25cf511bd571673a238119f813ff63 { hunk ./TODO 6 -gtk/Graphics/UI/Gtk/Printing/PageSetup.chs hunk ./gtk/Graphics/UI/Gtk.chs 210 + module Graphics.UI.Gtk.Printing.PageSetup, hunk ./gtk/Graphics/UI/Gtk.chs 438 +import Graphics.UI.Gtk.Printing.PageSetup hunk ./gtk/Graphics/UI/Gtk/General/Enums.chs 87 +#if GTK_CHECK_VERSION(2,10,0) + PageOrientation (..), +#endif + hunk ./gtk/Graphics/UI/Gtk/General/Enums.chs 433 +#if GTK_CHECK_VERSION(2,10,0) +{#enum PageOrientation {underscoreToCase} deriving (Eq,Show)#} +#endif + addfile ./gtk/Graphics/UI/Gtk/Printing/PageSetup.chs hunk ./gtk/Graphics/UI/Gtk/Printing/PageSetup.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget PageSetup +-- +-- Author : Andy Stewart +-- +-- Created: 28 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) +-- +-- Stores page setup information +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Printing.PageSetup ( + +-- * Detail +-- +-- | A 'PageSetup' object stores the page size, orientation and margins. The +-- idea is that you can get one of these from the page setup dialog and then +-- pass it to the 'PrintOperation' when printing. The benefit of splitting this +-- out of the 'PrintSettings' is that these affect the actual layout of the +-- page, and thus need to be set long before user prints. +-- +-- The margins specified in this object are the \"print margins\", i.e. the +-- parts of the page that the printer cannot print on. These are different from +-- the layout margins that a word processor uses; they are typically used to +-- determine the /minimal/ size for the layout margins. +-- +-- To obtain a 'PageSetup' use 'pageSetupNew' to get the defaults, or use +-- 'printRunPageSetupDialog' to show the page setup dialog and receive the +-- resulting page setup. +-- +-- Printing support was added in Gtk+ 2.10. +-- [_$_] + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----PageSetup +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + PageSetup, + PageSetupClass, + castToPageSetup, + toPageSetup, + +-- * Constructors + pageSetupNew, +#if GTK_CHECK_VERSION(2,12,0) + pageSetupNewFromFile, +#endif + +-- * Methods + pageSetupCopy, + pageSetupGetTopMargin, + pageSetupSetTopMargin, + pageSetupGetBottomMargin, + pageSetupSetBottomMargin, + pageSetupGetLeftMargin, + pageSetupSetLeftMargin, + pageSetupGetRightMargin, + pageSetupSetRightMargin, + pageSetupSetPaperSizeAndDefaultMargins, + pageSetupGetPaperWidth, + pageSetupGetPaperHeight, + pageSetupGetPageWidth, + pageSetupGetPageHeight, +#if GTK_CHECK_VERSION(2,14,0) + pageSetupLoadFile, +#endif +#if GTK_CHECK_VERSION(2,12,0) + pageSetupToFile, +#endif + +-- * Attributes + pageSetupOrientation, + pageSetupPaperSize, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.GError +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.UTFString +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Printing.PaperSize#} (PaperSize(..), mkPaperSize, Unit(..)) +import Graphics.UI.Gtk.General.Enums (PageOrientation(..)) + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Constructors + +-- | Creates a new 'PageSetup'. +-- +pageSetupNew :: IO PageSetup +pageSetupNew = + constructNewGObject mkPageSetup $ + {# call gtk_page_setup_new #} + +#if GTK_CHECK_VERSION(2,12,0) +-- | Reads the page setup from the file @fileName@. Returns a new 'PageSetup' +-- object with the restored page setup. +-- +-- * Available since Gtk+ version 2.12 +-- +pageSetupNewFromFile :: + String -- ^ @fileName@ - the filename to read the page setup from + -> IO PageSetup +pageSetupNewFromFile fileName = + propagateGError $ \errorPtr -> + withUTFString fileName $ \fileNamePtr -> do + setupPtr <- {# call gtk_page_setup_new_from_file #} + fileNamePtr + errorPtr + constructNewGObject mkPageSetup (return setupPtr) [_$_] + +#endif + +-------------------- +-- Methods + +-- | Copies a 'PageSetup'. +-- +pageSetupCopy :: PageSetupClass self => self + -> IO PageSetup -- ^ returns a copy of @other@ +pageSetupCopy self = + makeNewGObject mkPageSetup $ + {# call gtk_page_setup_copy #} + (toPageSetup self) + +-- | Gets the page orientation of the 'PageSetup'. +pageSetupGetOrientation :: PageSetupClass self => self + -> IO PageOrientation -- ^ returns the page orientation +pageSetupGetOrientation self = + liftM (toEnum . fromIntegral) $ + {# call gtk_page_setup_get_orientation #} + (toPageSetup self) + +-- | Sets the page orientation of the 'PageSetup'. +pageSetupSetOrientation :: PageSetupClass self => self + -> PageOrientation -- ^ @orientation@ - a 'PageOrientation' value + -> IO () +pageSetupSetOrientation self orientation = + {# call gtk_page_setup_set_orientation #} + (toPageSetup self) + ((fromIntegral . fromEnum) orientation) + +-- | Gets the paper size of the 'PageSetup'. +pageSetupGetPaperSize :: PageSetupClass self => self + -> IO PaperSize -- ^ returns the paper size +pageSetupGetPaperSize self = + {# call gtk_page_setup_get_paper_size #} + (toPageSetup self) + >>= mkPaperSize . castPtr + +pageSetupSetPaperSize :: PageSetupClass self => self + -> PaperSize -- ^ @size@ - a 'PaperSize' + -> IO () +pageSetupSetPaperSize self size = + {# call gtk_page_setup_set_paper_size #} + (toPageSetup self) + size + +-- | Gets the top margin in units of @unit@. +-- +pageSetupGetTopMargin :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the top margin +pageSetupGetTopMargin self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_top_margin #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Sets the top margin of the 'PageSetup'. +-- +pageSetupSetTopMargin :: PageSetupClass self => self + -> Double -- ^ @margin@ - the new top margin in units of @unit@ + -> Unit -- ^ @unit@ - the units for @margin@ + -> IO () +pageSetupSetTopMargin self margin unit = + {# call gtk_page_setup_set_top_margin #} + (toPageSetup self) + (realToFrac margin) + ((fromIntegral . fromEnum) unit) + +-- | Gets the bottom margin in units of @unit@. +-- +pageSetupGetBottomMargin :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the bottom margin +pageSetupGetBottomMargin self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_bottom_margin #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Sets the bottom margin of the 'PageSetup'. +-- +pageSetupSetBottomMargin :: PageSetupClass self => self + -> Double -- ^ @margin@ - the new bottom margin in units of @unit@ + -> Unit -- ^ @unit@ - the units for @margin@ + -> IO () +pageSetupSetBottomMargin self margin unit = + {# call gtk_page_setup_set_bottom_margin #} + (toPageSetup self) + (realToFrac margin) + ((fromIntegral . fromEnum) unit) + +-- | Gets the left margin in units of @unit@. +-- +pageSetupGetLeftMargin :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the left margin +pageSetupGetLeftMargin self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_left_margin #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Sets the left margin of the 'PageSetup'. +-- +pageSetupSetLeftMargin :: PageSetupClass self => self + -> Double -- ^ @margin@ - the new left margin in units of @unit@ + -> Unit -- ^ @unit@ - the units for @margin@ + -> IO () +pageSetupSetLeftMargin self margin unit = + {# call gtk_page_setup_set_left_margin #} + (toPageSetup self) + (realToFrac margin) + ((fromIntegral . fromEnum) unit) + +-- | Gets the right margin in units of @unit@. +-- +pageSetupGetRightMargin :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the right margin +pageSetupGetRightMargin self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_right_margin #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Sets the right margin of the 'PageSetup'. +-- +pageSetupSetRightMargin :: PageSetupClass self => self + -> Double -- ^ @margin@ - the new right margin in units of @unit@ + -> Unit -- ^ @unit@ - the units for @margin@ + -> IO () +pageSetupSetRightMargin self margin unit = + {# call gtk_page_setup_set_right_margin #} + (toPageSetup self) + (realToFrac margin) + ((fromIntegral . fromEnum) unit) + +-- | Sets the paper size of the 'PageSetup' and modifies the margins according +-- to the new paper size. +-- +pageSetupSetPaperSizeAndDefaultMargins :: PageSetupClass self => self + -> PaperSize -- ^ @size@ - a 'PaperSize' + -> IO () +pageSetupSetPaperSizeAndDefaultMargins self size = + {# call gtk_page_setup_set_paper_size_and_default_margins #} + (toPageSetup self) + size + +-- | Returns the paper width in units of @unit@. +-- +-- Note that this function takes orientation, but not margins into +-- consideration. See 'pageSetupGetPageWidth'. +-- +pageSetupGetPaperWidth :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the paper width. +pageSetupGetPaperWidth self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_paper_width #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Returns the paper height in units of @unit@. +-- +-- Note that this function takes orientation, but not margins into +-- consideration. See 'pageSetupGetPageHeight'. +-- +pageSetupGetPaperHeight :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the paper height. +pageSetupGetPaperHeight self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_paper_height #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Returns the page width in units of @unit@. +-- +-- Note that this function takes orientation and margins into consideration. +-- See 'pageSetupGetPaperWidth'. +-- +pageSetupGetPageWidth :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the page width. +pageSetupGetPageWidth self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_page_width #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +-- | Returns the page height in units of @unit@. +-- +-- Note that this function takes orientation and margins into consideration. +-- See 'pageSetupGetPaperHeight'. +-- +pageSetupGetPageHeight :: PageSetupClass self => self + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the page height. +pageSetupGetPageHeight self unit = + liftM realToFrac $ + {# call gtk_page_setup_get_page_height #} + (toPageSetup self) + ((fromIntegral . fromEnum) unit) + +#if GTK_CHECK_VERSION(2,14,0) +-- | Reads the page setup from the file @fileName@. See 'pageSetupToFile'. +-- +-- * Available since Gtk+ version 2.14 +-- +pageSetupLoadFile :: PageSetupClass self => self + -> String -- ^ @fileName@ - the filename to read the page setup from + -> IO Bool -- ^ returns @True@ on success +pageSetupLoadFile self fileName = + liftM toBool $ + propagateGError $ \errorPtr -> + withUTFString fileName $ \fileNamePtr -> + {# call gtk_page_setup_load_file #} + (toPageSetup self) + fileNamePtr + errorPtr + +#endif + +#if GTK_CHECK_VERSION(2,12,0) +-- | This function saves the information from @setup@ to @fileName@. +-- +-- * Available since Gtk+ version 2.12 +-- +pageSetupToFile :: PageSetupClass self => self + -> String -- ^ @fileName@ - the file to save to + -> IO Bool -- ^ returns @True@ on success +pageSetupToFile self fileName = + liftM toBool $ + propagateGError $ \errorPtr -> + withUTFString fileName $ \fileNamePtr -> + {# call gtk_page_setup_to_file #} + (toPageSetup self) + fileNamePtr + errorPtr + +#endif +-- | The page orientation of the 'PageSetup'. +pageSetupOrientation :: PageSetupClass self => Attr self PageOrientation +pageSetupOrientation = newAttr + pageSetupGetOrientation + pageSetupSetOrientation + +-- | The paper size of the 'PageSetup'. +pageSetupPaperSize :: PageSetupClass self => Attr self PaperSize +pageSetupPaperSize = newAttr + pageSetupGetPaperSize + pageSetupSetPaperSize + +#endif + hunk ./gtk/Graphics/UI/Gtk/Printing/PaperSize.chs 47 + mkPaperSize, hunk ./gtk/gtk.cabal 291 + Graphics.UI.Gtk.Printing.PageSetup hunk ./gtk/hierarchy.list 25 + GtkPageSetup if gtk-2.10 } |
From: Andy S. <And...@co...> - 2010-09-21 19:59:05
|
diffing dir... Tue Sep 21 15:43:48 EDT 2010 Andy Stewart <laz...@gm...> * Fix docs of RecentInfo.chs Ignore-this: ce6bb97ded342cb03f8369b4bfb96f0 hunk ./gtk/Graphics/UI/Gtk/Recent/RecentInfo.chs 246 --- example, calling this function on an item that refers to "file:///foo/bar.txt" will yield "bar.txt". +-- example, calling this function on an item that refers to \"file:///foo/bar.txt\" will yield \"bar.txt\". |
From: Andy S. <And...@co...> - 2010-09-21 19:59:02
|
diffing dir... Tue Sep 21 15:39:15 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Printing.PaperSize (Axel, if you have time, best check it :) Ignore-this: 33a6c2deecb632e9c788835d9d99cf8e { hunk ./TODO 7 -gtk/Graphics/UI/Gtk/Printing/PaperSize.chs hunk ./gtk/Graphics/UI/Gtk.chs 208 + -- * Printing + module Graphics.UI.Gtk.Printing.PaperSize, hunk ./gtk/Graphics/UI/Gtk.chs 435 +-- printing +import Graphics.UI.Gtk.Printing.PaperSize adddir ./gtk/Graphics/UI/Gtk/Printing addfile ./gtk/Graphics/UI/Gtk/Printing/PaperSize.chs hunk ./gtk/Graphics/UI/Gtk/Printing/PaperSize.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget PaperSize +-- +-- Author : Andy Stewart +-- +-- Created: 28 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) +-- +-- Support for named paper sizes +-- +module Graphics.UI.Gtk.Printing.PaperSize ( + +-- * Detail +-- +-- | 'PaperSize' handles paper sizes. It uses the +-- standard called \"PWG 5101.1-2002 PWG: Standard for Media Standardized +-- Names\" to name the paper sizes (and to get the data for the page sizes). In +-- addition to standard paper sizes, 'PaperSize' allows +-- to construct custom paper sizes with arbitrary dimensions. +-- +-- The 'PaperSize' object stores not only the +-- dimensions (width and height) of a paper size and its name, it also provides +-- default print margins. +-- +-- Printing support has been added in Gtk+ 2.10. + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + PaperSize(..), + +-- * Enums + Unit(..), + +-- * Constructors + paperSizeNew, + paperSizeNewFromPpd, + paperSizeNewCustom, + +-- * Methods + paperSizeCopy, + paperSizeIsEqual, + paperSizeGetName, + paperSizeGetDisplayName, + paperSizeGetPpdName, + paperSizeGetWidth, + paperSizeGetHeight, + paperSizeIsCustom, + paperSizeSetSize, + paperSizeGetDefaultTopMargin, + paperSizeGetDefaultBottomMargin, + paperSizeGetDefaultLeftMargin, + paperSizeGetDefaultRightMargin, + paperSizeGetDefault, +#endif +#if GTK_CHECK_VERSION(2,12,0) + paperSizeGetPaperSizes, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.UTFString +import System.Glib.GList +{#import Graphics.UI.Gtk.Types#} + +{# context lib="gtk" prefix="gtk" #} + +-------------------- +-- Types +{#pointer *PaperSize foreign newtype#} + +-------------------- +-- Enums +{#enum Unit {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-------------------- +-- Constructors + +mkPaperSize :: Ptr PaperSize -> IO PaperSize +mkPaperSize pPtr = do + size <- newForeignPtr pPtr paper_size_free + return (PaperSize size) + +foreign import ccall unsafe ">k_paper_size_free" + paper_size_free :: FinalizerPtr PaperSize + +#if GTK_CHECK_VERSION(2,10,0) +-- | Creates a new 'PaperSize' object by parsing a PWG +-- 5101.1-2002 paper name. +-- +-- If @name@ is Nothing, the default paper size is returned, see 'paperSizeGetDefault'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeNew :: + Maybe String -- ^ @name@ - a paper size name, or 'Nothing' + -> IO PaperSize +paperSizeNew name = + maybeWith withUTFString name $ \namePtr -> + {# call gtk_paper_size_new #} + namePtr + >>= mkPaperSize + +-- | Creates a new 'PaperSize' object by using PPD +-- information. +-- +-- If @ppdName@ is not a recognized PPD paper name, @ppdDisplayName@, +-- @width@ and @height@ are used to construct a custom 'PaperSize' object. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeNewFromPpd :: + String -- ^ @ppdName@ - a PPD paper name + -> String -- ^ @ppdDisplayName@ - the corresponding human-readable name + -> Double -- ^ @width@ - the paper width, in points + -> Double -- ^ @height@ - the paper height in points + -> IO PaperSize +paperSizeNewFromPpd ppdName ppdDisplayName width height = + withUTFString ppdDisplayName $ \ppdDisplayNamePtr -> + withUTFString ppdName $ \ppdNamePtr -> + {# call gtk_paper_size_new_from_ppd #} + ppdNamePtr + ppdDisplayNamePtr + (realToFrac width) + (realToFrac height) + >>= mkPaperSize + +-- | Creates a new 'PaperSize' object with the given +-- parameters. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeNewCustom :: + String -- ^ @name@ - the paper name + -> String -- ^ @displayName@ - the human-readable name + -> Double -- ^ @width@ - the paper width, in units of @unit@ + -> Double -- ^ @height@ - the paper height, in units of @unit@ + -> Unit -- ^ @unit@ - the unit for @width@ and @height@ + -> IO PaperSize +paperSizeNewCustom name displayName width height unit = + withUTFString displayName $ \displayNamePtr -> + withUTFString name $ \namePtr -> + {# call gtk_paper_size_new_custom #} + namePtr + displayNamePtr + (realToFrac width) + (realToFrac height) + ((fromIntegral . fromEnum) unit) + >>= mkPaperSize + + +-------------------- +-- Methods + +-- | Copies an existing 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeCopy :: PaperSize + -> IO PaperSize -- ^ returns a copy of @other@ +paperSizeCopy self = + {# call gtk_paper_size_copy #} self >>= mkPaperSize + +-- | Compares two 'PaperSize' objects. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeIsEqual :: PaperSize + -> PaperSize -- ^ @size2@ - another 'PaperSize' object + -> IO Bool -- ^ returns @True@, if @size1@ and @size2@ represent + -- the same paper size +paperSizeIsEqual self size2 = + liftM toBool $ + {# call gtk_paper_size_is_equal #} + self + size2 + +-- | Gets the name of the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetName :: PaperSize + -> IO String -- ^ returns the name of @size@ +paperSizeGetName self = + {# call gtk_paper_size_get_name #} + self + >>= peekUTFString + +-- | Gets the human-readable name of the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDisplayName :: PaperSize + -> IO String -- ^ returns the human-readable name of @size@ +paperSizeGetDisplayName self = + {# call gtk_paper_size_get_display_name #} + self + >>= peekUTFString + +-- | Gets the PPD name of the 'PaperSize', which may be +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetPpdName :: PaperSize + -> IO (Maybe String) -- ^ returns the PPD name of @size@, or 'Nothing' +paperSizeGetPpdName self = + {# call gtk_paper_size_get_ppd_name #} + self + >>= maybePeekUTFString + +-- | Gets the paper width of the 'PaperSize', in units +-- of @unit@. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetWidth :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the paper width +paperSizeGetWidth self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_width #} + self + ((fromIntegral . fromEnum) unit) + +-- | Gets the paper height of the 'PaperSize', in units +-- of @unit@. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetHeight :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the paper height +paperSizeGetHeight self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_height #} + self + ((fromIntegral . fromEnum) unit) + +-- | Returns @True@ if @size@ is not a standard paper size. +-- +paperSizeIsCustom :: PaperSize + -> IO Bool -- ^ returns whether @size@ is a custom paper size. +paperSizeIsCustom self = + liftM toBool $ + {# call gtk_paper_size_is_custom #} + self + +-- | Changes the dimensions of a @size@ to @width@ x @height@. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeSetSize :: PaperSize + -> Double -- ^ @width@ - the new width in units of @unit@ + -> Double -- ^ @height@ - the new height in units of @unit@ + -> Unit -- ^ @unit@ - the unit for @width@ and @height@ + -> IO () +paperSizeSetSize self width height unit = + {# call gtk_paper_size_set_size #} + self + (realToFrac width) + (realToFrac height) + ((fromIntegral . fromEnum) unit) + +-- | Gets the default top margin for the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDefaultTopMargin :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the default top margin +paperSizeGetDefaultTopMargin self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_default_top_margin #} + self + ((fromIntegral . fromEnum) unit) + +-- | Gets the default bottom margin for the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDefaultBottomMargin :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the default bottom margin +paperSizeGetDefaultBottomMargin self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_default_bottom_margin #} + self + ((fromIntegral . fromEnum) unit) + +-- | Gets the default left margin for the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDefaultLeftMargin :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the default left margin +paperSizeGetDefaultLeftMargin self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_default_left_margin #} + self + ((fromIntegral . fromEnum) unit) + +-- | Gets the default right margin for the 'PaperSize'. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDefaultRightMargin :: PaperSize + -> Unit -- ^ @unit@ - the unit for the return value + -> IO Double -- ^ returns the default right margin +paperSizeGetDefaultRightMargin self unit = + liftM realToFrac $ + {# call gtk_paper_size_get_default_right_margin #} + self + ((fromIntegral . fromEnum) unit) + +-- | Returns the name of the default paper size, which depends on the current +-- locale. +-- +-- * Available since Gtk+ version 2.10 +-- +paperSizeGetDefault :: + IO String -- ^ returns the name of the default paper size. +paperSizeGetDefault = + {# call gtk_paper_size_get_default #} + >>= peekUTFString + +#endif + +#if GTK_CHECK_VERSION(2,12,0) +-- | Creates a list of known paper sizes. +-- +-- * Available since Gtk+ version 2.12 +-- +paperSizeGetPaperSizes :: + Bool -- ^ @includeCustom@ - whether to include custom + -- paper sizes as defined in the page setup dialog + -> IO [PaperSize] +paperSizeGetPaperSizes includeCustom = do + glist <- {# call gtk_paper_size_get_paper_sizes #} (fromBool includeCustom) + list <- fromGList glist + mapM mkPaperSize list +#endif + hunk ./gtk/gtk.cabal 290 + Graphics.UI.Gtk.Printing.PaperSize } |
From: Andy S. <And...@co...> - 2010-09-16 17:30:36
|
diffing dir... Thu Sep 16 13:27:57 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Windows.Assistant Ignore-this: 1b38660f7a46dc7b90d101ae31174c05 { hunk ./gtk/Graphics/UI/Gtk.chs 75 + module Graphics.UI.Gtk.Windows.Assistant, hunk ./gtk/Graphics/UI/Gtk.chs 295 +import Graphics.UI.Gtk.Windows.Assistant addfile ./gtk/Graphics/UI/Gtk/Windows/Assistant.chs hunk ./gtk/Graphics/UI/Gtk/Windows/Assistant.chs 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 ( + +-- * 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, + castToAssistant, + toAssistant, + +-- * Enums. + AssistantPageType(..), + +-- * Constructors + assistantNew, + +-- * Methods + assistantGetNPages, + assistantGetNthPage, + assistantPrependPage, + assistantAppendPage, + assistantInsertPage, + assistantSetForwardPageFunc, + assistantAddActionWidget, + assistantRemoveActionWidget, + assistantUpdateButtonsState, + assistantSetPageType, + assistantGetPageType, + assistantSetPageTitle, + assistantGetPageTitle, + assistantSetPageHeaderImage, + assistantGetPageHeaderImage, + assistantSetPageSideImage, + assistantGetPageSideImage, + assistantSetPageComplete, + assistantGetPageComplete, + +-- * Attributes + assistantCurrentPage, + +-- * Child Attributes + assistantChildPageType, + assistantChildTitle, + assistantChildHeaderImage, + assistantChildSidebarImage, + assistantChildComplete, + +-- * Signals + assistantCancel, + assistantPrepare, + assistantApply, + assistantClose, +#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) +-------------------- +-- Enum +{#enum GtkAssistantPageType as AssistantPageType {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-------------------- +-- Constructors + +-- | Creates a new 'Assistant'. +-- +-- * Available since Gtk+ version 2.10 +-- +assistantNew :: IO Assistant +assistantNew = + makeNewObject mkAssistant $ + liftM (castPtr :: Ptr Widget -> Ptr Assistant) $ + {# call gtk_assistant_new #} + +-------------------- +-- Methods + +-- | Returns the page number of the current page +-- +-- * Available since Gtk+ version 2.10 +-- +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) + +-- | Switches the page to @pageNum@. Note that this will only be necessary in custom buttons, as the +-- assistant flow can be set with 'assistantSetForwardPageFunc'. +-- +-- * Available since Gtk+ version 2.10 +-- +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@ +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantGetNthPage :: AssistantClass self => self + -> Int -- ^ @pageNum@ - The index of a page in the @assistant@, or -1 + -- to get the last page; + -> IO (Maybe Widget) -- ^ returns The child widget, or 'Nothing' if @pageNum@ is out of bounds. [_$_] +assistantGetNthPage self pageNum = + maybeNull (makeNewObject mkWidget) $ + {# call gtk_assistant_get_nth_page #} + (toAssistant self) + (fromIntegral pageNum) + +-- | Prepends a page to the @assistant@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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 'Nothing' will make the assistant to use the +-- default forward function, which just goes to the next visible page. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantSetForwardPageFunc :: AssistantClass self => self + -> Maybe (Int -> IO Int) -- ^ @pageFunc@ - the 'AssistantPage', or 'Nothing' to use the default one. [_$_] + -> IO () +assistantSetForwardPageFunc self Nothing = do + {# call gtk_assistant_set_forward_page_func #} + (toAssistant self) + nullFunPtr + (castFunPtrToPtr nullFunPtr) + destroyFunPtr + +assistantSetForwardPageFunc self (Just pageFunc) = do + pfPtr <- mkAssistantPageFunc $ \ c _ -> do + result <- pageFunc (fromIntegral c) + return $ fromIntegral result + {# call gtk_assistant_set_forward_page_func #} + (toAssistant self) + pfPtr + (castFunPtrToPtr pfPtr) + destroyFunPtr + +{#pointer AssistantPageFunc#} + +foreign import ccall "wrapper" mkAssistantPageFunc :: + ({#type glong#} -> Ptr () -> IO {#type glong#}) + -> IO AssistantPageFunc + +-- | Sets the page type for @page@. The page type determines the page behavior +-- in the @assistant@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantGetPageHeaderImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO (Maybe Pixbuf) -- ^ returns the header image for @page@, or 'Nothing' if there's no header image for the page. +assistantGetPageHeaderImage self page = + maybeNull (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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantGetPageSideImage :: (AssistantClass self, WidgetClass page) => self + -> page -- ^ @page@ - a page of @assistant@ + -> IO (Maybe Pixbuf) -- ^ returns the side image for @page@, or 'Nothing' if there's no side image for the page. +assistantGetPageSideImage self page = + maybeNull (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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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'. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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'. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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 +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantCurrentPage :: AssistantClass self => Attr self Int +assistantCurrentPage = newAttr + assistantGetCurrentPage + assistantSetCurrentPage + +-------------------- +-- Child Attributes + +-- | The type of the assistant page. +-- +-- Default value: 'AssistantPageContent' +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantChildTitle :: AssistantClass self => Attr self String +assistantChildTitle = newAttrFromStringProperty "title" + +-- | The image that is displayed next to the page. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantChildHeaderImage :: AssistantClass self => Attr self Pixbuf +assistantChildHeaderImage = newAttrFromObjectProperty "header-image" + {# call pure unsafe gdk_pixbuf_get_type #} + +-- | Sidebar image for the assistant page. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +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@ +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantChildComplete :: AssistantClass self => Attr self Bool +assistantChildComplete = newAttrFromBoolProperty "complete" + +-------------------- +-- Signals + +-- | The ::assistantCancel signal is emitted when then the assistantCancel button is clicked. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantCancel :: AssistantClass self => Signal self (IO ()) +assistantCancel = Signal (connect_NONE__NONE "cancel") + +-- | The ::assistantPrepare 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@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantPrepare :: AssistantClass self => Signal self (Widget -> IO ()) +assistantPrepare = Signal (connect_OBJECT__NONE "prepare") + +-- | The ::assistantApply signal is emitted when the assistantApply 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 ::assistantApply 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 'assistantPrepare' signal of the progress page. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +assistantApply :: AssistantClass self => Signal self (IO ()) +assistantApply = Signal (connect_NONE__NONE "apply") + +-- | The ::assistantClose signal is emitted either when the assistantClose button of a summary +-- page is clicked, or when the apply button in the last page in the flow (of +-- type 'AssistantPageConfirm') is clicked. +-- +assistantClose :: AssistantClass self => Signal self (IO ()) +assistantClose = Signal (connect_NONE__NONE "close") +#endif hunk ./gtk/gtk.cabal 316 + Graphics.UI.Gtk.Windows.Assistant hunk ./gtk/hierarchy.list 96 + GtkAssistant if gtk-2.10 } |
From: Andy S. <And...@co...> - 2010-09-13 07:44:39
|
diffing dir... Mon Sep 13 03:07:57 EDT 2010 Jens Petersen <pet...@ha...> * gtk-0.11.2 needs glib >= 0.11.2 for maybePeekUTFString Ignore-this: d397e1bd7e214a3ef01eb20a3d1bd7b5 hunk ./gtk/gtk.cabal 127 - glib >= 0.11.1 && < 0.12, + glib >= 0.11.2 && < 0.12, |
From: Andy S. <And...@co...> - 2010-09-12 14:18:56
|
diffing dir... Sun Sep 12 10:17:42 EDT 2010 Andy Stewart <laz...@gm...> * Fix typo and docs Ignore-this: 9e4150953e40f28d512b52f45dc68293 { hunk ./pango/Graphics/Rendering/Pango/Enums.chs 141 - strikethroughThickenss :: Double, + strikethroughThickness :: Double, hunk ./pango/Graphics/Rendering/Pango/Markup.chs 56 --- The full markup language can be found at --- <http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html>. --- } |
From: Andy S. <And...@co...> - 2010-09-12 10:03:28
|
diffing dir... Sun Sep 12 06:00:29 EDT 2010 Andy Stewart <laz...@gm...> * Add ByteString version functions. Ignore-this: d6f807c5418e289c240e46daa5d48056 Those functions handy for some network program (e.g. irc client), don't need convert between ByteString and String. { hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 82 + textBufferInsertByteString, hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 84 + textBufferInsertByteStringAtCursor, hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 86 + textBufferInsertByteStringInteractive, hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 88 + textBufferInsertByteStringInteractiveAtCursor, hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 276 +-- | Inserts @text@ at position @iter@. Similar +-- to 'textBufferInsert' but uses 'ByteString' buffers. +-- +-- * The passed-in buffer must contain a valid UTF-8 encoded string. +-- +textBufferInsertByteString :: TextBufferClass self => self + -> TextIter -- ^ @iter@ - a position in the buffer + -> ByteString -- ^ @text@ - text to insert + -> IO () +textBufferInsertByteString self iter text = + unsafeUseAsCStringLen text $ \(textPtr, len) -> + {# call text_buffer_insert #} + (toTextBuffer self) + iter + textPtr + (fromIntegral len) + hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 304 +-- | Simply calls 'textBufferInsert', using the current cursor position as the +-- insertion point. Similar to 'textBufferInsertAtCursor' but uses 'ByteString' buffers. +-- +-- * The passed-in buffer must contain a valid UTF-8 encoded string. +-- +textBufferInsertByteStringAtCursor :: TextBufferClass self => self -> ByteString -> IO () +textBufferInsertByteStringAtCursor self text = + unsafeUseAsCStringLen text $ \(textPtr, len) -> + {# call text_buffer_insert_at_cursor #} + (toTextBuffer self) + textPtr + (fromIntegral len) + hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 341 +-- | Similar to 'textBufferInsertInteractive' but uses 'ByteString' buffers. +-- +-- * The passed-in buffer must contain a valid UTF-8 encoded string. +-- +textBufferInsertByteStringInteractive :: TextBufferClass self => self + -> TextIter -- ^ @iter@ - a position in @buffer@ + -> ByteString -- ^ @text@ - the text to insert + -> Bool -- ^ @defaultEditable@ - default editability of buffer + -> IO Bool -- ^ returns whether text was actually inserted +textBufferInsertByteStringInteractive self iter text defaultEditable = + liftM toBool $ + unsafeUseAsCStringLen text $ \(textPtr, len) -> + {# call text_buffer_insert_interactive #} + (toTextBuffer self) + iter + textPtr + (fromIntegral len) + (fromBool defaultEditable) + hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 375 +-- | Similar to 'textBufferInsertInteractiveAtCursor' but uses 'ByteString' buffers. +-- +-- * The passed-in buffer must contain a valid UTF-8 encoded string. +-- +textBufferInsertByteStringInteractiveAtCursor :: TextBufferClass self => self + -> ByteString -- ^ @text@ - the text to insert + -> Bool -- ^ @defaultEditable@ - default editability of buffer + -> IO Bool -- ^ returns whether text was actually inserted +textBufferInsertByteStringInteractiveAtCursor self text defaultEditable = + liftM toBool $ + unsafeUseAsCStringLen text $ \(textPtr, len) -> + {# call text_buffer_insert_interactive_at_cursor #} + (toTextBuffer self) + textPtr + (fromIntegral len) + (fromBool defaultEditable) + } |
From: Andy S. <And...@co...> - 2010-09-11 11:55:45
|
diffing dir... Sat Sep 11 07:54:21 EDT 2010 Andy Stewart <laz...@gm...> * Fix docs Ignore-this: f5cf4155c18161a61e5d5261a133bbef { hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 256 --- \"insert_text\" signal; insertion actually occurs in the default handler for +-- 'insertText' signal; insertion actually occurs in the default handler for hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 366 --- actually emits the \"delete_range\" signal, and the default handler of that +-- actually emits the 'deleteRange' signal, and the default handler of that hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 601 --- belongs to a buffer. The \"mark_deleted\" signal will be emitted as +-- belongs to a buffer. The 'markDeleted' signal will be emitted as hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 679 --- | Emits the \"apply_tag\" signal on the buffer. The default handler for the +-- | Emits the 'applyTag' signal on the buffer. The default handler for the hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 695 --- | Emits the \"remove_tag\" signal. The default handler for the signal +-- | Emits the 'removeTag' signal. The default handler for the signal hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 862 --- modified bit flips, the buffer emits a \"modified_changed\" signal. +-- modified bit flips, the buffer emits a 'modifiedChanged' signal. hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 918 --- a call to 'textBufferEndUserAction', and emits the \"begin_user_action\" and --- \"end_user_action\" signals only for the outermost pair of calls. This +-- a call to 'textBufferEndUserAction', and emits the 'beginUserAction' and +-- 'endUserAction' signals only for the outermost pair of calls. This } |
From: Andy S. <And...@co...> - 2010-09-11 06:59:53
|
diffing dir... Sat Sep 11 02:59:04 EDT 2010 Andy Stewart <laz...@gm...> * Fix docs Ignore-this: 464f6a65b1b24526fa4bc949ab7b4fea hunk ./gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs 537 --- Emits the \"mark_set\" signal as notification of the mark's initial +-- Emits the 'markSet' signal as notification of the mark's initial |
From: Andy S. <And...@co...> - 2010-09-10 13:55:34
|
diffing dir... Fri Sep 10 09:54:03 EDT 2010 Andy Stewart <laz...@gm...> * Add new module ActionMenuToolbar.RecentAction Ignore-this: cdbfd37b62e462f2e0995009a8e2e599 { hunk ./TODO 13 -gtk/Graphics/UI/Gtk/ActionMenuToolbar/Action.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/ActionGroup.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/Activatable.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/RadioAction.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/ToggleAction.chs -gtk/Graphics/UI/Gtk/ActionMenuToolbar/UIManager.chs - hunk ./gtk/Graphics/UI/Gtk.chs 165 + module Graphics.UI.Gtk.ActionMenuToolbar.RecentAction, hunk ./gtk/Graphics/UI/Gtk.chs 390 +import Graphics.UI.Gtk.ActionMenuToolbar.RecentAction addfile ./gtk/Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs hunk ./gtk/Graphics/UI/Gtk/ActionMenuToolbar/RecentAction.chs 1 +{-# LANGUAGE CPP #-} +-- -*-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 : gtk...@li... +-- 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 +-- @ + +#if GTK_CHECK_VERSION(2,12,0) +-- * Types + RecentAction, + RecentActionClass, + castToRecentAction, + toRecentAction, + +-- * Constructors + recentActionNew, + recentActionNewForManager, + +-- * Attributes + recentActionShowNumbers, +#endif + ) where + +import Control.Monad (liftM) +import Data.Maybe (fromMaybe) + +import System.Glib.FFI +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.UTFString +import System.Glib.GObject (constructNewGObject) +{#import Graphics.UI.Gtk.Types#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,12,0) +-------------------- +-- Constructors + +-- | Creates a new 'RecentAction' object. To add the action to a 'ActionGroup' +-- and set the accelerator for the action, call +-- 'actionGroupAddActionWithAccel'. +-- +recentActionNew :: + 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 name label tooltip stockId = + constructNewGObject mkRecentAction $ [_$_] + liftM castPtr $ + withUTFString name $ \namePtr -> + maybeWith withUTFString label $ \labelPtr -> + maybeWith withUTFString tooltip $ \tooltipPtr -> + maybeWith withUTFString stockId $ \stockIdPtr -> + {# call gtk_recent_action_new #} + namePtr + labelPtr + tooltipPtr + 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 => + 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 name label tooltip stockId manager = + constructNewGObject mkRecentAction $ liftM castPtr $ + withUTFString name $ \namePtr -> + maybeWith withUTFString label $ \labelPtr -> + maybeWith withUTFString tooltip $ \tooltipPtr -> + maybeWith withUTFString stockId $ \stockIdPtr -> do + {# call gtk_recent_action_new_for_manager #} + namePtr + labelPtr + tooltipPtr + stockIdPtr + (maybe (RecentManager nullForeignPtr) toRecentManager manager) + +-------------------- +-- Attributes + +-- | If recent items should be shown with numbers next to them. +-- +recentActionShowNumbers :: RecentActionClass self => Attr self Bool +recentActionShowNumbers = newAttrFromBoolProperty "show-numbers" +#endif hunk ./gtk/gtk.cabal 155 + Graphics.UI.Gtk.ActionMenuToolbar.RecentAction hunk ./gtk/hierarchy.list 227 + GtkRecentAction if gtk-2.12 } |
From: Andy S. <And...@co...> - 2010-09-10 12:22:30
|
diffing dir... Fri Sep 10 08:21:39 EDT 2010 Andy Stewart <laz...@gm...> * Add new module Recent.RecentChooser Ignore-this: 63ffda2155253ef1f30109b56318d227 { hunk ./TODO 13 -gtk/Graphics/UI/Gtk/Recent/RecentChooser.chs - hunk ./gtk/Graphics/UI/Gtk.chs 212 + module Graphics.UI.Gtk.Recent.RecentChooser, hunk ./gtk/Graphics/UI/Gtk.chs 435 +import Graphics.UI.Gtk.Recent.RecentChooser addfile ./gtk/Graphics/UI/Gtk/Recent/RecentChooser.chs hunk ./gtk/Graphics/UI/Gtk/Recent/RecentChooser.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Interface RecentChooser +-- +-- Author : Andy Stewart +-- +-- Created: 27 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) +-- +-- Interface implemented by widgets displaying recently used files +-- +-- * Module available since Gtk+ version 2.10 +-- +module Graphics.UI.Gtk.Recent.RecentChooser ( + +-- * Detail +-- +-- | 'RecentChooser' is an interface that can be implemented by widgets +-- displaying the list of recently used files. In Gtk+, the main objects that +-- implement this interface are 'RecentChooserWidget', 'RecentChooserDialog' +-- and 'RecentChooserMenu'. +-- +-- Recently used files are supported since Gtk+ 2.10. + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GInterface' +-- | +----RecentChooser +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + RecentChooser, + RecentChooserClass, + castToRecentChooser, + toRecentChooser, + +-- * Enums + RecentChooserError(..), + RecentSortType(..), + +-- * Methods + recentChooserSetSortFunc, + recentChooserSetCurrentURI, + recentChooserGetCurrentURI, + recentChooserGetCurrentItem, + recentChooserSelectURI, + recentChooserUnselectURI, + recentChooserSelectAll, + recentChooserUnselectAll, + recentChooserGetItems, + recentChooserGetURIs, + recentChooserAddFilter, + recentChooserRemoveFilter, + recentChooserListFilters, + +-- * Attributes + recentChooserShowPrivate, + recentChooserShowTips, + recentChooserShowIcons, + recentChooserShowNotFound, + recentChooserSelectMultiple, + recentChooserLocalOnly, + recentChooserLimit, + recentChooserSortType, + recentChooserFilter, + +-- * Signals + recentChooserSelectionChanged, + recentChooserItemActivated, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.UTFString +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.GList +import System.Glib.GObject (Quark, quarkFromString) +import System.Glib.GError (GErrorDomain, GErrorClass(..), propagateGError, checkGError) +import Graphics.UI.Gtk.Abstract.Object (makeNewObject) +{#import Graphics.UI.Gtk.Recent.RecentInfo#} (RecentInfo, mkRecentInfo) +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Enums +-- | These identify the various errors that can occur while calling 'RecentChooser' functions. +{#enum RecentChooserError {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-- | Used to specify the sorting method to be applyed to the recently used resource list. +{#enum RecentSortType {underscoreToCase} deriving (Bounded,Eq,Show)#} + +-------------------- +-- Methods + +-- | Sets the comparison function used when sorting to be @sortFunc@. If the +-- @chooser@ has the sort type set to 'RecentSortCustom' then the chooser will +-- sort using this function. +-- +-- To the comparison function will be passed two 'RecentInfo' structs and @sortData@; @sortFunc@ should return a positive +-- integer if the first item comes before the second, zero if the two items are +-- equal and a negative integer if the first item comes after the second. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSetSortFunc :: RecentChooserClass self => self + -> (Maybe (RecentInfo -> IO Int)) + -> IO () +recentChooserSetSortFunc self Nothing = + {# call gtk_recent_chooser_set_sort_func #} + (toRecentChooser self) nullFunPtr nullPtr nullFunPtr +recentChooserSetSortFunc self (Just func) = do + fPtr <- mkRecentSortFunc $ \_ infoPtr _ -> do + info <- mkRecentInfo infoPtr + liftM fromIntegral (func info) + {# call gtk_recent_chooser_set_sort_func #} + (toRecentChooser self) + fPtr + (castFunPtrToPtr fPtr) + destroyFunPtr + +{#pointer RecentSortFunc#} + +foreign import ccall "wrapper" mkRecentSortFunc :: + (Ptr RecentInfo -> Ptr RecentInfo -> Ptr () -> IO {#type gint#}) + -> IO RecentSortFunc + +-- | Sets @uri@ as the current URI for @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSetCurrentURI :: RecentChooserClass self => self + -> String -- ^ @uri@ - a URI + -> IO Bool -- ^ returns @True@ if the URI was found. +recentChooserSetCurrentURI self uri = + checkGError ( \errorPtr -> + liftM toBool $ + withUTFString uri $ \uriPtr -> + {# call gtk_recent_chooser_set_current_uri #} + (toRecentChooser self) + uriPtr + errorPtr) + (\_ -> return False) + +-- | Gets the URI currently selected by @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserGetCurrentURI :: RecentChooserClass self => self + -> IO String -- ^ returns a newly string holding a URI. +recentChooserGetCurrentURI self = + {# call gtk_recent_chooser_get_current_uri #} + (toRecentChooser self) + >>= readUTFString + +-- | Gets the 'RecentInfo' currently selected by +-- @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserGetCurrentItem :: RecentChooserClass self => self + -> IO RecentInfo -- ^ returns a 'RecentInfo'. + -- Use 'recentInfoUnref' when when you have finished + -- using it. +recentChooserGetCurrentItem self = do + info <- {# call gtk_recent_chooser_get_current_item #} (toRecentChooser self) + mkRecentInfo info + +-- | Selects @uri@ inside @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSelectURI :: RecentChooserClass self => self + -> String -- ^ @uri@ - a URI + -> IO Bool -- ^ returns @True@ if @uri@ was found. +recentChooserSelectURI self uri = + checkGError ( \errorPtr -> + liftM toBool $ + withUTFString uri $ \uriPtr -> + {# call gtk_recent_chooser_select_uri #} + (toRecentChooser self) + uriPtr + errorPtr) + (\_ -> return False) + +-- | Unselects @uri@ inside @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserUnselectURI :: RecentChooserClass self => self + -> String -- ^ @uri@ - a URI + -> IO () +recentChooserUnselectURI self uri = + withUTFString uri $ \uriPtr -> + {# call gtk_recent_chooser_unselect_uri #} + (toRecentChooser self) + uriPtr + +-- | Selects all the items inside @chooser@, if the @chooser@ supports +-- multiple selection. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSelectAll :: RecentChooserClass self => self -> IO () +recentChooserSelectAll self = + {# call gtk_recent_chooser_select_all #} + (toRecentChooser self) + +-- | Unselects all the items inside @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserUnselectAll :: RecentChooserClass self => self -> IO () +recentChooserUnselectAll self = + {# call gtk_recent_chooser_unselect_all #} + (toRecentChooser self) + +-- | Gets the list of recently used resources in form of 'RecentInfo' +-- +-- The return value of this function is affected by the \"sort-type\" and +-- \"limit\" properties of @chooser@. +-- +recentChooserGetItems :: RecentChooserClass self => self + -> IO [RecentInfo] -- ^ returns A list of 'RecentInfo' objects. [_$_] +recentChooserGetItems self = do + glist <- {# call gtk_recent_chooser_get_items #} (toRecentChooser self) + list <- fromGList glist + mapM mkRecentInfo list + +-- | Gets the URI of the recently used resources. +-- +-- The return value of this function is affected by the \"sort-type\" and +-- \"limit\" properties of @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserGetURIs :: RecentChooserClass self => self + -> IO [String] +recentChooserGetURIs self = [_$_] + alloca $ \lengthPtr -> do + str <- {# call gtk_recent_chooser_get_uris #} + (toRecentChooser self) + lengthPtr + length <- peek lengthPtr + mapM peekUTFString =<< peekArray (fromIntegral length) str + +-- | Adds @filter@ to the list of 'RecentFilter' objects held by @chooser@. +-- +-- If no previous filter objects were defined, this function will call +-- 'recentChooserSetFilter'. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserAddFilter :: (RecentChooserClass self, RecentFilterClass filter) => self + -> filter -- ^ @filter@ - a 'RecentFilter' + -> IO () +recentChooserAddFilter self filter = + {# call gtk_recent_chooser_add_filter #} + (toRecentChooser self) + (toRecentFilter filter) + +-- | Removes @filter@ from the list of 'RecentFilter' objects held by +-- @chooser@. +-- +recentChooserRemoveFilter :: (RecentChooserClass self, RecentFilterClass filter) => self + -> filter -- ^ @filter@ - a 'RecentFilter' + -> IO () +recentChooserRemoveFilter self filter = + {# call gtk_recent_chooser_remove_filter #} + (toRecentChooser self) + (toRecentFilter filter) + +-- | Gets the 'RecentFilter' objects held by @chooser@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserListFilters :: RecentChooserClass self => self + -> IO [RecentFilter] -- ^ returns A singly linked list of 'RecentFilter'. +recentChooserListFilters self = do + glist <- {# call gtk_recent_chooser_list_filters #} + (toRecentChooser self) + list <- fromGList glist + mapM (\x -> makeNewObject mkRecentFilter (return (castPtr x))) list + +-------------------- +-- Attributes + +-- | Whether the private items should be displayed. +-- [_$_] +-- Default value: 'False' +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserShowPrivate :: RecentChooserClass self => Attr self Bool +recentChooserShowPrivate = newAttrFromBoolProperty "show-private" + +-- | Whether this 'RecentChooser' should display a tooltip containing the full path of the recently used +-- resources. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserShowTips :: RecentChooserClass self => Attr self Bool +recentChooserShowTips = newAttrFromBoolProperty "show-tips" + +-- | Whether this 'RecentChooser' should display an icon near the item. +-- [_$_] +-- Default value: 'True' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserShowIcons :: RecentChooserClass self => Attr self Bool +recentChooserShowIcons = newAttrFromBoolProperty "show-icons" + +-- | Whether this 'RecentChooser' should display the recently used resources even if not present +-- anymore. Setting this to 'False' will perform a potentially expensive check on every local resource +-- (every remote resource will always be displayed). +-- [_$_] +-- Default value: 'True' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserShowNotFound :: RecentChooserClass self => Attr self Bool +recentChooserShowNotFound = newAttrFromBoolProperty "show-not-found" + +-- | Allow the user to select multiple resources. +-- [_$_] +-- Default value: 'False' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSelectMultiple :: RecentChooserClass self => Attr self Bool +recentChooserSelectMultiple = newAttrFromBoolProperty "select-multiple" + +-- | Whether this 'RecentChooser' should display only local (file:) resources. +-- [_$_] +-- Default value: 'True' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserLocalOnly :: RecentChooserClass self => Attr self Bool +recentChooserLocalOnly = newAttrFromBoolProperty "local-only" + +-- | The maximum number of recently used resources to be displayed, or -1 to display all items. By +-- default, the 'Setting':gtk-recent-files-limit setting is respected: you can override that limit on +-- a particular instance of 'RecentChooser' by setting this property. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: -1 +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserLimit :: RecentChooserClass self => Attr self Int +recentChooserLimit = newAttrFromIntProperty "limit" + +-- | Sorting order to be used when displaying the recently used resources. +-- [_$_] +-- Default value: ''RecentSortNone'' +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSortType :: RecentChooserClass self => Attr self RecentSortType +recentChooserSortType = newAttrFromEnumProperty "sort-type" + {# call pure unsafe gtk_recent_sort_type_get_type #} + +-- | The 'RecentFilter' object to be used when displaying the recently used resources. +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserFilter :: (RecentChooserClass self, RecentFilterClass recentFilter) => ReadWriteAttr self RecentFilter recentFilter +recentChooserFilter = newAttrFromObjectProperty "filter" + {# call pure unsafe gtk_recent_filter_get_type #} + +-------------------- +-- Signals + +-- | This signal is emitted when there is a change in the set of selected +-- recently used resources. This can happen when a user modifies the selection +-- with the mouse or the keyboard, or when explicitely calling functions to +-- change the selection. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserSelectionChanged :: RecentChooserClass self => Signal self (IO ()) +recentChooserSelectionChanged = Signal (connect_NONE__NONE "selection_changed") + +-- | This signal is emitted when the user \"activates\" a recent item in the +-- recent chooser. This can happen by double-clicking on an item in the +-- recently used resources list, or by pressing Enter. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentChooserItemActivated :: RecentChooserClass self => Signal self (IO ()) +recentChooserItemActivated = Signal (connect_NONE__NONE "item_activated") +#endif hunk ./gtk/gtk.cabal 294 + Graphics.UI.Gtk.Recent.RecentChooser hunk ./gtk/hierarchy.list 25 + GtkRecentChooser if gtk-2.10 } |
From: Andy S. <And...@co...> - 2010-09-10 12:14:52
|
diffing dir... Fri Sep 10 08:00:42 EDT 2010 Andy Stewart <laz...@gm...> * Add new modules : Recent.RecentInfo and Recent.RecentManager Ignore-this: a84e33300b3374465cdfd4604ae9908e { hunk ./TODO 14 -gtk/Graphics/UI/Gtk/Recent/RecentInfo.chs -gtk/Graphics/UI/Gtk/Recent/RecentManager.chs hunk ./gtk/Graphics/UI/Gtk.chs 210 + module Graphics.UI.Gtk.Recent.RecentManager, + module Graphics.UI.Gtk.Recent.RecentInfo, hunk ./gtk/Graphics/UI/Gtk.chs 432 +import Graphics.UI.Gtk.Recent.RecentManager +import Graphics.UI.Gtk.Recent.RecentInfo addfile ./gtk/Graphics/UI/Gtk/Recent/RecentInfo.chs hunk ./gtk/Graphics/UI/Gtk/Recent/RecentInfo.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget RecentInfo +-- +-- Author : Andy Stewart +-- +-- Created: 27 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) +-- +-- +module Graphics.UI.Gtk.Recent.RecentInfo ( hunk ./gtk/Graphics/UI/Gtk/Recent/RecentInfo.chs 29 +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + RecentInfo, + mkRecentInfo, + +-- * Methods + recentInfoExists, + recentInfoGetAdded, + recentInfoGetAge, + recentInfoGetApplicationInfo, + recentInfoGetApplications, + recentInfoGetDescription, + recentInfoGetDisplayName, + recentInfoGetGroups, + recentInfoGetIcon, + recentInfoGetMimeType, + recentInfoGetModified, + recentInfoGetPrivateHint, + recentInfoGetShortName, + recentInfoGetURI, + recentInfoGetURIDisplay, + recentInfoGetVisited, + recentInfoHasApplication, + recentInfoHasGroup, + recentInfoIsLocal, + recentInfoLastApplication, + recentInfoMatch, +#endif + ) 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#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) +-------------------- +-- Types +{#pointer *RecentInfo foreign newtype#} + +-------------------- +-- Methods + +-- | Helper function for build 'RecentInfo' +mkRecentInfo :: Ptr RecentInfo -> IO RecentInfo +mkRecentInfo rPtr = do + info <- newForeignPtr rPtr gtk_recent_info_unref + return (RecentInfo info) + +foreign import ccall unsafe ">k_recent_info_unref" + gtk_recent_info_unref :: FinalizerPtr RecentInfo + +-- | Checks whether the resource pointed by info still exists. At the moment this check is done only on +-- resources pointing to local files. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoExists :: RecentInfo [_$_] + -> IO Bool -- ^ returns 'True' if the resource exists [_$_] +recentInfoExists self = + liftM toBool $ + {# call gtk_recent_info_exists #} + self + +-- | Gets the timestamp (seconds from system's Epoch) when the resource was added to the recently used +-- resources list. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetAdded :: RecentInfo [_$_] + -> IO Int -- ^ returns the number of seconds elapsed from system's Epoch when the resource was added to the list, or -1 on failure. +recentInfoGetAdded self = + liftM fromIntegral $ + {# call gtk_recent_info_get_added #} + self + +-- | Gets the number of days elapsed since the last update of the resource pointed by info. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetAge :: RecentInfo [_$_] + -> IO Int -- ^ returns a positive integer containing the number of days elapsed since the time this resource was last modified. +recentInfoGetAge self = + liftM fromIntegral $ + {# call gtk_recent_info_get_age #} + self + +-- | Gets the data regarding the application that has registered the resource pointed by info. +-- [_$_] +-- If the command line contains any escape characters defined inside the storage specification, they +-- will be expanded. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetApplicationInfo :: RecentInfo [_$_] + -> String -- ^ @appName@ the name of the application that has registered this item + -> IO (Maybe ([String], Int, Int)) + -- ^ @appExec@ return location for the string containing the command line. transfer none. + -- ^ @count@ return location for the number of times this item was registered. out. + -- ^ @time@ out. out. +recentInfoGetApplicationInfo self appName = + alloca $ \countPtr -> + alloca $ \timePtr -> + allocaArray 0 $ \execPtr -> [_$_] + withUTFString appName $ \appNamePtr -> do + success <- liftM toBool $ + {# call gtk_recent_info_get_application_info #} + self + appNamePtr + execPtr + countPtr + timePtr + if success [_$_] + then do + exec <- mapM peekUTFString =<< peekArray 0 execPtr + count <- peek countPtr + time <- peek timePtr + return (Just (exec, fromIntegral count, fromIntegral time)) + else return Nothing + +-- | Retrieves the list of applications that have registered this resource. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetApplications :: RecentInfo -> IO [String] +recentInfoGetApplications self = [_$_] + alloca $ \lengthPtr -> do + str <- {# call gtk_recent_info_get_applications #} self lengthPtr + length <- peek lengthPtr + mapM peekUTFString =<< peekArray (fromIntegral length) str + +-- | Gets the (short) description of the resource. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetDescription :: RecentInfo [_$_] + -> IO String -- ^ returns the description of the resource. [_$_] +recentInfoGetDescription self = + {# call gtk_recent_info_get_description #} + self + >>= peekUTFString + +-- | Gets the name of the resource. If none has been defined, the basename of the resource is obtained. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetDisplayName :: RecentInfo [_$_] + -> IO String -- ^ returns the display name of the resource. [_$_] +recentInfoGetDisplayName self = + {# call gtk_recent_info_get_display_name #} + self + >>= peekUTFString + +-- | Returns all groups registered for the recently used item info. [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetGroups :: RecentInfo -> IO [String] +recentInfoGetGroups self = [_$_] + alloca $ \lengthPtr -> do + str <- {# call gtk_recent_info_get_groups #} self lengthPtr + length <- peek lengthPtr + mapM peekUTFString =<< peekArray (fromIntegral length) str + +-- | Retrieves the icon of size size associated to the resource MIME type. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetIcon :: RecentInfo [_$_] + -> Int -- ^ @size@ the size of the icon in pixels + -> IO (Maybe Pixbuf) -- ^ returns a 'Pixbuf' containing the icon, or 'Nothing' +recentInfoGetIcon self size = + maybeNull (makeNewGObject mkPixbuf) $ + {# call gtk_recent_info_get_icon #} + self + (fromIntegral size) + +-- | Gets the MIME type of the resource. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetMimeType :: RecentInfo [_$_] + -> IO String -- ^ returns the MIME type of the resource. [_$_] +recentInfoGetMimeType self = + {# call gtk_recent_info_get_mime_type #} + self + >>= peekUTFString + +-- | Gets the timestamp (seconds from system's Epoch) when the resource was last modified. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetModified :: RecentInfo [_$_] + -> IO Int -- ^ returns the number of seconds elapsed from system's Epoch when the resource was last modified, or -1 on failure. +recentInfoGetModified self = + liftM fromIntegral $ + {# call gtk_recent_info_get_modified #} + self + +-- | Gets the value of the "private" flag. Resources in the recently used list that have this flag set to +-- 'True' should only be displayed by the applications that have registered them. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetPrivateHint :: RecentInfo [_$_] + -> IO Bool -- ^ returns 'True' if the private flag was found, 'False' otherwise. [_$_] +recentInfoGetPrivateHint self = + liftM toBool $ + {# call gtk_recent_info_get_private_hint #} + self + +-- | Computes a valid UTF-8 string that can be used as the name of the item in a menu or list. For +-- example, calling this function on an item that refers to "file:///foo/bar.txt" will yield "bar.txt". +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetShortName :: RecentInfo [_$_] + -> IO String +recentInfoGetShortName self = + {# call gtk_recent_info_get_short_name #} + self + >>= readUTFString + +-- | Gets the URI of the resource. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetURI :: RecentInfo [_$_] + -> IO String -- ^ returns the URI of the resource. [_$_] +recentInfoGetURI self = + {# call gtk_recent_info_get_uri #} + self + >>= peekUTFString + +-- | Gets a displayable version of the resource's URI. If the resource is local, it returns a local path; +-- if the resource is not local, it returns the UTF-8 encoded content of 'recentInfoGetUri'. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetURIDisplay :: RecentInfo -> IO String +recentInfoGetURIDisplay self = + {# call gtk_recent_info_get_uri_display #} + self + >>= readUTFString + +-- | Gets the timestamp (seconds from system's Epoch) when the resource was last visited. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoGetVisited :: RecentInfo [_$_] + -> IO Int -- ^ returns the number of seconds elapsed from system's Epoch when the resource was last visited, or -1 on failure. +recentInfoGetVisited self = + liftM fromIntegral $ + {# call gtk_recent_info_get_visited #} + self + +-- | Checks whether an application registered this resource using @appName@. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoHasApplication :: RecentInfo [_$_] + -> String -- ^ @appName@ a string containing an application name [_$_] + -> IO Bool -- ^ returns 'True' if an application with name @appName@ was found, 'False' otherwise. +recentInfoHasApplication self appName = + liftM toBool $ + withUTFString appName $ \appNamePtr -> + {# call gtk_recent_info_has_application #} + self + appNamePtr + +-- | Checks whether @groupName@ appears inside the groups registered for the recently used item info. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoHasGroup :: RecentInfo [_$_] + -> String -- ^ @groupName@ name of a group [_$_] + -> IO Bool -- ^ returns 'True' if the group was found. [_$_] +recentInfoHasGroup self groupName = + liftM toBool $ + withUTFString groupName $ \groupNamePtr -> + {# call gtk_recent_info_has_group #} + self + groupNamePtr + +-- | Checks whether the resource is local or not by looking at the scheme of its URI. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoIsLocal :: RecentInfo [_$_] + -> IO Bool -- ^ returns 'True' if the resource is local. [_$_] +recentInfoIsLocal self = + liftM toBool $ + {# call gtk_recent_info_is_local #} + self + +-- | Gets the name of the last application that have registered the recently used resource represented by +-- info. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoLastApplication :: RecentInfo [_$_] + -> IO String -- ^ returns an application name. [_$_] +recentInfoLastApplication self = + {# call gtk_recent_info_last_application #} + self + >>= readUTFString + +-- | Checks whether two 'RecentInfo' structures point to the same resource. +-- +-- * Available since Gtk+ version 2.10 +-- +recentInfoMatch :: RecentInfo -> RecentInfo [_$_] + -> IO Bool -- ^ returns 'True' if both 'RecentInfo' structures point to se same resource, 'False' otherwise. +recentInfoMatch self infoB = + liftM toBool $ + {# call gtk_recent_info_match #} + self + infoB +#endif addfile ./gtk/Graphics/UI/Gtk/Recent/RecentManager.chs hunk ./gtk/Graphics/UI/Gtk/Recent/RecentManager.chs 1 +{-# LANGUAGE CPP #-} +-- -*-haskell-*- +-- GIMP Toolkit (GTK) Widget RecentManager +-- +-- Author : Andy Stewart +-- +-- Created: 27 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) +-- +-- Managing Recently Used Files +-- +-- * Module available since Gtk+ version 2.10 +-- +-- TODO: [_$_] +-- GtkRecentData +-- gtk_recent_manager_add_full +-- +module Graphics.UI.Gtk.Recent.RecentManager ( + +-- * Detail +-- +-- | 'RecentManager' provides a facility for adding, removing and looking up +-- recently used files. Each recently used file is identified by its URI, and +-- has meta-data associated to it, like the names and command lines of the +-- applications that have registered it, the number of time each application +-- has registered the same file, the mime type of the file and whether the file +-- should be displayed only by the applications that have registered it. +-- +-- The 'RecentManager' acts like a database of all the recently used files. +-- You can create new 'RecentManager' objects, but it is more efficient to use +-- the standard recent manager for the 'Screen' so that informations about the +-- recently used files is shared with other people using them. In case the +-- default screen is being used, adding a new recently used file is as simple +-- as: +-- +-- Recently used files are supported since Gtk+ 2.10. + +-- * Class Hierarchy +-- +-- | +-- @ +-- | 'GObject' +-- | +----RecentManager +-- @ + +#if GTK_CHECK_VERSION(2,10,0) +-- * Types + RecentManager, + RecentManagerClass, + castToRecentManager, + toRecentManager, + +-- * Constructors + recentManagerNew, + +-- * Methods + recentManagerGetDefault, + recentManagerAddItem, + recentManagerRemoveItem, + recentManagerLookupItem, + recentManagerHasItem, + recentManagerMoveItem, + recentManagerGetItems, + recentManagerPurgeItems, + +-- * Attributes + recentManagerFilename, + recentManagerLimit, + recentManagerSize, + +-- * Signals + recentManagerChanged, +#endif + ) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.Attributes +import System.Glib.Properties +import System.Glib.GList +import System.Glib.UTFString +import System.Glib.GObject (Quark, quarkFromString) +import System.Glib.GError (GErrorDomain, GErrorClass(..), propagateGError, checkGError) +{#import Graphics.UI.Gtk.Recent.RecentInfo#} (RecentInfo, mkRecentInfo) +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.Signals#} + +{# context lib="gtk" prefix="gtk" #} + +#if GTK_CHECK_VERSION(2,10,0) + +-------------------- +-- Constructors + +-- | Creates a new recent manager object. Recent manager objects are used to +-- handle the list of recently used resources. A 'RecentManager' object +-- monitors the recently used resources list, and emits the \"changed\" signal +-- each time something inside the list changes. +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerNew :: IO RecentManager +recentManagerNew = + constructNewGObject mkRecentManager $ + {# call gtk_recent_manager_new #} + +-------------------- +-- Methods + +-- | Gets a unique instance of 'RecentManager'. +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerGetDefault :: IO RecentManager -- ^ returns A unique 'RecentManager'. [_$_] +recentManagerGetDefault = + makeNewGObject mkRecentManager $ + {# call gtk_recent_manager_get_default #} + +-- | Adds a new resource, pointed by @uri@, into the recently used resources +-- list. +-- +-- This function automatically retrieves some of the needed metadata and +-- setting other metadata to common default values; it then feeds the data to +-- 'recentManagerAddFull'. +-- +-- See 'recentManagerAddFull' if you want to explicitly define the metadata +-- for the resource pointed by @uri@. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerAddItem :: RecentManagerClass self => self + -> String -- ^ @uri@ - a valid URI + -> IO Bool -- ^ returns @True@ if the new item was successfully added to the + -- recently used resources list +recentManagerAddItem self uri = + liftM toBool $ + withUTFString uri $ \uriPtr -> + {# call gtk_recent_manager_add_item #} + (toRecentManager self) + uriPtr + +-- | Removes a resource pointed by @uri@ from the recently used resources list +-- handled by a recent manager. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerRemoveItem :: RecentManagerClass self => self + -> String -- ^ @uri@ - the URI of the item you wish to remove + -> IO Bool -- ^ returns @True@ if the item pointed by @uri@ has been + -- successfully removed by the recently used resources list, and + -- @False@ otherwise. +recentManagerRemoveItem self uri = + checkGError (\errorPtr -> + liftM toBool $ + withUTFString uri $ \uriPtr -> + {# call gtk_recent_manager_remove_item #} + (toRecentManager self) + uriPtr + errorPtr) + (\_ -> return False) + +-- | Searches for a URI inside the recently used resources list, and returns a +-- structure containing informations about the resource like its MIME type, or +-- its display name. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerLookupItem :: RecentManagerClass self => self + -> String -- ^ @uri@ - a URI + -> IO RecentInfo -- ^ returns a 'RecentInfo' + -- structure containing information about the + -- resource pointed by @uri@, or {@NULL@, FIXME: this + -- should probably be converted to a Maybe data type} + -- if the URI was not registered in the recently used + -- resources list. [_$_] +recentManagerLookupItem self uri = + propagateGError $ \errorPtr -> + withUTFString uri $ \uriPtr -> do + result <- {# call unsafe gtk_recent_manager_lookup_item #} + (toRecentManager self) + uriPtr + errorPtr + mkRecentInfo result + +-- | Checks whether there is a recently used resource registered with @uri@ +-- inside the recent manager. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerHasItem :: RecentManagerClass self => self + -> String -- ^ @uri@ - a URI + -> IO Bool -- ^ returns @True@ if the resource was found, @False@ otherwise. +recentManagerHasItem self uri = + liftM toBool $ + withUTFString uri $ \uriPtr -> + {# call gtk_recent_manager_has_item #} + (toRecentManager self) + uriPtr + +-- | Changes the location of a recently used resource from @uri@ to @newUri@. +-- +-- Please note that this function will not affect the resource pointed by +-- the URIs, but only the URI used in the recently used resources list. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerMoveItem :: RecentManagerClass self => self + -> String -- ^ @uri@ - the URI of a recently used resource + -> String -- ^ @newUri@ - the new URI of the recently used resource to remove the item pointed by @uri@ in the list + -> IO Bool -- ^ returns @True@ on success. +recentManagerMoveItem self uri newUri = + checkGError ( \errorPtr -> + liftM toBool $ + withUTFString newUri $ \newUriPtr -> + withUTFString uri $ \uriPtr -> + {# call gtk_recent_manager_move_item #} + (toRecentManager self) + uriPtr + newUriPtr + errorPtr) + (\_ -> return False) + +-- | Gets the list of recently used resources. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerGetItems :: RecentManagerClass self => self + -> IO [RecentInfo] -- ^ returns a list of newly allocated + -- 'RecentInfo' objects. [_$_] +recentManagerGetItems self = do + glist <- {# call gtk_recent_manager_get_items #} + (toRecentManager self) + list <- fromGList glist + mapM mkRecentInfo list + +-- | Purges every item from the recently used resources list. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerPurgeItems :: RecentManagerClass self => self + -> IO Int -- ^ returns the number of items that have been removed from the + -- recently used resources list. +recentManagerPurgeItems self = + liftM fromIntegral $ + propagateGError $ \errorPtr -> + {# call gtk_recent_manager_purge_items #} + (toRecentManager self) + errorPtr + +-------------------- +-- Attributes + +-- | The full path to the file to be used to store and read the recently used resources list +-- [_$_] +-- Default value: 'Nothing' +-- [_$_] +-- * Available since Gtk+ version 2.10 +-- +recentManagerFilename :: RecentManagerClass self => ReadAttr self String +recentManagerFilename = readAttrFromStringProperty "filename" + +-- | The maximum number of items to be returned by the 'recentManagerGetItems' function. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: -1 +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerLimit :: RecentManagerClass self => Attr self Int +recentManagerLimit = newAttrFromIntProperty "limit" + +-- | The size of the recently used resources list. +-- [_$_] +-- Allowed values: >= 'GMaxulong' +-- [_$_] +-- Default value: 0 +-- [_$_] +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerSize :: RecentManagerClass self => ReadAttr self Int +recentManagerSize = readAttrFromIntProperty "size" + +-------------------- +-- Signals + +-- | Emitted when the current recently used resources manager changes its +-- contents. +-- +-- +-- * Available since Gtk+ version 2.10 +-- +recentManagerChanged :: RecentManagerClass self => Signal self (IO ()) +recentManagerChanged = Signal (connect_NONE__NONE "changed") +#endif hunk ./gtk/gtk.cabal 292 + Graphics.UI.Gtk.Recent.RecentManager + Graphics.UI.Gtk.Recent.RecentInfo } |