 -- 
 -- You may nest 'sourceBufferBeginNotUndoableAction' /
 -- 'sourceBufferEndNotUndoableAction' blocks.
-sourceBufferBeginNotUndoableAction :: SourceBuffer -> IO ()
+sourceBufferBeginNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()
 sourceBufferBeginNotUndoableAction sb =
-  {#call source_buffer_begin_not_undoable_action#} sb
+  {#call source_buffer_begin_not_undoable_action#} (toSourceBuffer sb)
   
 -- | Marks the end of a not undoable action on the buffer. When the last not undoable block is closed
 -- through the call to this function, the list of undo actions is cleared and the undo manager is
 -- re-enabled.
-sourceBufferEndNotUndoableAction :: SourceBuffer -> IO ()
+sourceBufferEndNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()
 sourceBufferEndNotUndoableAction sb =
-  {#call source_buffer_end_not_undoable_action#} sb
+  {#call source_buffer_end_not_undoable_action#} (toSourceBuffer sb)
 
 -- | Creates a marker in the buffer of the given type.
 --

-- general, this happens whenever the user presses any key which modifies the buffer, but the undo
-- manager will try to merge similar consecutive actions, such as multiple character insertions into
-- one action. But, inserting a newline does start a new action.
sourceBufferSetMaxUndoLevels :: SourceBuffer 
                             -> Int  -- ^ @maxUndoLevels@ the desired maximum number of undo levels. 
                             -> IO ()
sourceBufferSetMaxUndoLevels sb newVal =
  {#call unsafe source_buffer_set_max_undo_levels#} sb (fromIntegral newVal)
  
-- | Determines the number of undo levels the buffer will track for buffer edits.
sourceBufferGetMaxUndoLevels :: SourceBuffer 
                             -> IO Int -- ^ returns the maximum number of possible undo levels or -1 if no limit is set.
sourceBufferGetMaxUndoLevels sb = liftM fromIntegral $
  {#call unsafe source_buffer_get_max_undo_levels#} sb

-- | Determines whether a source buffer can undo the last action.
sourceBufferGetCanUndo :: SourceBuffer 
                       -> IO Bool -- ^ returns 'True' if it's possible to undo the last action. 
sourceBufferGetCanUndo sb = liftM toBool $
  {#call unsafe source_buffer_can_undo#} sb
  
-- | Determines whether a source buffer can redo the last action (i.e. if the last operation was an
-- undo).
sourceBufferGetCanRedo :: SourceBuffer 
                       -> IO Bool -- ^ returns 'True' if a redo is possible. 
sourceBufferGetCanRedo sb = liftM toBool $
  {#call unsafe source_buffer_can_redo#} sb

-- | Undoes the last user action which modified the buffer. Use 'sourceBufferCanUndo' to check
-- whether a call to this function will have any effect.

-- Actions are defined as groups of operations between a call to 'textBufferBeginUserAction'
-- and 'textBufferEndUserAction' on the
-- same line.
sourceBufferUndo :: SourceBufferClass buffer => buffer -> IO ()
sourceBufferUndo sb =
  {#call source_buffer_undo#} (toSourceBuffer sb)
  
-- | Redoes the last undo operation. Use 'sourceBufferCanRedo' to check whether a call to this
-- function will have any effect.
sourceBufferRedo :: SourceBufferClass buffer => buffer -> IO ()
sourceBufferRedo sb =
  {#call source_buffer_redo#} (toSourceBuffer sb)

-- | Marks the beginning of a not undoable action on the buffer, disabling the undo manager. Typically
-- you would call this function before initially setting the contents of the buffer (e.g. when loading
