 -- 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 
+sourceBufferSetMaxUndoLevels :: SourceBufferClass buffer => buffer 
                              -> Int  -- ^ @maxUndoLevels@ the desired maximum number of undo levels. 
                              -> IO ()
 sourceBufferSetMaxUndoLevels sb newVal =
-  {#call unsafe source_buffer_set_max_undo_levels#} sb (fromIntegral newVal)
+  {#call unsafe source_buffer_set_max_undo_levels#} (toSourceBuffer sb) (fromIntegral newVal)
   
 -- | Determines the number of undo levels the buffer will track for buffer edits.
-sourceBufferGetMaxUndoLevels :: SourceBuffer 
+sourceBufferGetMaxUndoLevels :: SourceBufferClass buffer => buffer 
                              -> 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
+  {#call unsafe source_buffer_get_max_undo_levels#} (toSourceBuffer sb)
 
 -- | Determines whether a source buffer can undo the last action.
-sourceBufferGetCanUndo :: SourceBuffer 
+sourceBufferGetCanUndo :: SourceBufferClass buffer => buffer 
                        -> IO Bool -- ^ returns 'True' if it's possible to undo the last action. 
 sourceBufferGetCanUndo sb = liftM toBool $
-  {#call unsafe source_buffer_can_undo#} sb
+  {#call unsafe source_buffer_can_undo#} (toSourceBuffer sb)
   
 -- | Determines whether a source buffer can redo the last action (i.e. if the last operation was an
 -- undo).
-sourceBufferGetCanRedo :: SourceBuffer 
+sourceBufferGetCanRedo :: SourceBufferClass buffer => buffer 
                        -> IO Bool -- ^ returns 'True' if a redo is possible. 
 sourceBufferGetCanRedo sb = liftM toBool $
-  {#call unsafe source_buffer_can_redo#} sb
+  {#call unsafe source_buffer_can_redo#} (toSourceBuffer sb)
 
 -- | Undoes the last user action which modified the buffer. Use 'sourceBufferCanUndo' to check
 -- whether a call to this function will have any effect.

-- 
-- You may nest 'sourceBufferBeginNotUndoableAction' /
-- 'sourceBufferEndNotUndoableAction' blocks.
sourceBufferBeginNotUndoableAction :: SourceBuffer -> IO ()
sourceBufferBeginNotUndoableAction sb =
  {#call source_buffer_begin_not_undoable_action#} 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 sb =
  {#call source_buffer_end_not_undoable_action#} sb

-- | Creates a marker in the buffer of the given type.
--


-- | Remove all marks of category between start and end from the buffer. If category is empty, all marks
-- in the range will be removed.
sourceBufferRemoveSourceMarks :: SourceBufferClass buffer => buffer -- ^ @buffer@   a 'SourceBuffer'.             
                              -> TextIter -- ^ @start@    a 'TextIter'                  
                              -> TextIter -- ^ @end@      a 'TextIter'                  
                              -> String -- ^ @category@ category to search for or empty
