File: CellEditable.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 (144 lines) | stat: -rw-r--r-- 4,231 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
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Interface CellEditable
--
--  Author : Andy Stewart
--
--  Created: 26 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)
--
-- Interface for widgets which can are used for editing cells
--
module Graphics.UI.Gtk.ModelView.CellEditable (

-- * Detail
--
-- | The 'CellEditable' interface must be implemented for widgets to be usable
-- when editing the contents of a 'TreeView' cell.

-- * Class Hierarchy
--
-- |
-- @
-- |  'GInterface'
-- |   +----CellEditable
-- @

-- * Types
  CellEditable,
  CellEditableClass,
  castToCellEditable,
  toCellEditable,

-- * Methods
  cellEditableStartEditing,
  cellEditableEmitEditingDone,
  cellEditableEmitRemoveWidget,

-- * Attributes
#if GTK_CHECK_VERSION(2,20,0)
  cellEditableEditingCanceled,
#endif

-- * Signals
  cellEditableEditingDone,
  cellEditableRemoveWidget,
  ) where

import Control.Monad.Reader.Class (ask)
import Control.Monad.Trans (liftIO)

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
{#import Graphics.UI.Gtk.Types#}
{#import Graphics.UI.Gtk.Signals#}
import Graphics.UI.Gtk.Gdk.EventM (EventM, EAny)

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

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

-- | Begins editing on a @cellEditable@. @event@ is the 'Event' that began the editing process.
--
cellEditableStartEditing :: CellEditableClass self => self -> EventM EAny ()
cellEditableStartEditing self = do
  eventPtr <- ask
  liftIO $ {# call gtk_cell_editable_start_editing #}
             (toCellEditable self)
             (castPtr eventPtr)

-- | Emits the 'cellEditableEditingDone' signal.
--
cellEditableEmitEditingDone :: CellEditableClass self => self -> IO ()
cellEditableEmitEditingDone self =
  {# call gtk_cell_editable_editing_done #}
    (toCellEditable self)

-- | Emits the 'cellEditableRemoveWidget' signal.
--
cellEditableEmitRemoveWidget :: CellEditableClass self => self -> IO ()
cellEditableEmitRemoveWidget self =
  {# call gtk_cell_editable_remove_widget #}
    (toCellEditable self)

--------------------
-- Attributes
#if GTK_CHECK_VERSION(2,20,0)
-- | Indicates whether editing on the cell has been canceled.
--
-- Default value: 'False'
--
-- * Available since Gtk+ version 2.20
--
cellEditableEditingCanceled :: CellEditableClass self => Attr self Bool
cellEditableEditingCanceled =
  newAttrFromBoolProperty "editing-canceled"
#endif

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

-- | This signal is a sign for the cell renderer to update its value from the
-- @cellEditable@.
--
-- Implementations of 'CellEditable' are responsible for emitting this
-- signal when they are done editing, e.g. 'Entry' is emitting it when the user
-- presses Enter.
--
-- 'cellEditableEmitEditingDone' is a convenience method for emitting
-- ::editing-done.
--
cellEditableEditingDone :: CellEditableClass self => Signal self (IO ())
cellEditableEditingDone = Signal (connect_NONE__NONE "editing_done")

-- | This signal is meant to indicate that the cell is finished editing, and
-- the widget may now be destroyed.
--
-- Implementations of 'CellEditable' are responsible for emitting this
-- signal when they are done editing. It must be emitted after the
-- 'cellEditableEditingDone' signal, to give the cell
-- renderer a chance to update the cell's value before the widget is removed.
--
-- 'cellEditableEmitRemoveWidget' is a convenience method for emitting
-- ::remove-widget.
--
cellEditableRemoveWidget :: CellEditableClass self => Signal self (IO ())
cellEditableRemoveWidget = Signal (connect_NONE__NONE "remove_widget")