From: Axel S. <A....@ke...> - 2007-12-02 21:38:34
|
Sun Dec 2 13:19:58 PST 2007 A....@ke... * Complete the default drag and drop interface for ListStore. This patch completes the former patch which adds the C functions to the C custom model. With this patch it is possible to reorder the rows of a list store using drag and drop. The drag and drop for tree stores doesn't quite work yet since I'm not sure what the exact semantics are (do we move a row at a time, or a full tree? is the last index of the drop path the position where we insert the new row?). This patch also enables the reordering in the two listtest and treetest demo programs. hunk ./Makefile.am 559 + gtk/Graphics/UI/Gtk/ModelView/TreeDrag.chs \ hunk ./demo/treeList/ListTest.hs 67 + New.treeViewSetReorderable view True + hunk ./demo/treeList/TreeTest.hs 64 + + New.treeViewSetReorderable view True hunk ./gtk/Graphics/UI/Gtk/Gdk/Enums.chs 32 + DragAction(..), hunk ./gtk/Graphics/UI/Gtk/Gdk/Enums.chs 67 +-- | Specify the kind of action performed on a drag event. +{#enum DragAction {underscoreToCase} deriving (Bounded)#} + +instance Flags DragAction + hunk ./gtk/Graphics/UI/Gtk/Gdk/Events.hsc 79 + | ButtonLeft + | ButtonRight + | ButtonMiddle hunk ./gtk/Graphics/UI/Gtk/Gdk/Events.hsc 90 + toEnum #{const GDK_BUTTON1_MASK} = ButtonLeft + toEnum #{const GDK_BUTTON2_MASK} = ButtonRight + toEnum #{const GDK_BUTTON3_MASK} = ButtonMiddle hunk ./gtk/Graphics/UI/Gtk/Gdk/Events.hsc 98 + fromEnum ButtonLeft = #{const GDK_BUTTON1_MASK} + fromEnum ButtonRight = #{const GDK_BUTTON2_MASK} + fromEnum ButtonMiddle = #{const GDK_BUTTON3_MASK} hunk ./gtk/Graphics/UI/Gtk/General/Drag.chs.pp 62 + DragAction(..), + DestDefaults(..), + DragProtocol(..), hunk ./gtk/Graphics/UI/Gtk/General/Drag.chs.pp 258 --- | Returns the list of targets this widget can accept from drag-and-drop. +-- | Returns the list of targets this widget can accept for drag-and-drop. hunk ./gtk/Graphics/UI/Gtk/General/Selection.chs.pp 39 - [_$_] + TargetFlags(..), + [_$_] hunk ./gtk/Graphics/UI/Gtk/General/Selection.chs.pp 94 -import Graphics.UI.Gtk.General.Enums (TargetFlags) +import Graphics.UI.Gtk.General.Enums (TargetFlags(..)) hunk ./gtk/Graphics/UI/Gtk/General/Selection.chs.pp 153 --- flag is @True@ then serializable rich text formats will be added, +-- flag is @True@ then deserializable rich text formats will be added, hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 29 - [_$_] + hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 39 + DragSourceIface(..), + DragDestIface(..), hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 83 -instance GObjectClass (CustomTreeModel private row) + hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 129 -data CustomTreeModelImplementation row = CustomTreeModelImplementation { - customTreeModelColumns :: ColumnMap row, -- provide access via columns +data CustomTreeModelImplementation model row = CustomTreeModelImplementation { + customTreeModelColumns :: ColumnMap row, -- provide access via columns hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 132 - customTreeDragSourceIface :: DragSourceIface, -- the drag and drop source interface - customTreeDragDestIface :: DragDestIface -- the drag and drop dest interface + customTreeDragSourceIface :: DragSourceIface model row, -- the drag and drop source interface + customTreeDragDestIface :: DragDestIface model row -- the drag and drop dest interface hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 151 -data DragSourceIface = DragSourceIface { - treeDragSourceRowDraggable :: TreePath -> IO Bool, -- query if the row is draggable - treeDragSourceDragDataGet :: TreePath -> SelectionDataM Bool, -- store row in selection object - treeDragSourceDragDataDelete:: TreePath -> IO Bool -- instruct store to delete the row +data DragSourceIface model row = DragSourceIface { + treeDragSourceRowDraggable :: model row -> TreePath -> IO Bool, -- query if the row is draggable + treeDragSourceDragDataGet :: model row -> TreePath -> SelectionDataM Bool, -- store row in selection object + treeDragSourceDragDataDelete:: model row -> TreePath -> IO Bool -- instruct store to delete the row hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 157 -data DragDestIface = DragDestIface { - treeDragDestDragDataReceived:: TreePath -> SelectionDataM Bool, -- insert row from selection object - treeDragDestRowDropPossible :: TreePath -> SelectionDataM Bool -- query if row drop is possible +data DragDestIface model row = DragDestIface { + treeDragDestRowDropPossible :: model row -> TreePath -> SelectionDataM Bool, -- query if row drop is possible + treeDragDestDragDataReceived:: model row -> TreePath -> SelectionDataM Bool -- insert row from selection object hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 163 --- optionally the 'DragSourceIface' and the 'DragDestIface'. If the latter to +-- optionally the 'DragSourceIface' and the 'DragDestIface'. If the latter two hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 165 --- drag and drops. -customTreeModelNew :: private -- | Any private data the store needs to store. Usually an 'IORef'. - -> TreeModelIface row -- | Functions necessary to implement the 'TreeModel' interface. - -> Maybe DragSourceIface -- | Functions to enable this store to generate drag events. - -> Maybe DragDestIface -- | Functions to enable this store to receive drag events. - -> IO (CustomTreeModel private row) -customTreeModelNew priv tmIface mDragSource mDragDest = do +-- drag and drop. +customTreeModelNew :: (TreeModelClass (model row), TypedTreeModelClass model) => + private -- ^ Any private data the store needs to store. Usually an 'IORef'. + -> ((CustomTreeModel private row) -> model row) + -> TreeModelIface row -- ^ Functions necessary to implement the 'TreeModel' interface. + -> Maybe (DragSourceIface model row) + -- ^ Functions to enable this store to generate drag events. + -> Maybe (DragDestIface model row) + -- ^ Functions to enable this store to receive drag events. + -> IO (model row) +customTreeModelNew priv con tmIface mDragSource mDragDest = do hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 177 - let dummyDragSource = DragSourceIface { treeDragSourceRowDraggable = \_ -> return False, - treeDragSourceDragDataGet = \_ -> return False, - treeDragSourceDragDataDelete = \_ -> return False } - let dummyDragDest = DragDestIface { treeDragDestDragDataReceived = \_ -> return False, - treeDragDestRowDropPossible = \_ -> return False } - implPtr <- newStablePtr CustomTreeModelImplementation { customTreeModelColumns = cMap, - customTreeModelIface = tmIface, - customTreeDragSourceIface = fromMaybe dummyDragSource mDragSource, - customTreeDragDestIface = fromMaybe dummyDragDest mDragDest } + let dummyDragSource = DragSourceIface { treeDragSourceRowDraggable = \_ _ -> return False, + treeDragSourceDragDataGet = \_ _ -> return False, + treeDragSourceDragDataDelete = \_ _ -> return False } + let dummyDragDest = DragDestIface { treeDragDestRowDropPossible = \_ _ -> return False, + treeDragDestDragDataReceived = \_ _ -> return False } + implPtr <- newStablePtr CustomTreeModelImplementation { + customTreeModelColumns = cMap, + customTreeModelIface = tmIface, + customTreeDragSourceIface = fromMaybe dummyDragSource mDragSource, + customTreeDragDestIface = fromMaybe dummyDragDest mDragDest } hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 188 - makeNewGObject CustomTreeModel $ + liftM con $ makeNewGObject CustomTreeModel $ hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 192 - gtk2hs_store_new :: StablePtr (CustomTreeModelImplementation row) + gtk2hs_store_new :: StablePtr (CustomTreeModelImplementation model row) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 204 - gtk2hs_store_get_impl :: Ptr (TypedTreeModel row) -> IO (StablePtr (CustomTreeModelImplementation row)) + gtk2hs_store_get_impl :: Ptr (TypedTreeModel row) -> IO (StablePtr (CustomTreeModelImplementation model row)) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 229 -treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt +treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation model row) -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 236 - treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt + treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation model row) -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 245 -treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType +treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation model row) -> CInt -> IO GType hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 254 - treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType + treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation model row) -> CInt -> IO GType hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 257 -treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt +treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation model row) -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 263 - treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt + treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation model row) -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 266 -treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt +treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 277 - treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt + treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 279 -treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) +treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 288 - treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) + treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 291 -treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () +treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 309 - treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () + treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 312 -treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 323 - treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 326 -treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt +treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 337 - treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt + treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 340 -treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 347 - treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 350 -treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 357 - treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 360 -treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt +treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 371 - treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt + treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 374 -treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt +treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 385 - treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt + treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 388 -treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () +treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 395 - treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () + treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 398 -treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () +treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 405 - treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () + treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation model row) -> Ptr TreeIter -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 407 -treeDragSourceRowDraggable_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt -treeDragSourceRowDraggable_static storePtr pathPtr = do +treeDragSourceRowDraggable_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> IO CInt +treeDragSourceRowDraggable_static mPtr storePtr pathPtr = do + model <- makeNewGObject mkTreeModel (return mPtr) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 412 - liftM fromBool $ treeDragSourceRowDraggable store path + liftM fromBool $ treeDragSourceRowDraggable store (unsafeTreeModelToGeneric model) path hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 415 - treeDragSourceRowDraggable_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt + treeDragSourceRowDraggable_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 417 -treeDragSourceDragDataGet_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt -treeDragSourceDragDataGet_static storePtr pathPtr selectionPtr = do +treeDragSourceDragDataGet_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragSourceDragDataGet_static mPtr storePtr pathPtr selectionPtr = do + model <- makeNewGObject mkTreeModel (return mPtr) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 422 - liftM fromBool $ runReaderT (treeDragSourceDragDataGet store path) selectionPtr + liftM fromBool $ runReaderT (treeDragSourceDragDataGet store (unsafeTreeModelToGeneric model) path) selectionPtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 425 - treeDragSourceDragDataGet_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt + treeDragSourceDragDataGet_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 427 -treeDragSourceDragDataDelete_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt -treeDragSourceDragDataDelete_static storePtr pathPtr = do +treeDragSourceDragDataDelete_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> IO CInt +treeDragSourceDragDataDelete_static mPtr storePtr pathPtr = do + model <- makeNewGObject mkTreeModel (return mPtr) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 432 - liftM fromBool $ treeDragSourceDragDataDelete store path + liftM fromBool $ treeDragSourceDragDataDelete store (unsafeTreeModelToGeneric model) path hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 435 - treeDragSourceDragDataDelete_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt + treeDragSourceDragDataDelete_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 437 -treeDragDestDragDataReceived_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt -treeDragDestDragDataReceived_static storePtr pathPtr selectionPtr = do +treeDragDestDragDataReceived_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragDestDragDataReceived_static mPtr storePtr pathPtr selectionPtr = do + model <- makeNewGObject mkTreeModel (return mPtr) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 442 - liftM fromBool $ runReaderT (treeDragDestDragDataReceived store path) selectionPtr + liftM fromBool $ runReaderT (treeDragDestDragDataReceived store (unsafeTreeModelToGeneric model) path) selectionPtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 445 - treeDragDestDragDataReceived_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt + treeDragDestDragDataReceived_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 447 -treeDragDestRowDropPossible_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt -treeDragDestRowDropPossible_static storePtr pathPtr selectionPtr = do +treeDragDestRowDropPossible_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragDestRowDropPossible_static mPtr storePtr pathPtr selectionPtr = do + model <- makeNewGObject mkTreeModel (return mPtr) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 452 - liftM fromBool $ runReaderT (treeDragDestRowDropPossible store path) selectionPtr + liftM fromBool $ runReaderT (treeDragDestRowDropPossible store (unsafeTreeModelToGeneric model) path) selectionPtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 455 - treeDragDestRowDropPossible_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt + treeDragDestRowDropPossible_static :: Ptr TreeModel -> StablePtr (CustomTreeModelImplementation model row) -> Ptr NativeTreePath -> SelectionData -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 637 - gboolean result = gtk2hs_store_row_draggable_impl(store->impl, path); + gboolean result = gtk2hs_store_row_draggable_impl(drag_source, store->impl, path); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 655 - gboolean result = gtk2hs_store_drag_data_get_impl(store->impl, path, selection_data); + gboolean result = gtk2hs_store_drag_data_get_impl(drag_source, store->impl, path, selection_data); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 671 - gboolean result = gtk2hs_store_drag_data_delete_impl(store->impl, path); + gboolean result = gtk2hs_store_drag_data_delete_impl(drag_source, store->impl, path); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 689 - gboolean result = gtk2hs_store_drag_data_received_impl(store->impl, dest_path, selection_data); + gboolean result = gtk2hs_store_drag_data_received_impl(drag_dest, store->impl, dest_path, selection_data); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 707 - gboolean result = gtk2hs_store_row_drop_possible_impl(store->impl, dest_path, selection_data); + gboolean result = gtk2hs_store_row_drop_possible_impl(drag_dest, store->impl, dest_path, selection_data); hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 35 +-- * Implementation of Interfaces + listStoreDefaultDragSourceIface, + listStoreDefaultDragDestIface, + [_$_] hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 67 +import Graphics.UI.Gtk.ModelView.TreeDrag +import Control.Monad.Trans ( liftIO ) hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 78 +-- | Create a new 'TreeModel' that contains a list of elements. hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 80 -listStoreNew xs = do +listStoreNew xs = listStoreNewDND xs (Just listStoreDefaultDragSourceIface) + (Just listStoreDefaultDragDestIface) + +-- | Create a new 'TreeModel' that contains a list of elements. In addition, specify two +-- interfaces for drag and drop. +-- +listStoreNewDND :: [a] -- ^ the initial content of the model + -> Maybe (DragSourceIface ListStore a) -- ^ an optional interface for drags + -> Maybe (DragDestIface ListStore a) -- ^ an optional interface to handle drops + -> IO (ListStore a) -- ^ the new model +listStoreNewDND xs mDSource mDDest = do hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 93 - liftM ListStore $ customTreeModelNew rows TreeModelIface { + customTreeModelNew rows ListStore TreeModelIface { hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 122 - } Nothing Nothing + } mDSource mDDest + + +-- | Default drag functions for 'Graphics.UI.Gtk.ModelView.ListStore'. These +-- functions allow the rows of the model to serve as drag source. Any row is +-- allowed to be dragged and the data set in the 'SelectionDataM' object is +-- set with 'treeSetRowDragData', i.e. it contains the model and the +-- 'TreePath' to the row. +listStoreDefaultDragSourceIface :: DragSourceIface ListStore row +listStoreDefaultDragSourceIface = DragSourceIface { + treeDragSourceRowDraggable = \_ _-> return True, + treeDragSourceDragDataGet = treeSetRowDragData, + treeDragSourceDragDataDelete = \model (dest:_) -> do + liftIO $ listStoreRemove model dest + return True + + } + +-- | Default drop functions for 'Graphics.UI.Gtk.ModelView.ListStore'. These +-- functions accept a row and insert the row into the new location if it is +-- dragged into a tree view +-- that uses the same model. +listStoreDefaultDragDestIface :: DragDestIface ListStore row +listStoreDefaultDragDestIface = DragDestIface { + treeDragDestRowDropPossible = \model dest -> do + mModelPath <- treeGetRowDragData + case mModelPath of + Nothing -> return False + Just (model', source) -> return (treeModelEqual model model'), + treeDragDestDragDataReceived = \model (dest:_) -> do + mModelPath <- treeGetRowDragData + case mModelPath of + Nothing -> return False + Just (model', (source:_)) -> + if not (treeModelEqual model model') then return False + else liftIO $ do + row <- listStoreGetValue model source + listStoreInsert model dest row + return True + } hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 287 + hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModel.chs.pp 87 - TreeModelFlags(..), hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 35 +-- * Implementation of Interfaces + treeStoreDefaultDragSourceIface, + treeStoreDefaultDragDestIface, + hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 64 +import Graphics.UI.Gtk.ModelView.TreeDrag +import Control.Monad.Trans ( liftIO ) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 100 -treeStoreNew forest = do +treeStoreNew forest = treeStoreNewDND forest + (Just treeStoreDefaultDragSourceIface) + (Just treeStoreDefaultDragDestIface) + +-- | Create a new list store. +-- +-- * In addition to 'treeStoreNew', this function takes an two interfaces +-- to implement user-defined drag-and-drop functionality. +-- +treeStoreNewDND :: Forest a -- ^ the inital tree stored in this model + -> Maybe (DragSourceIface TreeStore a) -- ^ an optional interface for drags + -> Maybe (DragDestIface TreeStore a) -- ^ an optional interface to handle drops + -> IO (TreeStore a) +treeStoreNewDND forest mDSource mDDest = do hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 125 - liftM TreeStore $ customTreeModelNew storeRef TreeModelIface { + customTreeModelNew storeRef TreeStore TreeModelIface { hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 169 - } Nothing Nothing + } mDSource mDDest + + +-- | Default drag functions for +-- 'Graphics.UI.Gtk.ModelView.TreeStore'. These functions allow the rows of +-- the model to serve as drag source. Any row is allowed to be dragged and the +-- data set in the 'SelectionDataM' object is set with 'treeSetRowDragData', +-- i.e. it contains the model and the 'TreePath' to the row. +treeStoreDefaultDragSourceIface :: DragSourceIface TreeStore row +treeStoreDefaultDragSourceIface = DragSourceIface { + treeDragSourceRowDraggable = \_ _-> return True, + treeDragSourceDragDataGet = treeSetRowDragData, + treeDragSourceDragDataDelete = \model dest@(_:_) -> do + liftIO $ treeStoreRemove model dest + return True + + } + +-- | Default drop functions for 'Graphics.UI.Gtk.ModelView.TreeStore'. These +-- functions accept a row and insert the row into the new location if it is +-- dragged into a tree view +-- that uses the same model. +treeStoreDefaultDragDestIface :: DragDestIface TreeStore row +treeStoreDefaultDragDestIface = DragDestIface { + treeDragDestRowDropPossible = \model dest -> do + mModelPath <- treeGetRowDragData + case mModelPath of + Nothing -> return False + Just (model', source) -> return (treeModelEqual model model'), + treeDragDestDragDataReceived = \model dest@(_:_) -> do + mModelPath <- treeGetRowDragData + case mModelPath of + Nothing -> return False + Just (model', source@(_:_)) -> + if not (treeModelEqual model model') then return False + else liftIO $ do + row <- treeStoreGetTree model source + treeStoreInsertTree model (init dest) (last dest) row + return True + } hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 83 + DragAction(..), + TreeViewGridLines(..), hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 107 - treeViewInsertColumnWithAttributes, hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 152 +#if GTK_CHECK_VERSION(2,10,0) + treeViewGetHeadersClickable, +#endif +#endif +#if GTK_CHECK_VERSION(2,8,0) + treeViewGetVisibleRange, +#endif + treeViewEnableModelDragDest, + treeViewEnableModelDragSource, +#if GTK_CHECK_VERSION(2,10,0) + treeViewGetSearchEntry, + treeViewSetSearchEntry, +#endif +#if GTK_CHECK_VERSION(2,6,0) + treeViewSetRowSeparatorFunc, +#if GTK_CHECK_VERSION(2,10,0) + treeViewGetRubberBanding, + treeViewSetRubberBanding, + treeViewGetEnableTreeLines, + treeViewSetEnableTreeLines, + treeViewGetGridLines, + treeViewSetGridLines, +#endif hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 218 +import System.Glib.Flags hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 223 +import Graphics.UI.Gtk.Gdk.Enums (DragAction(..)) +import Graphics.UI.Gtk.Gdk.Events (Modifier(..))[_^I_][_^I_][_^I_][_^I_][_^I_] [_$_] hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 229 -{#import Graphics.UI.Gtk.TreeList.TreePath#} -{#import Graphics.UI.Gtk.TreeList.TreeIter#} hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 230 +{#import Graphics.UI.Gtk.ModelView.Types#} +{#import Graphics.UI.Gtk.General.DNDTypes#} (TargetList(..)) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 414 --- | Insert new 'TreeViewColumn'. --- --- * Inserts new column into the --- 'TreeView' @self@ at position @pos@ with title --- ref argtitle, cell renderer @cr@ and attributes --- @attribs@. Specify -1 for @pos@ to insert the column at --- the end. --- -treeViewInsertColumnWithAttributes :: (TreeViewClass self, CellRendererClass cr) - => self -> Int -> String -> cr -> [(String,Int)] -> IO () -treeViewInsertColumnWithAttributes self pos title cr attribs = do - column <- treeViewColumnNew - treeViewColumnSetTitle column title - treeViewColumnPackStart column cr True - treeViewColumnAddAttributes column cr attribs - treeViewInsertColumn self column pos - return () - hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 33 + unsafeTreeModelToGeneric, hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 53 -{#import Graphics.UI.Gtk.Types#} () +{#import Graphics.UI.Gtk.Types#} (TreeModel) hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 69 +unsafeTreeModelToGeneric :: TreeModel -> model row +unsafeTreeModelToGeneric = unsafeCoerce# + |