From: Axel S. <A....@ke...> - 2007-12-04 21:36:23
|
Tue Dec 4 13:35:15 PST 2007 A....@ke... * Add DND functions to IconView. hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 93 -{- iconViewGetItemAtPos, + iconViewGetItemAtPos, hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 104 - iconViewSetDragDestItem, - iconViewGetDragDestItem, - iconViewGetDestItemAtPos, - -} iconViewCreateDragIcon, hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 135 -{#import System.Glib.GList#} +import System.Glib.GList (fromGList) +import System.Glib.Flags hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 139 +import Graphics.UI.Gtk.Gdk.Enums (DragAction(..)) +import Graphics.UI.Gtk.Gdk.Events (Modifier(..)) hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 147 +{#import Graphics.UI.Gtk.General.DNDTypes#} (TargetList(..)) hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 730 -{- hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 736 - -> [ModifierType] -- ^ @startButtonMask@ - Mask of allowed buttons - -- to start drag - -> {-const-GtkTargetEntry*-} -- ^ @targets@ - the table of targets that the - -- drag will support - -> Int -- ^ @nTargets@ - the number of items in - -- @targets@ - -> [DragAction] -- ^ @actions@ - the bitmask of possible actions - -- for a drag from this widget - -> IO () -iconViewEnableModelDragSource self startButtonMask targets nTargets actions = + -> [Modifier] -- ^ @startButtonMask@ - Mask of allowed buttons + -- to start drag + -> TargetList -- ^ @targets@ - the list of targets that the + -- the view will support + -> [DragAction] -- ^ @actions@ - flags denoting the possible actions + -- for a drag from this widget + -> IO () +iconViewEnableModelDragSource self startButtonMask targets actions = + alloca $ \nTargetsPtr -> do + tlPtr <- {#call unsafe gtk_target_table_new_from_list#} targets nTargetsPtr + nTargets <- peek nTargetsPtr hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 750 - {-targets-} - (fromIntegral nTargets) + tlPtr + nTargets hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 753 + {#call unsafe gtk_target_table_free#} tlPtr nTargets hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 761 - -> {-const-GtkTargetEntry*-} -- ^ @targets@ - the table of targets that the - -- drag will support - -> Int -- ^ @nTargets@ - the number of items in - -- @targets@ - -> [DragAction] -- ^ @actions@ - the bitmask of possible actions - -- for a drag to this widget - -> IO () -iconViewEnableModelDragDest self targets nTargets actions = + -> TargetList -- ^ @targets@ - the list of targets that the + -- the view will support + -> [DragAction] -- ^ @actions@ - flags denoting the possible actions + -- for a drop into this widget + -> IO () +iconViewEnableModelDragDest self targets actions = + alloca $ \nTargetsPtr -> do + tlPtr <- {#call unsafe gtk_target_table_new_from_list#} targets nTargetsPtr + nTargets <- peek nTargetsPtr hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 772 - {-targets-} - (fromIntegral nTargets) + tlPtr + nTargets hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 785 --} hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 797 --- | This function is a convenience function to allow you to reorder models --- that support the {GtkTreeDragSourceIface, FIXME: unknown type\/value} and --- the {GtkTreeDragDestIface, FIXME: unknown type\/value}. Both 'TreeStore' and --- 'ListStore' support these. If @reorderable@ is @True@, then the user can --- reorder the model by dragging and dropping rows. The developer can listen to --- these changes by connecting to the model's row_inserted and row_deleted --- signals. +-- | Check if icons can be moved around. hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 799 --- This function does not give you any degree of control over the order -- --- any reordering is allowed. If more control is needed, you should probably --- handle drag and drop manually. +-- * Set whether the user can use drag and drop (DND) to reorder the rows in +-- the store. This works on both 'TreeStore' and 'ListStore' models. If @ro@ +-- is @True@, then the user can reorder the model by dragging and dropping +-- rows. The developer can listen to these changes by connecting to the +-- model's signals. If you need to control which rows may be dragged or +-- where rows may be dropped, you can override the +-- 'Graphics.UI.Gtk.ModelView.CustomStore.treeDragSourceRowDraggable' +-- function in the default DND implementation of the model. hunk ./gtk/Graphics/UI/Gtk/ModelView/IconView.chs.pp 831 -{- --- %hash c:9574 d:34ea --- | Sets the item that is highlighted for feedback. --- --- * Available since Gtk+ version 2.8 --- -iconViewSetDragDestItem :: IconViewClass self => self - -> TreePath -- ^ @path@ - The path of the item to highlight, or - -- {@NULL@, FIXME: this should probably be converted - -- to a Maybe data type}. - -> IconViewDropPosition -- ^ @pos@ - Specifies where to drop, relative to the - -- item - -> IO () -iconViewSetDragDestItem self path pos = - withTreePath path $ \path -> - {# call gtk_icon_view_set_drag_dest_item #} - (toIconView self) - path - ((fromIntegral . fromEnum) pos) - --- %hash c:92a7 d:8b3f --- | Gets information about the item that is highlighted for feedback. --- --- * Available since Gtk+ version 2.8 --- -iconViewGetDragDestItem :: IconViewClass self => self - -> {-GtkTreePath**-} -- ^ @path@ - Return location for the path of - -- the highlighted item, or {@NULL@, FIXME: - -- this should probably be converted to a - -- Maybe data type}. - -> {-GtkIconViewDropPosition*-} -- ^ @pos@ - Return location for the drop - -- position, or {@NULL@, FIXME: this should - -- probably be converted to a Maybe data type} - -> IO () -iconViewGetDragDestItem self path pos = - {# call gtk_icon_view_get_drag_dest_item #} - (toIconView self) - {-path-} - {-pos-} - --- %hash c:28ff d:dcf9 --- | Determines the destination item for a given position. --- --- * Available since Gtk+ version 2.8 --- -iconViewGetDestItemAtPos :: IconViewClass self => self - -> Int -- ^ @dragX@ - the position to determine the - -- destination item for - -> Int -- ^ @dragY@ - the position to determine the - -- destination item for - -> {-GtkTreePath**-} -- ^ @path@ - Return location for the path of - -- the item, or {@NULL@, FIXME: this should - -- probably be converted to a Maybe data - -- type}. - -> {-GtkIconViewDropPosition*-} -- ^ @pos@ - Return location for the drop - -- position, or {@NULL@, FIXME: this should - -- probably be converted to a Maybe data type} - -> IO Bool -- ^ returns whether there is an item at the - -- given position. -iconViewGetDestItemAtPos self dragX dragY path pos = - liftM toBool $ - {# call gtk_icon_view_get_dest_item_at_pos #} - (toIconView self) - (fromIntegral dragX) - (fromIntegral dragY) - {-path-} - {-pos-} - --} - --- %hash c:e65a d:3e9 --- | Creates a 'Pixmap' representation of the item at @path@. This image is --- used for a drag icon. --- --- * Available since Gtk+ version 2.8 --- -iconViewCreateDragIcon :: IconViewClass self => self - -> TreePath -- ^ @path@ - a 'TreePath' in @iconView@ - -> IO Pixmap -- ^ returns a pixmap of the drag icon. -iconViewCreateDragIcon self path = - constructNewGObject mkPixmap $ - withTreePath path $ \path -> - {# call gtk_icon_view_create_drag_icon #} - (toIconView self) - path |