File: Settings.chs

package info (click to toggle)
haskell-gtk 0.15.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,964 kB
  • sloc: haskell: 3,346; ansic: 826; makefile: 161
file content (122 lines) | stat: -rw-r--r-- 3,017 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Clipboard
--
--  Author : Axel Simon
--
--  Created: 26 March 2007
--
--  Copyright (C) 2007 Axel Simon
--
--  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.
--
-- I removed all definitions for the clipboard by Juergen Nicklisch since
-- the way the clipboards were selected didn't tie in with the Selection
-- module.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- Storing data on clipboards
--
module Graphics.UI.Gtk.General.Settings (

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

-- * Types
  Settings,
  SettingsClass,
  castToSettings, gTypeSettings,
  toSettings,

-- * Methods
  settingsGetDefault,
#if GTK_CHECK_VERSION(2,2,0)
  settingsGetForScreen,
#endif
  settingsSetLongProperty,
  settingsSetStringProperty
  ) where

import System.Glib.FFI
import System.Glib.UTFString
{#import Graphics.UI.Gtk.Types#}

{# context lib="gtk" prefix="gtk" #}


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

-- | Gets the Settings object for the default GDK screen, creating
-- it if necessary. See 'settingsGetForScreen'.
--
settingsGetDefault ::
    IO (Maybe Settings) -- ^ returns a Settings. If there is no default
                        -- screen, then returns Nothing.
settingsGetDefault =
  maybeNull (makeNewGObject mkSettings)
    {# call gtk_settings_get_default #}

#if GTK_CHECK_VERSION(2,2,0)
-- | Gets the Settings object for screen, creating it if necessary.
--
settingsGetForScreen ::
    ScreenClass screen
 => screen
 -> IO Settings
settingsGetForScreen screen =
  makeNewGObject mkSettings $
    {# call gtk_settings_get_for_screen #}
      (toScreen screen)
#endif

settingsSetLongProperty ::
    (SettingsClass settings, GlibString string)
 => settings
 -> string
 -> Int
 -> string
 -> IO ()
settingsSetLongProperty settings name value origin =
  withUTFString name $ \namePtr ->
  withUTFString origin $ \originPtr ->
  {# call gtk_settings_set_long_property #}
    (toSettings settings)
    namePtr
    (fromIntegral value)
    originPtr

settingsSetStringProperty ::
    (SettingsClass settings, GlibString string)
 => settings
 -> string
 -> string
 -> string
 -> IO ()
settingsSetStringProperty settings name value origin =
  withUTFString name $ \namePtr ->
  withUTFString value $ \valuePtr ->
  withUTFString origin $ \originPtr ->
  {# call gtk_settings_set_string_property #}
    (toSettings settings)
    namePtr
    valuePtr
    originPtr