From: Axel S. <A....@ke...> - 2007-12-02 21:38:34
|
Fri Jul 20 05:34:34 PDT 2007 A....@ke... * Add drag and drop interfaces to the CustomStore. Both, ListStore and TreeStore should implement the drag and drop interfaces because the Gtk ListStore and TreeStore do. However, I'm not sure yet what they exactly implement; I assume they only accept rows from the same store. Figure out how to implement this in Haskell and provide a way to add the possiblity of accepting other dnd sources and destinations as well. hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 33 - columnMapNew, hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 38 - CustomTreeModelImplementation(..), + TreeModelIface(..), hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 44 -import Control.Monad (liftM, when) -import Data.IORef +import Control.Monad (liftM, when) +import Control.Monad.Reader (runReaderT) +import Data.IORef (IORef, newIORef, readIORef, writeIORef) +import Data.Maybe (fromMaybe) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 53 -import System.Glib.StoreValue (TMType(..), GenericValue(..) - ,valueSetGenericValue) +import Graphics.UI.Gtk.General.DNDTypes (SelectionDataM, SelectionData) + +import System.Glib.StoreValue (TMType(..), GenericValue(..), valueSetGenericValue) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 77 --- A CustomTreeModel is backed by a Gtk2HsStore +-- | A CustomTreeModel is backed by a Gtk2HsStore merger 0.0 ( hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 81 -instance GObjectClass (CustomTreeModel private row) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 81 +-- this is currently a receipe for segfaults: ) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 128 - customTreeModelGetFlags :: IO [TreeModelFlags], - customTreeModelColumns :: ColumnMap row, -- provide access via columns - customTreeModelGetIter :: TreePath -> IO (Maybe TreeIter), -- convert a path to an iterator - customTreeModelGetPath :: TreeIter -> IO TreePath, -- convert an interator to a path - customTreeModelGetRow :: TreeIter -> IO row, -- get the row at an iter - customTreeModelIterNext :: TreeIter -> IO (Maybe TreeIter), -- following row (if any) - customTreeModelIterChildren :: Maybe TreeIter -> IO (Maybe TreeIter), -- first child row (if any) - customTreeModelIterHasChild :: TreeIter -> IO Bool, -- row has any children at all - customTreeModelIterNChildren :: Maybe TreeIter -> IO Int, -- number of children of a row - customTreeModelIterNthChild :: Maybe TreeIter -> Int -> IO (Maybe TreeIter), -- nth child row of a given row - customTreeModelIterParent :: TreeIter -> IO (Maybe TreeIter), -- parent row of a row - customTreeModelRefNode :: TreeIter -> IO (), -- caching hint - customTreeModelUnrefNode :: TreeIter -> IO () -- caching hint + customTreeModelColumns :: ColumnMap row, -- provide access via columns + customTreeModelIface :: TreeModelIface row, -- functions implementing a tree model + customTreeDragSourceIface :: DragSourceIface, -- the drag and drop source interface + customTreeDragDestIface :: DragDestIface -- the drag and drop dest interface + } + +data TreeModelIface row = TreeModelIface { + treeModelIfaceGetFlags :: IO [TreeModelFlags], + treeModelIfaceGetIter :: TreePath -> IO (Maybe TreeIter), -- convert a path to an iterator + treeModelIfaceGetPath :: TreeIter -> IO TreePath, -- convert an interator to a path + treeModelIfaceGetRow :: TreeIter -> IO row, -- get the row at an iter + treeModelIfaceIterNext :: TreeIter -> IO (Maybe TreeIter), -- following row (if any) + treeModelIfaceIterChildren :: Maybe TreeIter -> IO (Maybe TreeIter), -- first child row (if any) + treeModelIfaceIterHasChild :: TreeIter -> IO Bool, -- row has any children at all + treeModelIfaceIterNChildren :: Maybe TreeIter -> IO Int, -- number of children of a row + treeModelIfaceIterNthChild :: Maybe TreeIter -> Int -> IO (Maybe TreeIter), -- nth child row of a given row + treeModelIfaceIterParent :: TreeIter -> IO (Maybe TreeIter), -- parent row of a row + treeModelIfaceRefNode :: TreeIter -> IO (), -- caching hint + treeModelIfaceUnrefNode :: TreeIter -> IO () -- caching hint hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 149 -customTreeModelNew :: private -> CustomTreeModelImplementation row -> IO (CustomTreeModel private row) -customTreeModelNew priv impl = do - implPtr <- newStablePtr impl +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 DragDestIface = DragDestIface { + treeDragDestDragDataReceived:: TreePath -> SelectionDataM Bool, -- insert row from selection object + treeDragDestRowDropPossible :: TreePath -> SelectionDataM Bool -- query if row drop is possible + } + [_$_] +-- | Create a new store that implements the 'TreeModelIface' interface and +-- optionally the 'DragSourceIface' and the 'DragDestIface'. If the latter to +-- are set to @Nothing@ a dummy interface is substituted that rejects every +-- 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 + cMap <- columnMapNew + 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 } hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 194 - customTreeModelGetRow impl iter + treeModelIfaceGetRow (customTreeModelIface impl) iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 222 - -customTreeModelGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt -customTreeModelGetFlags_static storePtr = do - store <- deRefStablePtr storePtr - liftM (fromIntegral . fromFlags) $ customTreeModelGetFlags store - -foreign export ccall "gtk2hs_store_get_flags_impl" - customTreeModelGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt - - -customTreeModelGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt -customTreeModelGetNColumns_static storePtr = do +treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt +treeModelIfaceGetNColumns_static storePtr = do hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 229 - customTreeModelGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt + treeModelIfaceGetNColumns_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 238 -customTreeModelGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType -customTreeModelGetColumnType_static storePtr column = do +treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType +treeModelIfaceGetColumnType_static storePtr column = do hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 247 - customTreeModelGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType + treeModelIfaceGetColumnType_static :: StablePtr (CustomTreeModelImplementation row) -> CInt -> IO GType hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 250 -customTreeModelGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt -customTreeModelGetIter_static storePtr iterPtr pathPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt +treeModelIfaceGetFlags_static storePtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr + liftM (fromIntegral . fromFlags) $ treeModelIfaceGetFlags store + +foreign export ccall "gtk2hs_store_get_flags_impl" + treeModelIfaceGetFlags_static :: StablePtr (CustomTreeModelImplementation row) -> IO CInt + + +treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt +treeModelIfaceGetIter_static storePtr iterPtr pathPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 263 - iter <- customTreeModelGetIter store path + iter <- treeModelIfaceGetIter store path hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 270 - customTreeModelGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt + treeModelIfaceGetIter_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr NativeTreePath -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 272 -customTreeModelGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) -customTreeModelGetPath_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) +treeModelIfaceGetPath_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 276 - path <- customTreeModelGetPath store iter + path <- treeModelIfaceGetPath store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 281 - customTreeModelGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) + treeModelIfaceGetPath_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO (Ptr NativeTreePath) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 284 -customTreeModelGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () -customTreeModelGetValue_static storePtr iterPtr column gvaluePtr = do +treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () +treeModelIfaceGetValue_static storePtr iterPtr column gvaluePtr = do hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 288 - row <- customTreeModelGetRow store iter + row <- treeModelIfaceGetRow (customTreeModelIface store) iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 302 - customTreeModelGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () + treeModelIfaceGetValue_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> CInt -> Ptr GValue -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 305 -customTreeModelIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt -customTreeModelIterNext_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterNext_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 309 - iter' <- customTreeModelIterNext store iter + iter' <- treeModelIfaceIterNext store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 316 - customTreeModelIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterNext_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 319 -customTreeModelIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt -customTreeModelIterChildren_static storePtr iterPtr parentIterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt +treeModelIfaceIterChildren_static storePtr iterPtr parentIterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 323 - iter <- customTreeModelIterChildren store parentIter + iter <- treeModelIfaceIterChildren store parentIter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 330 - customTreeModelIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt + treeModelIfaceIterChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 333 -customTreeModelIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt -customTreeModelIterHasChild_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterHasChild_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 337 - liftM fromBool $ customTreeModelIterHasChild store iter + liftM fromBool $ treeModelIfaceIterHasChild store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 340 - customTreeModelIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterHasChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 343 -customTreeModelIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt -customTreeModelIterNChildren_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt +treeModelIfaceIterNChildren_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 347 - liftM fromIntegral $ customTreeModelIterNChildren store iter + liftM fromIntegral $ treeModelIfaceIterNChildren store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 350 - customTreeModelIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt + treeModelIfaceIterNChildren_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 353 -customTreeModelIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt -customTreeModelIterNthChild_static storePtr iterPtr parentIterPtr n = do - store <- deRefStablePtr storePtr +treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt +treeModelIfaceIterNthChild_static storePtr iterPtr parentIterPtr n = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 357 - iter <- customTreeModelIterNthChild store parentIter (fromIntegral n) + iter <- treeModelIfaceIterNthChild store parentIter (fromIntegral n) hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 364 - customTreeModelIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt + treeModelIfaceIterNthChild_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> CInt -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 367 -customTreeModelIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt -customTreeModelIterParent_static storePtr iterPtr childIterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt +treeModelIfaceIterParent_static storePtr iterPtr childIterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 371 - iter <- customTreeModelIterParent store childIter + iter <- treeModelIfaceIterParent store childIter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 378 - customTreeModelIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt + treeModelIfaceIterParent_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> Ptr TreeIter -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 381 -customTreeModelRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () -customTreeModelRefNode_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () +treeModelIfaceRefNode_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 385 - customTreeModelRefNode store iter + treeModelIfaceRefNode store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 388 - customTreeModelRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () + treeModelIfaceRefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 391 -customTreeModelUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () -customTreeModelUnrefNode_static storePtr iterPtr = do - store <- deRefStablePtr storePtr +treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () +treeModelIfaceUnrefNode_static storePtr iterPtr = do + store <- liftM customTreeModelIface $ deRefStablePtr storePtr hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 395 - customTreeModelUnrefNode store iter + treeModelIfaceUnrefNode store iter hunk ./gtk/Graphics/UI/Gtk/ModelView/CustomStore.chs 398 - customTreeModelUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () + treeModelIfaceUnrefNode_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr TreeIter -> IO () + +treeDragSourceRowDraggable_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt +treeDragSourceRowDraggable_static storePtr pathPtr = do + store <- liftM customTreeDragSourceIface $ deRefStablePtr storePtr + path <- peekTreePath pathPtr + liftM fromBool $ treeDragSourceRowDraggable store path + +foreign export ccall "gtk2hs_store_row_draggable_impl" + treeDragSourceRowDraggable_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt + +treeDragSourceDragDataGet_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragSourceDragDataGet_static storePtr pathPtr selectionPtr = do + store <- liftM customTreeDragSourceIface $ deRefStablePtr storePtr + path <- peekTreePath pathPtr + liftM fromBool $ runReaderT (treeDragSourceDragDataGet store path) selectionPtr + +foreign export ccall "gtk2hs_store_drag_data_get_impl" + treeDragSourceDragDataGet_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt + +treeDragSourceDragDataDelete_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt +treeDragSourceDragDataDelete_static storePtr pathPtr = do + store <- liftM customTreeDragSourceIface $ deRefStablePtr storePtr + path <- peekTreePath pathPtr + liftM fromBool $ treeDragSourceDragDataDelete store path + +foreign export ccall "gtk2hs_store_drag_data_delete_impl" + treeDragSourceDragDataDelete_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> IO CInt + +treeDragDestDragDataReceived_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragDestDragDataReceived_static storePtr pathPtr selectionPtr = do + store <- liftM customTreeDragDestIface $ deRefStablePtr storePtr + path <- peekTreePath pathPtr + liftM fromBool $ runReaderT (treeDragDestDragDataReceived store path) selectionPtr + +foreign export ccall "gtk2hs_store_drag_data_received_impl" + treeDragDestDragDataReceived_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt + +treeDragDestRowDropPossible_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt +treeDragDestRowDropPossible_static storePtr pathPtr selectionPtr = do + store <- liftM customTreeDragDestIface $ deRefStablePtr storePtr + path <- peekTreePath pathPtr + liftM fromBool $ runReaderT (treeDragDestRowDropPossible store path) selectionPtr + +foreign export ccall "gtk2hs_store_row_drop_possible_impl" + treeDragDestRowDropPossible_static :: StablePtr (CustomTreeModelImplementation row) -> Ptr NativeTreePath -> SelectionData -> IO CInt hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 14 +static void gtk2hs_store_tree_drag_source_init (GtkTreeDragSourceIface *iface); +static void gtk2hs_store_tree_drag_dest_init (GtkTreeDragDestIface *iface); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 50 +/* The TreeSortable interface is currently not implemented and may never be. +static gbooelan gtk2hs_store_get_sort_column_id (GtkTreeSortable *sortable, + gint sort_column_id, + GtkSortType *order); +static void gtk2hs_store_set_sort_column_id (GtkTreeSortable *sortable, + gint sort_column_id, + GtkSortType order); +static void gtk2hs_store_set_sort_func (GtkTreeSortable *sortable, + gint sort_column_id, + GtkTreeIterCompareFunc func, + gpointer data, + GtkDestroyNotify destroy); +static void gtk2hs_store_set_default_sort_func (GtkTreeSortable *sortable, + GtkTreeIterCompareFunc func, + gpointer data, + GtkDestroyNotify destroy); +static gboolean gtk2hs_store_has_default_sort_func (GtkTreeSortable *sortable); +*/ hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 69 +static gboolean gtk2hs_store_row_draggable (GtkTreeDragSource *drag_source, + GtkTreePath *path); +static gboolean gtk2hs_store_drag_data_get (GtkTreeDragSource *drag_source, + GtkTreePath *path, + GtkSelectionData *selection_data); +static gboolean gtk2hs_store_drag_data_delete (GtkTreeDragSource *drag_source, + GtkTreePath *path); +static gboolean gtk2hs_store_drag_data_received (GtkTreeDragDest *drag_dest, + GtkTreePath *dest_path, + GtkSelectionData *selection_data); +static gboolean gtk2hs_store_row_drop_possible (GtkTreeDragDest *drag_dest, + GtkTreePath *dest_path, + GtkSelectionData *selection_data); + [_$_] hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 121 +/* The TreeSortable interface is currently not implemented. + static const GInterfaceInfo tree_sortable_info = + { + (GInterfaceInitFunc) gtk2hs_store_tree_sortable_init, + NULL, + NULL + }; +*/ + static const GInterfaceInfo tree_drag_source_info = + { + (GInterfaceInitFunc) gtk2hs_store_tree_drag_source_init, + NULL, + NULL + }; + + static const GInterfaceInfo tree_drag_dest_info = + { + (GInterfaceInitFunc) gtk2hs_store_tree_drag_dest_init, + NULL, + NULL + }; + hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 150 + [_$_] +/* The TreeSortable interface is currently not implemented. + g_type_add_interface_static (gtk2hs_store_type, + GTK_TYPE_TREE_SORTABLE, + &tree_sortable_info); +*/ + [_$_] + g_type_add_interface_static (gtk2hs_store_type, + GTK_TYPE_TREE_DRAG_SOURCE, + &tree_drag_source_info); + [_$_] + g_type_add_interface_static (gtk2hs_store_type, + GTK_TYPE_TREE_DRAG_DEST, + &tree_drag_dest_info); hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 217 +/** + * + * gtk2hs_store_tree_sortable_init: init callback for the interface registration + * in gtk2hs_store_get_type. Here we override + * the GtkTreeSortable interface functions that + * we implement. + * + **/ +/* The TreeSortable interface is currently not implemented. +static void +gtk2hs_store_tree_sortable_init (GtkTreeModelIface *iface) +{ + WHEN_DEBUG(g_debug("calling gtk2hs_store_tree_sortable_init\t(%p)\n", iface)); + iface->get_sort_column_id = gtk2hs_store_get_sort_column_id; + iface->set_sort_column_id = gtk2hs_store_set_sort_column_id; + iface->set_sort_func = gtk2hs_store_set_sort_func; + iface->set_default_sort_func = gtk2hs_store_set_default_sort_func; + iface->has_default_sort_func = gtk2hs_store_has_default_sort_func; +} +*/ + +/** + * + * gtk2hs_store_tree_drag_source_init: init callback for the interface registration + * in gtk2hs_store_get_type. Here we override + * the GtkTreeDragSource interface functions that + * we implement. + * + **/ +static void +gtk2hs_store_tree_drag_source_init (GtkTreeDragSourceIface *iface) +{ + WHEN_DEBUG(g_debug("calling gtk2hs_store_tree_drag_source_init\t(%p)\n", iface)); + iface->row_draggable = gtk2hs_store_row_draggable; + iface->drag_data_get = gtk2hs_store_drag_data_get; + iface->drag_data_delete = gtk2hs_store_drag_data_delete; +} + +/** + * + * gtk2hs_store_tree_drag_dest_init: init callback for the interface registration + * in gtk2hs_store_get_type. Here we override + * the GtkTreeDragDest interface functions that + * we implement. + * + **/ +static void +gtk2hs_store_tree_drag_dest_init (GtkTreeDragDestIface *iface) +{ + WHEN_DEBUG(g_debug("calling gtk2hs_store_tree_drag_dest_init\t(%p)\n", iface)); + iface->drag_data_received = gtk2hs_store_drag_data_received; + iface->row_drop_possible = gtk2hs_store_row_drop_possible; +} hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.c 625 + +static gboolean +gtk2hs_store_row_draggable (GtkTreeDragSource *drag_source, + GtkTreePath *path) { + WHEN_DEBUG( + gchar *path_str = gtk_tree_path_to_string(path); + g_debug("calling gtk2hs_store_row_draggable\t\t(%p, \"%s\")\n", drag_source, path_str); + g_free(path_str); + ) + Gtk2HsStore *store = (Gtk2HsStore *) drag_source; + g_return_val_if_fail (GTK2HS_IS_STORE (drag_source), FALSE); + [_$_] + gboolean result = gtk2hs_store_row_draggable_impl(store->impl, path); + WHEN_DEBUG(g_debug("return gtk2hs_store_row_draggable\t\t=%s\n", result ? "TRUE" : "FALSE")); + return result; +} + +static gboolean +gtk2hs_store_drag_data_get (GtkTreeDragSource *drag_source, + GtkTreePath *path, + GtkSelectionData *selection_data) { + WHEN_DEBUG( + gchar *path_str = gtk_tree_path_to_string(path); + g_debug("calling gtk2hs_store_drag_data_get\t\t(%p, \"%s\", %p)\n", drag_source, path_str, selection_data); + g_free(path_str); + ) + Gtk2HsStore *store = (Gtk2HsStore *) drag_source; + g_return_val_if_fail (GTK2HS_IS_STORE (drag_source), FALSE); + g_return_val_if_fail (selection_data!=NULL, FALSE); + [_$_] + gboolean result = gtk2hs_store_drag_data_get_impl(store->impl, path, selection_data); + WHEN_DEBUG(g_debug("return gtk2hs_store_drag_data_get\t\t=%s\n", result ? "TRUE" : "FALSE")); + return result; +} + +static gboolean +gtk2hs_store_drag_data_delete (GtkTreeDragSource *drag_source, + GtkTreePath *path) { + WHEN_DEBUG( + gchar *path_str = gtk_tree_path_to_string(path); + g_debug("calling gtk2hs_store_drag_data_delete\t\t(%p, \"%s\")\n", drag_source, path_str); + g_free(path_str); + ) + Gtk2HsStore *store = (Gtk2HsStore *) drag_source; + g_return_val_if_fail (GTK2HS_IS_STORE (drag_source), FALSE); + + gboolean result = gtk2hs_store_drag_data_delete_impl(store->impl, path); + WHEN_DEBUG(g_debug("return gtk2hs_store_drag_data_delete\t\t=%s\n", result ? "TRUE" : "FALSE")); + return result; +} + +static gboolean +gtk2hs_store_drag_data_received (GtkTreeDragDest *drag_dest, + GtkTreePath *dest_path, + GtkSelectionData *selection_data) { + WHEN_DEBUG( + gchar *path_str = gtk_tree_path_to_string(dest_path); + g_debug("calling gtk2hs_store_drag_data_received\t\t(%p, \"%s\", %p)\n", drag_dest, path_str, selection_data); + g_free(path_str); + ) + Gtk2HsStore *store = (Gtk2HsStore *) drag_dest; + g_return_val_if_fail (GTK2HS_IS_STORE (drag_dest), FALSE); + g_return_val_if_fail (selection_data!=NULL, FALSE); + + gboolean result = gtk2hs_store_drag_data_received_impl(store->impl, dest_path, selection_data); + WHEN_DEBUG(g_debug("return gtk2hs_store_drag_data_received\t\t=%s\n", result ? "TRUE" : "FALSE")); + return result; +} + +static gboolean +gtk2hs_store_row_drop_possible (GtkTreeDragDest *drag_dest, + GtkTreePath *dest_path, + GtkSelectionData *selection_data) { + WHEN_DEBUG( + gchar *path_str = gtk_tree_path_to_string(dest_path); + g_debug("calling gtk2hs_store_row_drop_possible\t\t(%p, \"%s\", %p)\n", drag_dest, path_str, selection_data); + g_free(path_str); + ) + Gtk2HsStore *store = (Gtk2HsStore *) drag_dest; + g_return_val_if_fail (GTK2HS_IS_STORE (drag_dest), FALSE); + g_return_val_if_fail (selection_data!=NULL, FALSE); + + gboolean result = gtk2hs_store_row_drop_possible_impl(store->impl, dest_path, selection_data); + WHEN_DEBUG(g_debug("return gtk2hs_store_row_drop_possible\t\t=%s\n", result ? "TRUE" : "FALSE")); + return result; +} hunk ./gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.h 5 +#include <gtk/gtktreednd.h> hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 75 - cMap <- columnMapNew hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 76 - liftM ListStore $ customTreeModelNew rows CustomTreeModelImplementation { - customTreeModelGetFlags = return [TreeModelListOnly], - customTreeModelColumns = cMap, - customTreeModelGetIter = \[n] -> readIORef rows >>= \rows -> + liftM ListStore $ customTreeModelNew rows TreeModelIface { + treeModelIfaceGetFlags = return [TreeModelListOnly], + treeModelIfaceGetIter = \[n] -> readIORef rows >>= \rows -> hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 81 - customTreeModelGetPath = \(TreeIter _ n _ _) -> return [fromIntegral n], - customTreeModelGetRow = \(TreeIter _ n _ _) -> + treeModelIfaceGetPath = \(TreeIter _ n _ _) -> return [fromIntegral n], + treeModelIfaceGetRow = \(TreeIter _ n _ _) -> hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 88 - customTreeModelIterNext = \(TreeIter _ n _ _) -> + treeModelIfaceIterNext = \(TreeIter _ n _ _) -> hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 93 - customTreeModelIterChildren = \_ -> return Nothing, - customTreeModelIterHasChild = \_ -> return False, - customTreeModelIterNChildren = \index -> readIORef rows >>= \rows -> + treeModelIfaceIterChildren = \_ -> return Nothing, + treeModelIfaceIterHasChild = \_ -> return False, + treeModelIfaceIterNChildren = \index -> readIORef rows >>= \rows -> hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 99 - customTreeModelIterNthChild = \index n -> case index of + treeModelIfaceIterNthChild = \index n -> case index of hunk ./gtk/Graphics/UI/Gtk/ModelView/ListStore.hs.pp 102 - customTreeModelIterParent = \_ -> return Nothing, - customTreeModelRefNode = \_ -> return (), - customTreeModelUnrefNode = \_ -> return () - } + treeModelIfaceIterParent = \_ -> return Nothing, + treeModelIfaceRefNode = \_ -> return (), + treeModelIfaceUnrefNode = \_ -> return () + } Nothing Nothing hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 105 - cMap <- columnMapNew hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 106 - liftM TreeStore $ customTreeModelNew storeRef CustomTreeModelImplementation { - customTreeModelGetFlags = return [], + liftM TreeStore $ customTreeModelNew storeRef TreeModelIface { + treeModelIfaceGetFlags = return [], hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 109 - customTreeModelColumns = cMap, - - customTreeModelGetIter = \path -> withStore $ + treeModelIfaceGetIter = \path -> withStore $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 112 - customTreeModelGetPath = \iter -> withStore $ + treeModelIfaceGetPath = \iter -> withStore $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 115 - customTreeModelGetRow = \iter -> withStoreUpdateCache $ + treeModelIfaceGetRow = \iter -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 122 - customTreeModelIterNext = \iter -> withStoreUpdateCache $ + treeModelIfaceIterNext = \iter -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 125 - customTreeModelIterChildren = \mIter -> withStoreUpdateCache $ + treeModelIfaceIterChildren = \mIter -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 130 - customTreeModelIterHasChild = \iter -> withStoreUpdateCache $ + treeModelIfaceIterHasChild = \iter -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 135 - customTreeModelIterNChildren = \mIter -> withStoreUpdateCache $ + treeModelIfaceIterNChildren = \mIter -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 140 - customTreeModelIterNthChild = \mIter idx -> withStoreUpdateCache $ + treeModelIfaceIterNthChild = \mIter idx -> withStoreUpdateCache $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 145 - customTreeModelIterParent = \iter -> withStore $ + treeModelIfaceIterParent = \iter -> withStore $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeStore.hs 148 - customTreeModelRefNode = \_ -> return (), - customTreeModelUnrefNode = \_ -> return () - } + treeModelIfaceRefNode = \_ -> return (), + treeModelIfaceUnrefNode = \_ -> return () + } Nothing Nothing |