File: CellRendererAccel.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 (171 lines) | stat: -rw-r--r-- 5,194 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget CellRendererAccel
--
--  Author : Andy Stewart
--
--  Created: 25 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  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- Renders a keyboard accelerator in a cell
--
-- * Module available since Gtk+ version 2.10
--
module Graphics.UI.Gtk.ModelView.CellRendererAccel (

-- * Detail
--
-- | 'CellRendererAccel' displays a keyboard accelerator (i.e. a key
-- combination like \<Control>-a). If the cell renderer is editable, the
-- accelerator can be changed by simply typing the new combination.
--
-- The 'CellRendererAccel' cell renderer was added in Gtk+ 2.10.

-- * Class Hierarchy
--
-- |
-- @
-- |  'GObject'
-- |   +----'Object'
-- |         +----'CellRenderer'
-- |               +----'CellRendererText'
-- |                     +----CellRendererAccel
-- @

#if GTK_CHECK_VERSION(2,10,0)
-- * Types
  CellRendererAccel,
  CellRendererAccelClass,
  castToCellRendererAccel,
  toCellRendererAccel,

-- * Enums
  CellRendererAccelMode(..),

-- * Constructors
  cellRendererAccelNew,

-- * Attributes
  cellRendererAccelAccelKey,
  cellRendererAccelAccelMods,
  cellRendererAccelKeycode,
  cellRendererAccelAccelMode,

-- * Signals
  accelEdited,
  accelCleared,
#endif
  ) where

import Control.Monad    (liftM)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.Gdk.Enums (Modifier)
import Graphics.UI.Gtk.Abstract.Object   (makeNewObject)
import Graphics.UI.Gtk.Gdk.Keys (KeyVal, KeyCode)
{#import Graphics.UI.Gtk.Signals#}
{#import Graphics.UI.Gtk.Types#}

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

#if GTK_CHECK_VERSION(2,10,0)
--------------------
-- Enums
{#enum CellRendererAccelMode {underscoreToCase} deriving (Bounded,Eq,Show)#}

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

-- | Creates a new 'CellRendererAccel'.
--
-- * Available since Gtk+ version 2.10
--
cellRendererAccelNew :: IO CellRendererAccel
cellRendererAccelNew =
  makeNewObject mkCellRendererAccel $ liftM castPtr $
  {# call gtk_cell_renderer_accel_new #}

--------------------
-- Attributes

-- | The keyval of the accelerator.
--
-- Allowed values: <= GMaxint
--
-- Default value: 0
--
-- * Available since Gtk+ version 2.10
--
cellRendererAccelAccelKey :: CellRendererAccelClass self => Attr self Int
cellRendererAccelAccelKey = newAttrFromUIntProperty "accel-key"

-- | The modifier mask of the accelerator.
--
-- * Available since Gtk+ version 2.10
--
cellRendererAccelAccelMods :: CellRendererAccelClass self => Attr self [Modifier]
cellRendererAccelAccelMods = newAttrFromFlagsProperty "accel-mods"
                               {# call pure unsafe gdk_modifier_type_get_type #}

-- | The hardware keycode of the accelerator. Note that the hardware keycode is only relevant if the key
-- does not have a keyval.  Normally, the keyboard configuration should assign keyvals to all keys.
--
-- Allowed values: <= GMaxint
--
-- Default value: 0
--
-- * Available since Gtk+ version 2.10
--
cellRendererAccelKeycode :: CellRendererAccelClass self => Attr self Int
cellRendererAccelKeycode = newAttrFromUIntProperty "keycode"

-- | Determines if the edited accelerators are GTK+ accelerators. If they are, consumed modifiers are
-- suppressed, only accelerators accepted by GTK+ are allowed, and the accelerators are rendered in the
-- same way as they are in menus.
--
-- Default value: 'CellRendererAccelModeGtk'
--
-- * Available since Gtk+ version 2.10
--
cellRendererAccelAccelMode :: CellRendererAccelClass self => Attr self CellRendererAccelMode
cellRendererAccelAccelMode = newAttrFromEnumProperty "accel-mode"
                               {# call pure unsafe gtk_cell_renderer_accel_mode_get_type #}

--------------------
-- Signals

-- | Gets emitted when the user has selected a new accelerator.
--
-- * Available since Gtk+ version 2.10
--
accelEdited :: (CellRendererAccelClass self, GlibString string) => Signal self (string -> KeyVal -> Modifier -> KeyCode -> IO ())
accelEdited = Signal (\after obj user -> connect_GLIBSTRING_INT_ENUM_INT__NONE "accel_edited" after obj
                      (\ path keyval modifier keycode ->
                        user path (fromIntegral keyval) modifier (fromIntegral keycode)))

-- | Gets emitted when the user has removed the accelerator.
--
-- * Available since Gtk+ version 2.10
--
accelCleared :: (CellRendererAccelClass self, GlibString string) => Signal self (string -> IO ())
accelCleared = Signal (connect_GLIBSTRING__NONE "accel_cleared")
#endif