Ticket #1163 (closed defect: invalid)

Opened 6 years ago

Last modified 6 years ago

Return type of treeModelSortGetModel

Reported by: guest Owned by: somebody
Priority: normal Milestone:
Component: general (Gtk+, Glib) Version: 0.9.12
Keywords: Cc:

Description (last modified by axel) (diff)

Hi. I'm not totally sure what I'm talking about, but it seems to me that the return type of treeModelSortGetModel should be TypedTreeModelClass? a rather than a generic TreeModel?.

treeModelSortNewWithModel :: (TreeModelClass (childModel row), TypedTreeModelClass childModel) => childModel row -> IO (TypedTreeModelSort row)

Creates a new TreeModelSort?, that will be a sorted view of the given model. Methods

treeModelSortGetModel :: TreeModelSortClass self => self -> IO TreeModel

Returns the underlying model the TreeModelSort? is sorting.

I'm having problems getting the currently selected row.

showSelectedProgramme ref = do
  xml <- liftM stXML $ readIORef ref
  view <- xmlGetWidget xml MV.castToTreeView "programmeTreeView"
  model' <- MV.treeViewGetModel view
  case model' of 
    Nothing -> return ()
    Just model -> do
      rawmodel <-  MV.treeModelSortGetModel model
      (path, col) <- MV.treeViewGetCursor view
      iter' <- MV.treeModelGetIter model path
      case iter' of 
        Nothing -> return ()
        Just iter -> do
          cIter <- MV.treeModelSortConvertIterToChildIter model iter
          p <- MV.treeModelGetRow rawmodel cIter
          displayProgrammeDetail ref p

(where ref is an IORef)

The following line is erroring p <- MV.treeModelGetRow rawmodel cIter since there doesn't seem to be a way of converting rawmodel to a typed ListStore?.

Change History

Changed 6 years ago by axel

  • description modified (diff)

Changed 6 years ago by axel

  • status changed from new to closed
  • resolution set to invalid

The return type of treeModelSortGetModel cannot be more general since you can call this function on any TreeModelSortClass. We could possibly provide a function that takes a typed TreeModelSort and returns a typed TreeModel.

Your problem is that you never create a typed ListStore and, in fact, retrieving the model from the view should throw an error since you have set no model for the view (although libglade might create an empty model for you in this case).

The solution is to create a ListStore and call it rawmodel. Remove the line

  rawmodel <- MV.treeModelSortGetModel model

and recompile. You need to add some rows to your view, though, before you see anything.

Note: See TracTickets for help on using tickets.