-- | menu button for local menus
createMenuButton :: String -> (Int -> DGraph -> IO ())
                 -> GInfo -> ButtonMenu GA.NodeValue
createMenuButton title menuFun gi = Button title
  $ \ (_, descr) -> do
    ost <- readIORef $ intState gi
    case i_state ost of
      Nothing -> return ()
      Just ist -> do
        let le = i_libEnv ist
            dGraph = lookupDGraph (libName gi) le
        menuFun descr dGraph
        return ()
createMenuButton :: String -> (Int -> DGraph -> IO ())
                 -> GInfo -> ButtonMenu GA.NodeValue
createMenuButton title menuFun gi = Button title
  $ \ (_, descr) -> do
    ost <- readIORef $ intState gi
    case i_state ost of
      Nothing -> return ()
      Just ist -> do
        let le = i_libEnv ist
            dGraph = lookupDGraph (libName gi) le
        menuFun descr dGraph
        return ()
createMenuButton title menuFun gi = Button title
  $ \ (_, descr) -> do
    ost <- readIORef $ intState gi
    case i_state ost of
      Nothing -> return ()
      Just ist -> do
        let le = i_libEnv ist
            dGraph = lookupDGraph (libName gi) le
        menuFun descr dGraph
        return ()