From: Axel S. <A....@ke...> - 2008-01-06 09:31:11
|
Thu Jan 3 10:56:41 PST 2008 A....@ke... * Update the TreeModelSort proxy to work with the new Haskell-land stores. This patch makes the TreeModelSort proxy fully functional. TreeModelSort encapsulates any model and provides a sorted view of it. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 32 --- child model and proxies its data. It has identical column types to this +-- child model and proxies its data. It has identical rows to its hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 34 --- purpose of this model is to provide a way to sort a different model without +-- purpose of this model is to provide a way to sort a model without hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 50 + TypedTreeModelSort, + hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 79 --------------------- --- Interfaces - ---instance TreeModelClass TreeModelSort ---TODO: this is only commented out because the old version also defines this --- instance. When we delete the old api, re-enable this instance. (That is --- if we keep this module at all) +instance TreeModelClass (TypedTreeModelSort a) +instance TreeModelSortClass (TypedTreeModelSort a) +instance GObjectClass (TypedTreeModelSort a) where + toGObject (TypedTreeModelSort tm) = mkGObject (castForeignPtr tm) + unsafeCastGObject = TypedTreeModelSort . castForeignPtr . unGObject +instance TreeSortableClass TreeModelSort +instance TreeSortableClass (TypedTreeModelSort row) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 93 -treeModelSortNewWithModel :: TreeModelClass childModel => childModel -> IO TreeModelSort -treeModelSortNewWithModel childModel = +treeModelSortNewWithModel :: (TreeModelClass (childModel row), + TypedTreeModelClass childModel) => + childModel row -> IO (TypedTreeModelSort row) +treeModelSortNewWithModel childModel = liftM unsafeTreeModelSortToGeneric $ hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 140 - {# call unsafe tree_model_sort_convert_path_to_child_path #} + {# call tree_model_sort_convert_path_to_child_path #} hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 169 - {# call unsafe tree_model_sort_convert_iter_to_child_iter #} + {# call tree_model_sort_convert_iter_to_child_iter #} hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeModelSort.chs.pp 175 --- | This resets the default sort function to be in the \'unsorted\' state. That --- is, it is in the same order as the child model. It will re-sort the model to --- be in the same order as the child model only if the 'TreeModelSort' is in [_$_] --- \'unsorted\' state. +-- | This resets the default sort function. As a consequence, the order of +-- this model will be the same order as that of the child model. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 22 --- treeViewMoveColumnAfter and treeViewMoveColumnFirst are not dealt with in --- Mogul --- hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 139 - treeViewGetSearchColumn, - treeViewSetSearchColumn, hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 181 - treeViewSearchColumn, hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 979 --- using the \"start-interactive-search\" key binding. +-- using the \"start-interactive-search\" key binding. In any case, +-- a predicate that compares a row of the model with the text the user +-- has typed must be set using 'treeViewSetSearchEqualFunc'. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 989 --- | Gets the column searched on by the interactive search. --- -treeViewGetSearchColumn :: TreeViewClass self => self - -> IO Int -treeViewGetSearchColumn self = - liftM fromIntegral $ - {# call unsafe tree_view_get_search_column #} - (toTreeView self) - --- | Sets @column@ as the column where the interactive search code should --- search in. --- --- If the sort column is set, users can use the \"start-interactive-search\" --- key binding to bring up search popup. The enable-search property controls --- whether simply typing text will also start an interactive search. --- --- Note that @column@ refers to a column of the model. --- -treeViewSetSearchColumn :: TreeViewClass self => self - -> Int -- ^ @column@ - the column of the model to search in, or -1 to - -- disable searching - -> IO () -treeViewSetSearchColumn self column = - {# call tree_view_set_search_column #} - (toTreeView self) - (fromIntegral column) - hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 991 --- * The default function assumes that the column @col@ has contains --- 'Attribute' @cr@ @String@. It conducts a --- case insensitive comparison of the text typed by the user and the --- text in the tree model. This function can be used to override this [_$_] --- behaviour. The predicate returns @True@ if the entries should --- be considered to match. The parameters are the column number, the text --- the user typed in and a 'TreeIter' which points to the cell --- to be compared. +-- * The predicate must returns @True@ if the text entered by the user +-- and the row of the model match. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 995 - -> (Int -> String -> TreeIter -> IO Bool) + -> Maybe (String -> TreeIter -> IO Bool) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 997 -treeViewSetSearchEqualFunc self pred = do - fPtr <- mkTreeViewSearchEqualFunc (\_ col keyPtr iterPtr _ -> do +treeViewSetSearchEqualFunc self (Just pred) = do + fPtr <- mkTreeViewSearchEqualFunc (\_ _ keyPtr iterPtr _ -> do hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 1001 - liftM (fromBool.not) $ pred (fromIntegral col) key iter) + liftM (fromBool . not) $ pred key iter) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 1005 + {# call tree_view_set_search_column #} (toTreeView self) 0 +treeViewSetSearchEqualFunc self Nothing = do + {# call tree_view_set_search_equal_func #} (toTreeView self) + nullFunPtr nullPtr nullFunPtr + {# call tree_view_set_search_column #} (toTreeView self) (-1) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeView.chs.pp 1412 --- | Model column to search through when searching through code. --- --- Allowed values: >= -1 --- --- Default value: -1 --- -treeViewSearchColumn :: TreeViewClass self => Attr self Int -treeViewSearchColumn = newAttr - treeViewGetSearchColumn - treeViewSetSearchColumn - hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 20 --- NOTES --- --- tree_view_column_new_with_attributes and tree_view_column_set_attributes [_$_] --- are variadic and the funcitonality can be achieved through other [_$_] --- functions. --- --- tree_view_column_set_cell_data and tree_view_column_cell_get_size are not --- bound because I am not sure what they do and when they are useful --- --- TODO --- --- treeViewColumnSetCellData is not bound. With this function the user has --- control over how data in the store is mapped to the attributes of a --- cell renderer. This functin should be bound in the future to allow the --- user to insert Haskell data types into the store and convert these --- values to attributes of cell renderers. --- hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 35 --- Please refer to the tree widget conceptual overview for an overview of --- all the objects and data types related to the tree widget and how they work --- together. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 92 +#if GTK_CHECK_VERSION(2,4,0) + treeViewColumnSetExpand, + treeViewColumnGetExpand, +#endif + treeViewColumnCellIsVisible, +#if GTK_CHECK_VERSION(2,2,0) + treeViewColumnFocusCell, +#if GTK_CHECK_VERSION(2,8,0) + treeViewColumnQueueResize, +#endif +#endif hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 114 + treeViewColumnExpand, hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 140 +import Graphics.UI.Gtk.General.Structs (SortColumnId) hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 437 --- will be clickable after this call. Logical refers to the column in --- the 'TreeModel'. +-- will be clickable after this call. Logical refers to the [_$_] +-- 'Graphics.UI.Gtk.ModelView.TreeSortable.SortColumnId' for which +-- a comparison function was set. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 441 -treeViewColumnSetSortColumnId :: TreeViewColumn -> Int -> IO () +treeViewColumnSetSortColumnId :: TreeViewColumn -> SortColumnId -> IO () hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 449 --- * Retrieves the logical @columnId@ that the model sorts on when --- this column is selected for sorting. +-- * Retrieves the logical @columnId@ that the model sorts on when this column +-- is selected for sorting. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 452 --- * Returns -1 if this column can't be used for sorting. +-- * Returns +-- 'Graphics.UI.Gtk.ModelView.TreeSortable.treeSortableDefaultSortColumnId' +-- if this tree view column has no +-- 'Graphics.UI.Gtk.ModelView.TreeSortable.SortColumnId' associated with it. hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 457 -treeViewColumnGetSortColumnId :: TreeViewColumn -> IO Int +treeViewColumnGetSortColumnId :: TreeViewColumn -> IO SortColumnId hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 501 +#if GTK_CHECK_VERSION(2,4,0) +-- %hash c:7808 d:942b +-- | Sets the column to take available extra space. This space is shared +-- equally amongst all columns that have the expand set to @True@. If no column +-- has this option set, then the last column gets all extra space. By default, +-- every column is created with this @False@. +-- +-- * Available since Gtk+ version 2.4 +-- +treeViewColumnSetExpand :: TreeViewColumn + -> Bool -- ^ @expand@ - @True@ if the column should take available extra + -- space, @False@ if not + -> IO () +treeViewColumnSetExpand self expand = + {# call gtk_tree_view_column_set_expand #} + self + (fromBool expand) + +-- %hash c:ee41 d:f16b +-- | Return @True@ if the column expands to take any available space. +-- +-- * Available since Gtk+ version 2.4 +-- +treeViewColumnGetExpand :: TreeViewColumn + -> IO Bool -- ^ returns @True@, if the column expands +treeViewColumnGetExpand self = + liftM toBool $ + {# call gtk_tree_view_column_get_expand #} + self +#endif + +-- %hash c:77e0 d:e1c7 +-- | Returns @True@ if any of the cells packed into the @treeColumn@ are +-- visible. For this to be meaningful, you must first initialize the cells with +-- 'treeViewColumnCellSetCellData' +-- +treeViewColumnCellIsVisible :: TreeViewColumn + -> IO Bool -- ^ returns @True@, if any of the cells packed into the + -- @treeColumn@ are currently visible +treeViewColumnCellIsVisible self = + liftM toBool $ + {# call gtk_tree_view_column_cell_is_visible #} + self + +#if GTK_CHECK_VERSION(2,2,0) +-- %hash c:a202 d:1401 +-- | Sets the current keyboard focus to be at @cell@, if the column contains 2 +-- or more editable and activatable cells. +-- +-- * Available since Gtk+ version 2.2 +-- +treeViewColumnFocusCell :: CellRendererClass cell => TreeViewColumn + -> cell -- ^ @cell@ - A 'CellRenderer' + -> IO () +treeViewColumnFocusCell self cell = + {# call gtk_tree_view_column_focus_cell #} + self + (toCellRenderer cell) + +#if GTK_CHECK_VERSION(2,8,0) +-- %hash c:4420 d:bfde +-- | Flags the column, and the cell renderers added to this column, to have +-- their sizes renegotiated. +-- +-- * Available since Gtk+ version 2.8 +-- +treeViewColumnQueueResize :: TreeViewColumn -> IO () +treeViewColumnQueueResize self = + {# call gtk_tree_view_column_queue_resize #} + self +#endif +#endif + hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 666 +-- %hash c:800 d:eb1a +-- | Column gets share of extra width allocated to the widget. +-- +-- Default value: @False@ +-- +treeViewColumnExpand :: Attr TreeViewColumn Bool +treeViewColumnExpand = newAttrFromBoolProperty "expand" + hunk ./gtk/Graphics/UI/Gtk/ModelView/TreeViewColumn.chs.pp 731 -treeViewColumnSortColumnId :: Attr TreeViewColumn Int +treeViewColumnSortColumnId :: Attr TreeViewColumn SortColumnId hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 35 + TypedTreeModelSort(..), + unsafeTreeModelSortToGeneric, + [_$_] hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 57 -{#import Graphics.UI.Gtk.Types#} (TreeModel) +{#import Graphics.UI.Gtk.Types#} (TreeModel, TreeModelSort) hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 67 + dummy _ = error "not used" hunk ./gtk/Graphics/UI/Gtk/ModelView/Types.chs 79 +newtype TypedTreeModelSort row = TypedTreeModelSort (ForeignPtr (TypedTreeModelSort row)) + +unsafeTreeModelSortToGeneric :: TreeModelSort -> TypedTreeModelSort row +unsafeTreeModelSortToGeneric = unsafeCoerce# + +instance TypedTreeModelClass TypedTreeModelSort + hunk ./gtk/Graphics/UI/Gtk/ModelView.hs 49 + module Graphics.UI.Gtk.ModelView.TreeSortable, hunk ./gtk/Graphics/UI/Gtk/ModelView.hs 73 +import Graphics.UI.Gtk.ModelView.TreeSortable |